Skip to content

Commit 0230b5b

Browse files
authored
Unify move to workspace behaviour (#1562)
Also fixes a bug where trying to move window to non-existing workspaces resulted it stuck to top when switching workspace afterwards. Resolves #1081
1 parent c1b5cb3 commit 0230b5b

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

data/gala.appdata.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<issue url="https://github.com/elementary/gala/issues/510">PiP doesn't respect animations key</issue>
2727
<issue url="https://github.com/elementary/gala/issues/849">Picture-in-Picture area selection being offset</issue>
2828
<issue url="https://github.com/elementary/gala/issues/975">Accidental middle click to close workspace</issue>
29+
<issue url="https://github.com/elementary/gala/issues/1081">"Move to Workspace" window menu action doesn't match what the Keyboard Shortcut do</issue>
2930
<issue url="https://github.com/elementary/gala/issues/1185">Unmaximize effect not working with mutter >= 3.38</issue>
3031
<issue url="https://github.com/elementary/gala/issues/1203">Artifact around non native apps in the overview mode</issue>
3132
<issue url="https://github.com/elementary/gala/issues/1478">PiP: Log spam on elementary OS 7.0</issue>

src/WindowManager.vala

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -674,25 +674,33 @@ namespace Gala {
674674
* {@inheritDoc}
675675
*/
676676
public void move_window (Meta.Window? window, Meta.MotionDirection direction) {
677-
if (window == null)
677+
if (window == null) {
678678
return;
679+
}
679680

680681
unowned Meta.Display display = get_display ();
681682
unowned Meta.WorkspaceManager manager = display.get_workspace_manager ();
682683

683-
var active = manager.get_active_workspace ();
684-
var next = active.get_neighbor (direction);
684+
unowned var active = manager.get_active_workspace ();
685+
unowned var next = active.get_neighbor (direction);
685686

686-
//dont allow empty workspaces to be created by moving, if we have dynamic workspaces
687+
// don't allow empty workspaces to be created by moving, if we have dynamic workspaces
687688
if (Meta.Prefs.get_dynamic_workspaces () && Utils.get_n_windows (active) == 1 && next.index () == manager.n_workspaces - 1) {
688689
Utils.bell (display);
689690
return;
690691
}
691692

693+
// don't allow moving into non-existing workspaces
694+
if (active == next) {
695+
Utils.bell (display);
696+
return;
697+
}
698+
692699
moving = window;
693700

694-
if (!window.is_on_all_workspaces ())
701+
if (!window.is_on_all_workspaces ()) {
695702
window.change_workspace (next);
703+
}
696704

697705
next.activate_with_focus (window, display.get_current_time ());
698706
}
@@ -837,18 +845,10 @@ namespace Gala {
837845
current.stick ();
838846
break;
839847
case ActionType.MOVE_CURRENT_WORKSPACE_LEFT:
840-
if (current != null) {
841-
var wp = current.get_workspace ().get_neighbor (Meta.MotionDirection.LEFT);
842-
if (wp != null)
843-
current.change_workspace (wp);
844-
}
848+
move_window (current, Meta.MotionDirection.LEFT);
845849
break;
846850
case ActionType.MOVE_CURRENT_WORKSPACE_RIGHT:
847-
if (current != null) {
848-
var wp = current.get_workspace ().get_neighbor (Meta.MotionDirection.RIGHT);
849-
if (wp != null)
850-
current.change_workspace (wp);
851-
}
851+
move_window (current, Meta.MotionDirection.RIGHT);
852852
break;
853853
case ActionType.CLOSE_CURRENT:
854854
if (current != null && current.can_close ())

0 commit comments

Comments
 (0)