Skip to content

Commit 7551c9d

Browse files
committed
Provide API for listening to workspace switch
1 parent b26a804 commit 7551c9d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/DesktopIntegration.vala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,20 @@ public class Gala.DesktopIntegration : GLib.Object {
2020
public uint version { get; default = 1; }
2121
public signal void running_applications_changed ();
2222
public signal void windows_changed ();
23+
public signal void active_workspace_changed ();
2324

2425
public DesktopIntegration (WindowManagerGala wm) {
2526
this.wm = wm;
2627
wm.window_tracker.windows_changed.connect (() => windows_changed ());
2728

2829
unowned var display = wm.get_display ();
2930
unowned var workspace_manager = display.get_workspace_manager ();
30-
workspace_manager.active_workspace_changed.connect (() => windows_changed ());
31+
workspace_manager.active_workspace_changed.connect (() => active_workspace_changed ());
3132
workspace_manager.workspaces_reordered.connect (() => windows_changed ());
3233
workspace_manager.workspace_added.connect (() => windows_changed ());
3334
workspace_manager.workspace_removed.connect (() => windows_changed ());
3435

36+
// TODO: figure out if there's a better way to handle ws rearrangement
3537
display.window_created.connect ((window) => {
3638
window.workspace_changed.connect (() => windows_changed ());
3739
});
@@ -90,7 +92,6 @@ public class Gala.DesktopIntegration : GLib.Object {
9092
properties.insert ("client-type", new GLib.Variant.uint32 (window.get_client_type ()));
9193
properties.insert ("is-hidden", new GLib.Variant.boolean (window.is_hidden ()));
9294
properties.insert ("has-focus", new GLib.Variant.boolean (window.has_focus ()));
93-
properties.insert ("on-active-workspace", new GLib.Variant.boolean (window.located_on_workspace (active_workspace)));
9495
properties.insert ("workspace-index", new GLib.Variant.int32 (window.get_workspace ().index ()));
9596
properties.insert ("width", new GLib.Variant.uint32 (frame_rect.width));
9697
properties.insert ("height", new GLib.Variant.uint32 (frame_rect.height));
@@ -148,6 +149,10 @@ public class Gala.DesktopIntegration : GLib.Object {
148149
return wm.get_display ().get_workspace_manager ().n_workspaces;
149150
}
150151

152+
public int get_active_workspace () throws GLib.DBusError, GLib.IOError {
153+
return wm.get_display ().get_workspace_manager ().get_active_workspace_index ();
154+
}
155+
151156
private bool notifying = false;
152157
private void notify_already_focused (Meta.Window window) {
153158
if (notifying) {

0 commit comments

Comments
 (0)