workspaceSwitcherPopup: Support horizontal layout

While mutter supports a variety of different grid layouts (n columns/rows,
growing vertically or horizontally from any of the four corners), we
hardcode a fixed vertical layout of a single column.

Now that mutter exposes the actual layout to us, add support for a more
traditional horizontal layout as well.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/575
This commit is contained in:
Florian Müllner
2019-06-04 19:22:26 +00:00
parent 43443d08ae
commit ab0f74aa15
3 changed files with 97 additions and 27 deletions

View File

@ -2132,6 +2132,8 @@ var WindowManager = class {
let [action,,, target] = binding.get_name().split('-');
let newWs;
let direction;
let vertical = workspaceManager.layout_rows == -1;
let rtl = Clutter.get_default_text_direction() == Clutter.TextDirection.RTL;
if (action == 'move') {
// "Moving" a window to another workspace doesn't make sense when
@ -2144,7 +2146,12 @@ var WindowManager = class {
}
if (target == 'last') {
direction = Meta.MotionDirection.DOWN;
if (vertical)
direction = Meta.MotionDirection.DOWN;
else if (rtl)
direction = Meta.MotionDirection.LEFT;
else
direction = Meta.MotionDirection.RIGHT;
newWs = workspaceManager.get_workspace_by_index(workspaceManager.n_workspaces - 1);
} else if (isNaN(target)) {
// Prepend a new workspace dynamically
@ -2160,16 +2167,33 @@ var WindowManager = class {
target--;
newWs = workspaceManager.get_workspace_by_index(target);
if (workspaceManager.get_active_workspace().index() > target)
direction = Meta.MotionDirection.UP;
else
direction = Meta.MotionDirection.DOWN;
if (workspaceManager.get_active_workspace().index() > target) {
if (vertical)
direction = Meta.MotionDirection.UP;
else if (rtl)
direction = Meta.MotionDirection.RIGHT;
else
direction = Meta.MotionDirection.LEFT;
} else {
if (vertical)
direction = Meta.MotionDirection.DOWN;
else if (rtl)
direction = Meta.MotionDirection.LEFT;
else
direction = Meta.MotionDirection.RIGHT;
}
}
if (direction != Meta.MotionDirection.UP &&
if (workspaceManager.layout_rows == -1 &&
direction != Meta.MotionDirection.UP &&
direction != Meta.MotionDirection.DOWN)
return;
if (workspaceManager.layout_columns == -1 &&
direction != Meta.MotionDirection.LEFT &&
direction != Meta.MotionDirection.RIGHT)
return;
if (action == 'switch')
this.actionMoveWorkspace(newWs);
else