Globally grab mousewheel scroll events



Hi.

Being a visually impaired coder, a 'killer feature' for me is the ability to zoom the desktop in/out using the mouse wheel together with a modifier key such as <shift>, <ctrl> or similar. This functionality is supported by the 'Enhanced Desktop Zoom' feature in compiz-based desktops and by OSX out-of-the box (not in Windows however...).

Currently this is not supported in a gnome-shell/wayland environment such as Ubuntu 17.10 so I thought I might take a stab at implementing this. I am however completely new to the whole gnome ecosystem so I have spent a couple of days trying to read-up on relevant concepts such as Wayland, Clutter, Mutter, Gjs, gnome-shell, etc.

The main technical problem seems to be how to globally grab the Clutter.EventType.SCROLL events when a modifier key is pressed and I would be thankful for all help and pointers to the best way to accomplish this (if possible).

My research so far seems to indicate the following:

1. There is a gnome-shell extension written in Vala by Tobias Quinn (https://github.com/tobiasquinn/gnome-shell-mousewheel-zoom) that accomplishes what I want but as I understand it, it requires gnome-shell to run under X and not Wayland.
2. It is possible to globally grab key combinations from within a gnome-shell extension using the 'accelerator-activated' signal like this:
 global.display.connect('accelerator-activated',...
(see https://stackoverflow.com/questions/12325405/gnome-shell-extension-key-binding#42466781 for the source of this)
3. I have not succeeded in receiving scroll events when connecting to the 'scroll-event' or 'captured-event' signals on 'high-level' actors such as global.stage or Main.layoutManager.uiGroup. My guess is that the scroll events are routed directly to the actor under the mouse cursor and swallowed by them, thus not propagated upwards in the scene graph.
4. The Magnifier included in the gnome-shell uses a number of 'special' techniques to accomplish its task
  - to follow the mouse it gets hold of a 'CursorTracker' that Mutter provides. (in src/meta/meta-cursor-tracker.h) but the CursorTracker only seems to care about pointer position and not about scroll events.
  - to register global listeners for 'focus change' and 'caret change' it uses the Atspi library but I haven't had the time to try to see if this library also supports a global listener for scroll events.

The best hypothesis I have come up with so far is to emulate the behaviour of the SwitcherPopup and write a gnome-shell extension that:
 - globally captures a key combination
 - implement an invisible actor that covers the whole screen and 'pops up' when the key combination above is captured (and destroyed when the keys are released).
 - use the scroll-events that are received by the invisible actor to change the magnification factor for the magnifier in 'real time'.

If the above would work, a draw-back would be that I can't just press <shift> and scroll but have to press a valid accelerator combo (e.g. <ctrl>+<shift>+'a' or similar) which would make it less ergonomical and swift.

So, any ideas about how to accomplish a global grab of mousewheel scroll together with a single modifier key?

Regards
/Anders



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]