How to bind Modifier+MouseButton in GJS?

First, events start at the reactive actor “closest” to the event, and only bubble up to the parent if the event wasn’t handled. That is, clicks on any actor that return Clutter.EVENT_STOP from their own handler will stop the event and it won’t reach the stage.

You could get around that by using captured-event::button, as that is emitted first on the stage and then bubbles down to the actor under the pointer, however that still won’t work for windows:

Mutter filters all events beore they are processed normally by Clutter, and events that are processed either by mutter itself (shortcuts, gestures, window drag operations etc.) or by clients (clicks inside windows, keyboard events while a window has key focus etc.) aren’t passed on to Clutter. And even if they were, the client would already have processed the event, which isn’t what you want anyway.

There never was such a signal on MetaDisplay. There is API for (un)registering keyboard shortcuts, but no equivalent for global “mouse shortcuts”.

Indeed, and also likely to break stuff left-and-right.

I’m afraid the best option isn’t quick and easy: Instead of trying to find a way to work around mutter’s event machinery, implement new API for “mouse shortcuts” and propose its inclusion in mutter. That would give you (and others) a clean way for building functionality on top.

1 Like