Skip to content

Commit c2f6647

Browse files
authored
Reorder workspaces (#2320)
1 parent cf68ff7 commit c2f6647

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/DesktopIntegration.vala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,15 @@ public class Gala.DesktopIntegration : GLib.Object {
244244

245245
wm.window_overview.open (hints);
246246
}
247+
248+
public void reorder_workspace (int index, int new_index) throws DBusError, IOError {
249+
unowned var workspace_manager = wm.get_display ().get_workspace_manager ();
250+
unowned var workspace = workspace_manager.get_workspace_by_index (index);
251+
252+
if (workspace == null) {
253+
throw new IOError.NOT_FOUND ("Invalid index, workspace not found");
254+
}
255+
256+
workspace_manager.reorder_workspace (workspace, new_index);
257+
}
247258
}

src/Widgets/MultitaskingView/MultitaskingView.vala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public class Gala.MultitaskingView : ActorTarget, ActivatableComponent {
9494
unowned var manager = display.get_workspace_manager ();
9595
manager.workspace_added.connect (add_workspace);
9696
manager.workspace_removed.connect (remove_workspace);
97-
manager.workspaces_reordered.connect (() => reposition_icon_groups (false));
97+
manager.workspaces_reordered.connect (on_workspaces_reordered);
9898
manager.workspace_switched.connect (on_workspace_switched);
9999

100100
manager.bind_property (
@@ -397,6 +397,15 @@ public class Gala.MultitaskingView : ActorTarget, ActivatableComponent {
397397
workspaces_gesture_controller.progress = -manager.get_active_workspace_index ();
398398
}
399399

400+
private void on_workspaces_reordered () {
401+
if (!visible) {
402+
unowned var manager = display.get_workspace_manager ();
403+
workspaces_gesture_controller.progress = -manager.get_active_workspace_index ();
404+
}
405+
406+
reposition_icon_groups (false);
407+
}
408+
400409
private void on_workspace_switched (int from, int to) {
401410
if ((int) (-get_current_commit (SWITCH_WORKSPACE)) != to) {
402411
workspaces_gesture_controller.goto (-to);

0 commit comments

Comments
 (0)