workspacesView/workspacesDisplay: Scroll on horizontal layouts

WokspacesDisplay simply remaps the scroll direction into the next
workspace, but that doesn't account for the new horizontal layout.

Scroll horizontally on horizontal layouts when scroll direction is
on the vertical axis.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1603>
This commit is contained in:
Georges Basile Stavracas Neto 2021-01-02 17:56:57 -03:00 committed by Marge Bot
parent 0882074ecc
commit cffad8b749

View File

@ -772,14 +772,21 @@ class WorkspacesDisplay extends St.Widget {
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
let workspaceManager = global.workspace_manager; let workspaceManager = global.workspace_manager;
const vertical = workspaceManager.layout_rows === -1;
let activeWs = workspaceManager.get_active_workspace(); let activeWs = workspaceManager.get_active_workspace();
let ws; let ws;
switch (event.get_scroll_direction()) { switch (event.get_scroll_direction()) {
case Clutter.ScrollDirection.UP: case Clutter.ScrollDirection.UP:
if (vertical)
ws = activeWs.get_neighbor(Meta.MotionDirection.UP); ws = activeWs.get_neighbor(Meta.MotionDirection.UP);
else
ws = activeWs.get_neighbor(Meta.MotionDirection.LEFT);
break; break;
case Clutter.ScrollDirection.DOWN: case Clutter.ScrollDirection.DOWN:
if (vertical)
ws = activeWs.get_neighbor(Meta.MotionDirection.DOWN); ws = activeWs.get_neighbor(Meta.MotionDirection.DOWN);
else
ws = activeWs.get_neighbor(Meta.MotionDirection.RIGHT);
break; break;
case Clutter.ScrollDirection.LEFT: case Clutter.ScrollDirection.LEFT:
ws = activeWs.get_neighbor(Meta.MotionDirection.LEFT); ws = activeWs.get_neighbor(Meta.MotionDirection.LEFT);