Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions [email protected]/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export default class Prefs extends ExtensionPreferences {
'Next/Previous Bordered',
], settings));

group.add(this._createSwitcherRow('Force horizontal scroll', 'force-horizontal-scroll', settings));

group = new Adw.PreferencesGroup({
title: _('Popup Settings'),
});
Expand Down
Binary file modified [email protected]/schemas/gschemas.compiled
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
<range min="1" max="36"/>
<summary>Number of rows of workspaces</summary>
</key>
<key type="b" name="force-horizontal-scroll">
<default>false</default>
<summary>Whether to force workspace scrolling to only work horizontally</summary>
</key>
<key type="b" name="show-popup">
<default>true</default>
<summary>Whether to show the popup or not</summary>
Expand Down
42 changes: 38 additions & 4 deletions [email protected]/workspacePopup/workspaceManagerOverride.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export default class WorkspaceManagerOverride {
this._overviewKeybindingActions = {};
this.monitors = [];

global._forceHorizontalScroll = this.settings.get_boolean('force-horizontal-scroll');

this._workspaceAnimation = new WorkspaceAnimationController();
this.overrideProperties = [
'_workspaceAnimation',
Expand Down Expand Up @@ -129,6 +131,11 @@ export default class WorkspaceManagerOverride {
'changed::enable-popup-workspace-hover',
this._destroyWorkspaceSwitcherPopup.bind(this)
);

this.settingsHandlerForceHorizontalScroll = this.settings.connect(
'changed::force-horizontal-scroll',
this._handleForceHorizontalScrollChanged.bind(this)
);
}

_disconnectSettings() {
Expand All @@ -141,6 +148,7 @@ export default class WorkspaceManagerOverride {
this.settings.disconnect(this.settingsHandlerWraparoundMode);
this.settings.disconnect(this.settingsHandlerShowWorkspaceNames);
this.settings.disconnect(this.settingsHandlerEnablePopupWorkspaceHover);
this.settings.disconnect(this.settingsHandlerForceHorizontalScroll);
}

_connectLayoutManager() {
Expand Down Expand Up @@ -331,24 +339,46 @@ export default class WorkspaceManagerOverride {

const workspaceManager = global.workspace_manager;
const activeWs = workspaceManager.get_active_workspace();
const currentIndex = workspaceManager.get_active_workspace_index();
const forceHorizontalScroll = global._forceHorizontalScroll;
let ws;
switch (direction) {
case Clutter.ScrollDirection.UP:
ws = activeWs.get_neighbor(Meta.MotionDirection.UP);
if (forceHorizontalScroll) {
ws = workspaceManager.get_workspace_by_index(currentIndex - 1);
} else {
ws = activeWs.get_neighbor(Meta.MotionDirection.UP);
}
break;
case Clutter.ScrollDirection.LEFT:
ws = activeWs.get_neighbor(Meta.MotionDirection.LEFT);
if (forceHorizontalScroll) {
ws = workspaceManager.get_workspace_by_index(currentIndex - 1);
} else {
ws = activeWs.get_neighbor(Meta.MotionDirection.LEFT);
}
break;
case Clutter.ScrollDirection.DOWN:
ws = activeWs.get_neighbor(Meta.MotionDirection.DOWN);
if (forceHorizontalScroll) {
ws = workspaceManager.get_workspace_by_index(currentIndex + 1);
} else {
ws = activeWs.get_neighbor(Meta.MotionDirection.DOWN);
}
break;
case Clutter.ScrollDirection.RIGHT:
ws = activeWs.get_neighbor(Meta.MotionDirection.RIGHT);
if (forceHorizontalScroll) {
ws = workspaceManager.get_workspace_by_index(currentIndex + 1);
} else {
ws = activeWs.get_neighbor(Meta.MotionDirection.RIGHT);
}
break;
default:
return Clutter.EVENT_PROPAGATE;
}

if (ws == null) {
return Clutter.EVENT_PROPAGATE;
}

this.actionMoveWorkspace(ws);

this._canScroll = false;
Expand Down Expand Up @@ -493,6 +523,10 @@ export default class WorkspaceManagerOverride {
this.wm._wsPopupList.filter(p => p).forEach(p => p.destroy());
}

_handleForceHorizontalScrollChanged() {
global._forceHorizontalScroll = this.settings.get_boolean('force-horizontal-scroll');
}

_getTargetWorkspace(direction) {
let newWs = this.wsManager.get_active_workspace().get_neighbor(direction);
let currentIndex = this.wsManager.get_active_workspace_index();
Expand Down