Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasresck committed Nov 25, 2023
2 parents 286b0ab + 3a5c9ee commit 6cb4ccb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
37 changes: 20 additions & 17 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,23 @@ import * as AltTab from "resource:///org/gnome/shell/ui/altTab.js";

import * as Overview from "resource:///org/gnome/shell/ui/overview.js";

const seat = Clutter.get_default_backend().get_default_seat();
const vdevice = seat.create_virtual_device(
Clutter.InputDeviceType.POINTER_DEVICE
);

function movePointer() {
const [x, y] = global.get_pointer();
vdevice.notify_absolute_motion(global.get_current_time(), x, y);
}

export default class AltTabScrollWorkaroundExtension extends Extension {
constructor(metadata) {
super(metadata);
enable() {
this._injectionManager = new InjectionManager();
}
const seat = Clutter.get_default_backend().get_default_seat();
this.vdevice = seat.create_virtual_device(
Clutter.InputDeviceType.POINTER_DEVICE
);

enable() {
// Fix for Alt+Tab (switch windows)
this._injectionManager.overrideMethod(
AltTab.WindowSwitcherPopup.prototype,
"_finish",
(originalMethod) => {
let that = this;
return function () {
movePointer();
that.movePointer();
originalMethod.call(this);
};
}
Expand All @@ -63,9 +56,10 @@ export default class AltTabScrollWorkaroundExtension extends Extension {
AltTab.AppSwitcherPopup.prototype,
"_finish",
(originalMethod) => {
let that = this;
return function (timestamp) {
if (this._currentWindow < 0) {
movePointer();
that.movePointer();
}
originalMethod.call(this, timestamp);
};
Expand All @@ -77,8 +71,9 @@ export default class AltTabScrollWorkaroundExtension extends Extension {
AltTab.WindowCyclerPopup.prototype,
"_finish",
(originalMethod) => {
let that = this;
return function () {
movePointer();
that.movePointer();
originalMethod.call(this);
};
}
Expand All @@ -89,15 +84,23 @@ export default class AltTabScrollWorkaroundExtension extends Extension {
Overview.Overview.prototype,
'_showDone',
(originalMethod) => {
let that = this;
return function () {
movePointer();
that.movePointer();
originalMethod.call(this);
};
}
);
}

movePointer() {
const [x, y] = global.get_pointer();
this.vdevice.notify_absolute_motion(global.get_current_time(), x, y);
}

disable() {
this._injectionManager.clear();
this._injectionManager = null;
this.vdevice = null;
}
}
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"uuid": "alt-tab-scroll-workaround@lucasresck.github.io",
"name": "Alt+Tab Scroll Workaround",
"description": "Quick fix to the bug where scrolling in one application is repeated in another when switching between them using Alt+Tab (e.g., VS Code and Chrome).",
"version": 5,
"version": 6,
"shell-version": ["45"],
"url": "https://github.com/lucasresck/gnome-shell-extension-alt-tab-scroll-workaround"
}

0 comments on commit 6cb4ccb

Please sign in to comment.