Skip to content

Commit a18c865

Browse files
committed
Add activate_workspace method
1 parent 35c74f0 commit a18c865

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/DesktopIntegration.vala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class Gala.DesktopIntegration : GLib.Object {
1717
}
1818

1919
public struct Workspace {
20+
uint index;
2021
Window[] windows;
2122
}
2223

@@ -137,6 +138,10 @@ public class Gala.DesktopIntegration : GLib.Object {
137138
public Workspace[] get_workspaces () throws GLib.DBusError, GLib.IOError {
138139
var n_workspaces = wm.get_display ().get_workspace_manager ().n_workspaces;
139140
var workspaces = new Workspace[n_workspaces];
141+
142+
for (var i = 0; i < workspaces.length; i++) {
143+
workspaces[i].index = i;
144+
}
140145

141146
var apps = Gala.AppSystem.get_default ().get_running_apps ();
142147
foreach (unowned var app in apps) {
@@ -175,6 +180,18 @@ public class Gala.DesktopIntegration : GLib.Object {
175180
}
176181
}
177182

183+
public void activate_workspace (int index) throws GLib.DBusError, GLib.IOError {
184+
unowned var workspace = wm.get_display ().get_workspace_manager ().get_workspace_by_index (index);
185+
if (workspace == null) {
186+
critical ("...");
187+
// throw error maybe...
188+
return;
189+
}
190+
191+
warning ("Activating");
192+
workspace.activate (wm.get_display ().get_current_time ());
193+
}
194+
178195
private bool notifying = false;
179196
private void notify_already_focused (Meta.Window window) {
180197
if (notifying) {

0 commit comments

Comments
 (0)