Skip to content

Commit 1ba00d4

Browse files
committed
DesktopIntegration: Allow to move windows to another workspace
1 parent 84a47b7 commit 1ba00d4

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/DesktopIntegration.vala

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,19 +143,31 @@ public class Gala.DesktopIntegration : GLib.Object {
143143
return (owned) returned_windows;
144144
}
145145

146-
public void focus_window (uint64 uid) throws GLib.DBusError, GLib.IOError {
146+
private Meta.Window find_window_by_uid (uint64 uid) throws IOError {
147147
var apps = Gala.AppSystem.get_default ().get_running_apps ();
148148
foreach (unowned var app in apps) {
149149
foreach (weak Meta.Window window in app.get_windows ()) {
150150
if (window.get_id () == uid) {
151-
if (window.has_focus ()) {
152-
notify_already_focused (window);
153-
} else {
154-
window.get_workspace ().activate_with_focus (window, wm.get_display ().get_current_time ());
155-
}
151+
return window;
156152
}
157153
}
158154
}
155+
156+
throw new IOError.NOT_FOUND ("Window with UID " + uid.to_string () + " not found");
157+
}
158+
159+
public void focus_window (uint64 uid) throws GLib.DBusError, GLib.IOError {
160+
var window = find_window_by_uid (uid);
161+
if (window.has_focus ()) {
162+
notify_already_focused (window);
163+
} else {
164+
window.get_workspace ().activate_with_focus (window, wm.get_display ().get_current_time ());
165+
}
166+
}
167+
168+
public void move_window_to_workspace (uint64 uid, int index) throws DBusError, IOError {
169+
var window = find_window_by_uid (uid);
170+
window.change_workspace_by_index (index, false);
159171
}
160172

161173
public void activate_workspace (int index) throws GLib.DBusError, GLib.IOError {

0 commit comments

Comments
 (0)