MCPcopy Create free account
hub / github.com/GNOME/gnome-shell / handleWorkspaceScroll

Method handleWorkspaceScroll

js/ui/windowManager.js:1874–1925  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

1872 }
1873
1874 handleWorkspaceScroll(event) {
1875 if (!this._canScroll)
1876 return Clutter.EVENT_PROPAGATE;
1877
1878 if (event.type() !== Clutter.EventType.SCROLL)
1879 return Clutter.EVENT_PROPAGATE;
1880
1881 const direction = event.get_scroll_direction();
1882 if (direction === Clutter.ScrollDirection.SMOOTH)
1883 return Clutter.EVENT_PROPAGATE;
1884
1885 const workspaceManager = global.workspace_manager;
1886 const vertical = workspaceManager.layout_rows === -1;
1887 const rtl = Clutter.get_default_text_direction() === Clutter.TextDirection.RTL;
1888 const activeWs = workspaceManager.get_active_workspace();
1889 let ws;
1890 switch (direction) {
1891 case Clutter.ScrollDirection.UP:
1892 if (vertical)
1893 ws = activeWs.get_neighbor(Meta.MotionDirection.UP);
1894 else if (rtl)
1895 ws = activeWs.get_neighbor(Meta.MotionDirection.RIGHT);
1896 else
1897 ws = activeWs.get_neighbor(Meta.MotionDirection.LEFT);
1898 break;
1899 case Clutter.ScrollDirection.DOWN:
1900 if (vertical)
1901 ws = activeWs.get_neighbor(Meta.MotionDirection.DOWN);
1902 else if (rtl)
1903 ws = activeWs.get_neighbor(Meta.MotionDirection.LEFT);
1904 else
1905 ws = activeWs.get_neighbor(Meta.MotionDirection.RIGHT);
1906 break;
1907 case Clutter.ScrollDirection.LEFT:
1908 ws = activeWs.get_neighbor(Meta.MotionDirection.LEFT);
1909 break;
1910 case Clutter.ScrollDirection.RIGHT:
1911 ws = activeWs.get_neighbor(Meta.MotionDirection.RIGHT);
1912 break;
1913 default:
1914 return Clutter.EVENT_PROPAGATE;
1915 }
1916 this.actionMoveWorkspace(ws);
1917
1918 this._canScroll = false;
1919 GLib.timeout_add_once(GLib.PRIORITY_DEFAULT,
1920 SCROLL_TIMEOUT_TIME, () => {
1921 this._canScroll = true;
1922 });
1923
1924 return Clutter.EVENT_STOP;
1925 }
1926
1927 _confirmDisplayChange() {
1928 const dialog = new DisplayChangeDialog(this._shellwm);

Callers 3

constructorMethod · 0.95
_onScrollEventMethod · 0.80
vfunc_scroll_eventMethod · 0.80

Calls 1

actionMoveWorkspaceMethod · 0.95

Tested by

no test coverage detected