Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DesktopIntegration: add 'time-appeared-on-workspace' property #2285

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/DesktopIntegration.vala
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,24 @@ public class Gala.DesktopIntegration : GLib.Object {
GLib.HashTable<unowned string, Variant> properties;
}

private unowned WindowManagerGala wm;
public uint version { get; default = 1; }
public signal void running_applications_changed ();
public signal void windows_changed ();
public signal void active_workspace_changed ();
public signal void workspace_removed (int index);

private unowned WindowManagerGala wm;
private GLib.HashTable<Meta.Window, int64?> time_appeared_on_workspace;

public DesktopIntegration (WindowManagerGala wm) {
this.wm = wm;
time_appeared_on_workspace = new GLib.HashTable<Meta.Window, int64?> (GLib.direct_hash, GLib.direct_equal);

wm.window_tracker.windows_changed.connect (() => windows_changed ());

unowned var display = wm.get_display ();
unowned var workspace_manager = display.get_workspace_manager ();

workspace_manager.active_workspace_changed.connect (() => {
active_workspace_changed ();
windows_changed (); // windows have 'on-active-workspace' property that we need to update
Expand All @@ -42,7 +47,16 @@ public class Gala.DesktopIntegration : GLib.Object {

// TODO: figure out if there's a better way to handle ws rearrangement
display.window_created.connect ((window) => {
window.workspace_changed.connect (() => windows_changed ());
time_appeared_on_workspace[window] = GLib.get_monotonic_time ();

window.workspace_changed.connect ((_window) => {
time_appeared_on_workspace[_window] = GLib.get_monotonic_time ();
windows_changed ();
});

window.unmanaging.connect ((_window) => {
time_appeared_on_workspace.remove (_window);
});
});
}

Expand Down Expand Up @@ -117,6 +131,10 @@ public class Gala.DesktopIntegration : GLib.Object {
properties.insert ("sandboxed-app-id", new GLib.Variant.string (sandboxed_app_id));
}

if (window in time_appeared_on_workspace && time_appeared_on_workspace[window] != null) {
properties.insert ("time-appeared-on-workspace", new GLib.Variant.int64 (time_appeared_on_workspace[window]));
}

returned_windows += Window () {
uid = window.get_id (),
properties = properties
Expand Down