workspacesView: Fix PgUp/PgDown shortcut

We still try to switch to the workspace above/below, which doesn't
do anything since the layout is now horizontal.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1798>
This commit is contained in:
Florian Müllner 2021-04-08 17:19:37 +02:00
parent dda23fc4c6
commit fc54e0bed8

View File

@ -1144,19 +1144,35 @@ class WorkspacesDisplay extends St.Widget {
_onKeyPressEvent(actor, event) { _onKeyPressEvent(actor, event) {
if (!this.mapped) if (!this.mapped)
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
let workspaceManager = global.workspace_manager;
let activeWs = workspaceManager.get_active_workspace(); const { workspaceManager } = global;
let ws; const vertical = workspaceManager.layout_rows === -1;
const rtl = this.get_text_direction() === Clutter.TextDirection.RTL;
let dir;
switch (event.get_key_symbol()) { switch (event.get_key_symbol()) {
case Clutter.KEY_Page_Up: case Clutter.KEY_Page_Up:
ws = activeWs.get_neighbor(Meta.MotionDirection.UP); if (vertical)
dir = Meta.MotionDirection.UP;
else if (rtl)
dir = Meta.MotionDirection.RIGHT;
else
dir = Meta.MotionDirection.LEFT;
break; break;
case Clutter.KEY_Page_Down: case Clutter.KEY_Page_Down:
ws = activeWs.get_neighbor(Meta.MotionDirection.DOWN); if (vertical)
dir = Meta.MotionDirection.DOWN;
else if (rtl)
dir = Meta.MotionDirection.LEFT;
else
dir = Meta.MotionDirection.RIGHT;
break; break;
default: default:
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }
const ws = workspaceManager.get_active_workspace().get_neighbor(dir);
if (ws)
Main.wm.actionMoveWorkspace(ws); Main.wm.actionMoveWorkspace(ws);
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }