workspacesView: Allow workspace switching via scroll wheel
This is already possible over the workspace switcher, extend this behavior to the entire window picker area. https://bugzilla.gnome.org/show_bug.cgi?id=686639
This commit is contained in:
parent
2ac88a7fa6
commit
af219ce9e7
@ -28,7 +28,8 @@ const WorkspacesView = new Lang.Class({
|
|||||||
Name: 'WorkspacesView',
|
Name: 'WorkspacesView',
|
||||||
|
|
||||||
_init: function(workspaces) {
|
_init: function(workspaces) {
|
||||||
this.actor = new St.Widget({ style_class: 'workspaces-view' });
|
this.actor = new St.Widget({ style_class: 'workspaces-view',
|
||||||
|
reactive: true });
|
||||||
|
|
||||||
// The actor itself isn't a drop target, so we don't want to pick on its area
|
// The actor itself isn't a drop target, so we don't want to pick on its area
|
||||||
this.actor.set_size(0, 0);
|
this.actor.set_size(0, 0);
|
||||||
@ -475,6 +476,7 @@ const WorkspacesDisplay = new Lang.Class({
|
|||||||
this._notifyOpacityId = 0;
|
this._notifyOpacityId = 0;
|
||||||
this._swipeScrollBeginId = 0;
|
this._swipeScrollBeginId = 0;
|
||||||
this._swipeScrollEndId = 0;
|
this._swipeScrollEndId = 0;
|
||||||
|
this._scrollEventId = 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
_onPan: function(action) {
|
_onPan: function(action) {
|
||||||
@ -490,6 +492,8 @@ const WorkspacesDisplay = new Lang.Class({
|
|||||||
this._restackedNotifyId =
|
this._restackedNotifyId =
|
||||||
Main.overview.connect('windows-restacked',
|
Main.overview.connect('windows-restacked',
|
||||||
Lang.bind(this, this._onRestacked));
|
Lang.bind(this, this._onRestacked));
|
||||||
|
if (this._scrollEventId == 0)
|
||||||
|
this._scrollEventId = Main.overview.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
|
||||||
},
|
},
|
||||||
|
|
||||||
zoomFromOverview: function() {
|
zoomFromOverview: function() {
|
||||||
@ -503,6 +507,10 @@ const WorkspacesDisplay = new Lang.Class({
|
|||||||
Main.overview.disconnect(this._restackedNotifyId);
|
Main.overview.disconnect(this._restackedNotifyId);
|
||||||
this._restackedNotifyId = 0;
|
this._restackedNotifyId = 0;
|
||||||
}
|
}
|
||||||
|
if (this._scrollEventId > 0) {
|
||||||
|
Main.overview.disconnect(this._scrollEventId);
|
||||||
|
this._scrollEventId = 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (let i = 0; i < this._workspacesViews.length; i++)
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
||||||
this._workspacesViews[i].destroy();
|
this._workspacesViews[i].destroy();
|
||||||
@ -548,6 +556,7 @@ const WorkspacesDisplay = new Lang.Class({
|
|||||||
this._workspaces.push(monitorWorkspaces);
|
this._workspaces.push(monitorWorkspaces);
|
||||||
|
|
||||||
let view = new WorkspacesView(monitorWorkspaces);
|
let view = new WorkspacesView(monitorWorkspaces);
|
||||||
|
view.actor.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
|
||||||
if (this._workspacesOnlyOnPrimary || i == this._primaryIndex) {
|
if (this._workspacesOnlyOnPrimary || i == this._primaryIndex) {
|
||||||
this._scrollAdjustment = view.scrollAdjustment;
|
this._scrollAdjustment = view.scrollAdjustment;
|
||||||
this._scrollAdjustment.connect('notify::value',
|
this._scrollAdjustment.connect('notify::value',
|
||||||
@ -703,6 +712,20 @@ const WorkspacesDisplay = new Lang.Class({
|
|||||||
for (let i = 0; i < this._workspacesViews.length; i++)
|
for (let i = 0; i < this._workspacesViews.length; i++)
|
||||||
this._workspacesViews[i].updateWorkspaces(oldNumWorkspaces,
|
this._workspacesViews[i].updateWorkspaces(oldNumWorkspaces,
|
||||||
newNumWorkspaces);
|
newNumWorkspaces);
|
||||||
|
},
|
||||||
|
|
||||||
|
_onScrollEvent: function(actor, event) {
|
||||||
|
if (!this.actor.mapped)
|
||||||
|
return false;
|
||||||
|
switch (event.get_scroll_direction()) {
|
||||||
|
case Clutter.ScrollDirection.UP:
|
||||||
|
Main.wm.actionMoveWorkspace(Meta.MotionDirection.UP);
|
||||||
|
return true;
|
||||||
|
case Clutter.ScrollDirection.DOWN:
|
||||||
|
Main.wm.actionMoveWorkspace(Meta.MotionDirection.DOWN);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Signals.addSignalMethods(WorkspacesDisplay.prototype);
|
Signals.addSignalMethods(WorkspacesDisplay.prototype);
|
||||||
|
Loading…
Reference in New Issue
Block a user