Skip to content

Commit f589b45

Browse files
committed
Add 'time-appeared-on-workspace' property
1 parent 14e3432 commit f589b45

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/DesktopIntegration.vala

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,19 @@ public class Gala.DesktopIntegration : GLib.Object {
1616
GLib.HashTable<unowned string, Variant> properties;
1717
}
1818

19-
private unowned WindowManagerGala wm;
2019
public uint version { get; default = 1; }
2120
public signal void running_applications_changed ();
2221
public signal void windows_changed ();
2322
public signal void active_workspace_changed ();
2423
public signal void workspace_removed (int index);
24+
25+
private unowned WindowManagerGala wm;
26+
private GLib.HashTable<Meta.Window, int64?> time_appeared_on_workspace;
2527

2628
public DesktopIntegration (WindowManagerGala wm) {
2729
this.wm = wm;
30+
time_appeared_on_workspace = new GLib.HashTable<Meta.Window, int64?> (GLib.direct_hash, GLib.direct_equal);
31+
2832
wm.window_tracker.windows_changed.connect (() => windows_changed ());
2933

3034
unowned var display = wm.get_display ();
@@ -42,7 +46,16 @@ public class Gala.DesktopIntegration : GLib.Object {
4246

4347
// TODO: figure out if there's a better way to handle ws rearrangement
4448
display.window_created.connect ((window) => {
45-
window.workspace_changed.connect (() => windows_changed ());
49+
time_appeared_on_workspace[window] = GLib.get_real_time ();
50+
51+
window.workspace_changed.connect ((_window) => {
52+
time_appeared_on_workspace[_window] = GLib.get_real_time ();
53+
windows_changed ();
54+
});
55+
56+
window.unmanaging.connect ((_window) => {
57+
time_appeared_on_workspace.remove (_window);
58+
});
4659
});
4760
}
4861

@@ -117,6 +130,10 @@ public class Gala.DesktopIntegration : GLib.Object {
117130
properties.insert ("sandboxed-app-id", new GLib.Variant.string (sandboxed_app_id));
118131
}
119132

133+
if (window in time_appeared_on_workspace && time_appeared_on_workspace[window] != null) {
134+
properties.insert ("time-appeared-on-workspace", new GLib.Variant.int64 (time_appeared_on_workspace[window]));
135+
}
136+
120137
returned_windows += Window () {
121138
uid = window.get_id (),
122139
properties = properties

0 commit comments

Comments
 (0)