Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can GNOME Shell extensions move the pointer? If so, how?

I want to write an extension that does the opposite of the "focus-follows mouse" setting in GNOME Shell: I want to make my pointer move to the center of the currently focused window.

Can this be done in a GNOME Shell extension? I see some GNOME code that wraps xfixes cursor, but I can't find any references to programmatic pointer updates in either the core Javascript or any existing extensions. (Am I just bad at Google?)

Valid answers include (1) example code that does it or (2) citation of a canonical source that says it can't be done.

like image 339
BrianTheLion Avatar asked Jan 04 '17 22:01

BrianTheLion


1 Answers

Found this code in overview.js

Gdk = imports.gi.Gdk
let display = Gdk.Display.get_default();
let deviceManager = display.get_device_manager();
let pointer = deviceManager.get_client_pointer();
let [screen, pointerX, pointerY] = pointer.get_position();
pointer.warp(screen, 10, 10);
like image 152
olejorgenb Avatar answered Sep 25 '22 02:09

olejorgenb