Skip to content

Commit 8b56f4d

Browse files
rcalixtemtwebster
authored andcommitted
Adding a setting to warp mouse pointer after Alt+Tab action completes
1 parent eb3371a commit 8b56f4d

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

data/org.cinnamon.gschema.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,11 @@
429429
<summary>Show all windows from all workspaces</summary>
430430
</key>
431431

432+
<key type="b" name="alttab-switcher-warp-mouse-pointer">
433+
<default>false</default>
434+
<summary>Warp mouse pointer to the new focused window</summary>
435+
</key>
436+
432437
<key name="bring-windows-to-current-workspace" type="b">
433438
<default>false</default>
434439
<summary>not used - lives in org.cinnamon.muffin now</summary>

files/usr/share/cinnamon/cinnamon-settings/modules/cs_windows.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,6 @@ def update_setting(widget, pspec):
178178

179179
widget = GSettingsSwitch(_("Show windows from all workspaces"), "org.cinnamon", "alttab-switcher-show-all-workspaces")
180180
settings.add_row(widget)
181+
182+
widget = GSettingsSwitch(_("Warp mouse pointer to the new focused window"), "org.cinnamon", "alttab-switcher-warp-mouse-pointer")
183+
settings.add_row(widget)

js/ui/appSwitcher/appSwitcher.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,17 @@ AppSwitcher.prototype = {
428428
},
429429

430430
_activateSelected: function() {
431-
let workspace_num = this._windows[this._currentIndex].get_workspace().index();
432-
Main.activateWindow(this._windows[this._currentIndex], global.get_current_time(), workspace_num);
431+
const _window = this._windows[this._currentIndex]
432+
const workspace_num = _window.get_workspace().index();
433+
Main.activateWindow(_window, global.get_current_time(), workspace_num);
434+
this._warpMouse = global.settings.get_boolean("alttab-switcher-warp-mouse-pointer");
435+
if (this._warpMouse) {
436+
const rect = _window.get_frame_rect();
437+
const x = rect.x + rect.width / 2;
438+
const y = rect.y + rect.height / 2;
439+
this._pointer = Clutter.get_default_backend().get_default_seat().create_virtual_device(Clutter.InputDeviceType.POINTER_DEVICE);
440+
this._pointer.notify_absolute_motion(global.get_current_time(), x, y);
441+
}
433442
if (!this._destroyed)
434443
this.destroy();
435444
},

0 commit comments

Comments
 (0)