Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option setting the direction of switching workspace #348

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

UUID = [email protected]
BASE_MODULES = extension.js stylesheet.css metadata.json COPYING README.md
EXTRA_MODULES = convenience.js dash.js docking.js appIcons.js intellihide.js prefs.js theming.js Settings.ui
EXTRA_MODULES = convenience.js dash.js docking.js appIcons.js intellihide.js prefs.js theming.js Settings.ui myWorkspaceSwitcherPopup.js
EXTRA_MEDIA = logo.svg
TOLOCALIZE = prefs.js
MSGSRC = $(wildcard po/*.po)
Expand Down
16 changes: 16 additions & 0 deletions Settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,22 @@
<property name="height">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="switch_workspace_horizontal_button">
<property name="label" translatable="yes">In horizontal direction</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="margin_top">12</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="width">2</property>
</packing>
</child>
</object>
</child>
</object>
Expand Down
64 changes: 49 additions & 15 deletions docking.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const Convenience = Me.imports.convenience;
const Intellihide = Me.imports.intellihide;
const Theming = Me.imports.theming;
const MyDash = Me.imports.dash;
const MyWorkspaceSwitcherPopup = Me.imports.myWorkspaceSwitcherPopup;

const DOCK_DWELL_CHECK_INTERVAL = 100;

Expand Down Expand Up @@ -515,6 +516,10 @@ const DockedDash = new Lang.Class({
this._optionalScrollWorkspaceSwitch(this._settings.get_boolean('scroll-switch-workspace'));
}));

this._settings.connect('changed::switch-workspace-horizontal', Lang.bind(this, function() {
this._optionalScrollWorkspaceSwitch(this._settings.get_boolean('scroll-switch-workspace'));
}));

this._settings.connect('changed::dash-max-icon-size', Lang.bind(this, function() {
this.dash.setIconSize(this._settings.get_int('dash-max-icon-size'));
}));
Expand Down Expand Up @@ -1290,6 +1295,13 @@ const DockedDash = new Lang.Class({
Lang.bind(this, disable)();
}));

this._settings.connect('changed::switch-workspace-horizontal', Lang.bind(this, function() {
if (this._settings.get_boolean('switch-workspace-horizontal'))
this._horizontalWorkspace = true;
else
this._horizontalWorkspace = false;
}));

if (this._settings.get_boolean('scroll-switch-workspace'))
Lang.bind(this, enable)();

Expand All @@ -1303,6 +1315,11 @@ const DockedDash = new Lang.Class({
]);

this._optionalScrollWorkspaceSwitchDeadTimeId = 0;

if (this._settings.get_boolean('switch-workspace-horizontal'))
this._horizontalWorkspace = true;
else
this._horizontalWorkspace = false;
}

function disable() {
Expand All @@ -1325,17 +1342,30 @@ const DockedDash = new Lang.Class({

switch (event.get_scroll_direction()) {
case Clutter.ScrollDirection.UP:
direction = Meta.MotionDirection.UP;
if (this._horizontalWorkspace)
direction = Meta.MotionDirection.LEFT;
else
direction = Meta.MotionDirection.UP;
break;
case Clutter.ScrollDirection.DOWN:
direction = Meta.MotionDirection.DOWN;
if (this._horizontalWorkspace)
direction = Meta.MotionDirection.RIGHT;
else
direction = Meta.MotionDirection.DOWN;
break;
case Clutter.ScrollDirection.SMOOTH:
let [dx, dy] = event.get_scroll_delta();
if (dy < 0)
direction = Meta.MotionDirection.UP;
else if (dy > 0)
direction = Meta.MotionDirection.DOWN;
if (this._horizontalWorkspace) {
if (dx < 0)
direction = Meta.MotionDirection.LEFT;
else if (dx > 0)
direction = Meta.MotionDirection.RIGHT;
} else {
if (dy < 0)
direction = Meta.MotionDirection.UP;
else if (dy > 0)
direction = Meta.MotionDirection.DOWN;
}
break;
}

Expand All @@ -1356,16 +1386,20 @@ const DockedDash = new Lang.Class({

ws = activeWs.get_neighbor(direction)

if (Main.wm._workspaceSwitcherPopup == null)
Main.wm._workspaceSwitcherPopup = new WorkspaceSwitcherPopup.WorkspaceSwitcherPopup();
// Set the actor non reactive, so that it doesn't prevent the
// clicks events from reaching the dash actor. I can't see a reason
// why it should be reactive.
Main.wm._workspaceSwitcherPopup.actor.reactive = false;
Main.wm._workspaceSwitcherPopup.connect('destroy', function() {
Main.wm._workspaceSwitcherPopup = null;
});
if (Main.wm._workspaceSwitcherPopup == null) {
if (this._horizontalWorkspace)
Main.wm._workspaceSwitcherPopup = new MyWorkspaceSwitcherPopup.myWorkspaceSwitcherPopup();
else
Main.wm._workspaceSwitcherPopup = new WorkspaceSwitcherPopup.WorkspaceSwitcherPopup();
}

// Set the actor non reactive, so that it doesn't prevent the
// clicks events from reaching the dash actor. I can't see a reason
// why it should be reactive.
Main.wm._workspaceSwitcherPopup.actor.reactive = false;
Main.wm._workspaceSwitcherPopup.connect('destroy', function() {
Main.wm._workspaceSwitcherPopup = null;
});
// Do not show wokspaceSwithcer in overview
if (!Main.overview.visible)
Main.wm._workspaceSwitcherPopup.display(direction, ws.index());
Expand Down
Loading