mirror of
https://github.com/morgan9e/dash-to-panel
synced 2026-04-14 00:04:17 +09:00
Change focused window when scrolling over appIcon
This commit is contained in:
35
appIcons.js
35
appIcons.js
@@ -197,6 +197,8 @@ var taskbarAppIcon = Utils.defineClass({
|
||||
Lang.bind(this, this._updateWindowTitle));
|
||||
}
|
||||
|
||||
this._scrollEventId = this.actor.connect('scroll-event', this._onMouseScroll.bind(this));
|
||||
|
||||
this._overviewWindowDragEndId = Main.overview.connect('window-drag-end',
|
||||
Lang.bind(this, this._onOverviewWindowDragEnd));
|
||||
|
||||
@@ -296,6 +298,10 @@ var taskbarAppIcon = Utils.defineClass({
|
||||
this.actor.disconnect(this._hoverChangeId);
|
||||
}
|
||||
|
||||
if (this._scrollEventId) {
|
||||
this.actor.disconnect(this._scrollEventId);
|
||||
}
|
||||
|
||||
for (let i = 0; i < this._dtpSettingsSignalIds.length; ++i) {
|
||||
this._dtpSettings.disconnect(this._dtpSettingsSignalIds[i]);
|
||||
}
|
||||
@@ -334,6 +340,35 @@ var taskbarAppIcon = Utils.defineClass({
|
||||
});
|
||||
},
|
||||
|
||||
_onMouseScroll: function(actor, event) {
|
||||
if (!this.window && !this._nWindows) {
|
||||
return;
|
||||
}
|
||||
|
||||
let direction = Utils.getMouseScrollDirection(event);
|
||||
|
||||
if (direction) {
|
||||
let windows = this.getAppIconInterestingWindows();
|
||||
|
||||
windows.sort(Taskbar.sortWindowsCompareFunction);
|
||||
|
||||
let windowIndex = windows.indexOf(global.display.focus_window);
|
||||
let nextWindowIndex = windowIndex < 0 ?
|
||||
this.window ? windows.indexOf(this.window) : 0 :
|
||||
windowIndex + (direction == 'up' ? 1 : -1);
|
||||
|
||||
if (nextWindowIndex == windows.length) {
|
||||
nextWindowIndex = 0;
|
||||
} else if (nextWindowIndex < 0) {
|
||||
nextWindowIndex = windows.length - 1;
|
||||
}
|
||||
|
||||
if (windowIndex != nextWindowIndex) {
|
||||
Main.activateWindow(windows[nextWindowIndex]);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_showDots: function() {
|
||||
// Just update style if dots already exist
|
||||
if (this._focusedDots && this._unfocusedDots) {
|
||||
|
||||
13
panel.js
13
panel.js
@@ -743,18 +743,7 @@ var dtpPanelWrapper = Utils.defineClass({
|
||||
},
|
||||
|
||||
_onPanelMouseScroll: function(actor, event) {
|
||||
let direction = 0;
|
||||
|
||||
switch (event.get_scroll_direction()) {
|
||||
case Clutter.ScrollDirection.UP:
|
||||
case Clutter.ScrollDirection.LEFT:
|
||||
direction = 'up';
|
||||
break;
|
||||
case Clutter.ScrollDirection.DOWN:
|
||||
case Clutter.ScrollDirection.RIGHT:
|
||||
direction = 'down';
|
||||
break;
|
||||
}
|
||||
let direction = Utils.getMouseScrollDirection(event);
|
||||
|
||||
if (direction) {
|
||||
Main.wm._showWorkspaceSwitcher(global.display, 0, { get_name: () => 'switch---' + direction });
|
||||
|
||||
17
utils.js
17
utils.js
@@ -380,6 +380,23 @@ var getrgbaColor = function(color, alpha, offset) {
|
||||
return 'rgba(' + rgb.red + ',' + rgb.green + ',' + rgb.blue + ',' + (Math.floor(alpha * 100) * 0.01) + '); ' ;
|
||||
};
|
||||
|
||||
var getMouseScrollDirection = function(event) {
|
||||
let direction;
|
||||
|
||||
switch (event.get_scroll_direction()) {
|
||||
case Clutter.ScrollDirection.UP:
|
||||
case Clutter.ScrollDirection.LEFT:
|
||||
direction = 'up';
|
||||
break;
|
||||
case Clutter.ScrollDirection.DOWN:
|
||||
case Clutter.ScrollDirection.RIGHT:
|
||||
direction = 'down';
|
||||
break;
|
||||
}
|
||||
|
||||
return direction;
|
||||
};
|
||||
|
||||
/*
|
||||
* This is a copy of the same function in utils.js, but also adjust horizontal scrolling
|
||||
* and perform few further cheks on the current value to avoid changing the values when
|
||||
|
||||
Reference in New Issue
Block a user