workspacesView: Add Home and End keys for workspace navigation
This commit adds support for Home and End keys to move to the first and last workspace respectively. Previously only Page_Up and Page_Down were recognized to move one workspace at a time in overview mode. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2201>
This commit is contained in:
parent
0fded45c76
commit
af2838d535
@ -1158,31 +1158,46 @@ class WorkspacesDisplay extends St.Widget {
|
|||||||
const vertical = workspaceManager.layout_rows === -1;
|
const vertical = workspaceManager.layout_rows === -1;
|
||||||
const rtl = this.get_text_direction() === Clutter.TextDirection.RTL;
|
const rtl = this.get_text_direction() === Clutter.TextDirection.RTL;
|
||||||
|
|
||||||
let dir;
|
let which;
|
||||||
switch (event.get_key_symbol()) {
|
switch (event.get_key_symbol()) {
|
||||||
case Clutter.KEY_Page_Up:
|
case Clutter.KEY_Page_Up:
|
||||||
if (vertical)
|
if (vertical)
|
||||||
dir = Meta.MotionDirection.UP;
|
which = Meta.MotionDirection.UP;
|
||||||
else if (rtl)
|
else if (rtl)
|
||||||
dir = Meta.MotionDirection.RIGHT;
|
which = Meta.MotionDirection.RIGHT;
|
||||||
else
|
else
|
||||||
dir = Meta.MotionDirection.LEFT;
|
which = Meta.MotionDirection.LEFT;
|
||||||
break;
|
break;
|
||||||
case Clutter.KEY_Page_Down:
|
case Clutter.KEY_Page_Down:
|
||||||
if (vertical)
|
if (vertical)
|
||||||
dir = Meta.MotionDirection.DOWN;
|
which = Meta.MotionDirection.DOWN;
|
||||||
else if (rtl)
|
else if (rtl)
|
||||||
dir = Meta.MotionDirection.LEFT;
|
which = Meta.MotionDirection.LEFT;
|
||||||
else
|
else
|
||||||
dir = Meta.MotionDirection.RIGHT;
|
which = Meta.MotionDirection.RIGHT;
|
||||||
|
break;
|
||||||
|
case Clutter.KEY_Home:
|
||||||
|
which = 0;
|
||||||
|
break;
|
||||||
|
case Clutter.KEY_End:
|
||||||
|
which = workspaceManager.n_workspaces - 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return Clutter.EVENT_PROPAGATE;
|
return Clutter.EVENT_PROPAGATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ws = workspaceManager.get_active_workspace().get_neighbor(dir);
|
let ws;
|
||||||
|
if (which < 0)
|
||||||
|
// Negative workspace numbers are directions
|
||||||
|
// with respect to the current workspace
|
||||||
|
ws = workspaceManager.get_active_workspace().get_neighbor(which);
|
||||||
|
else
|
||||||
|
// Otherwise it is a workspace index
|
||||||
|
ws = workspaceManager.get_workspace_by_index(which);
|
||||||
|
|
||||||
if (ws)
|
if (ws)
|
||||||
Main.wm.actionMoveWorkspace(ws);
|
Main.wm.actionMoveWorkspace(ws);
|
||||||
|
|
||||||
return Clutter.EVENT_STOP;
|
return Clutter.EVENT_STOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user