xmonad / xmonad-contrib

Contributed modules for xmonad
https://xmonad.org
BSD 3-Clause "New" or "Revised" License
586 stars 274 forks source link

Additional Mouse Action #133

Open simlu opened 7 years ago

simlu commented 7 years ago

I'm trying to extend functionality for mouse buttons, so that we can hook other functionality plus the existing one (I.e. The left mouse button should still pass through to the program Gui, but also do other things).

This is the only somewhat successful attempt I could find, and I couldn't get it to work with the latest xmonad version: http://stackoverflow.com/questions/18304191/keyboard-free-mouse-gestures-for-xmonad

Will this require changes to the core or the contrib? Or is there a better solution we can define in xmonad.hs already?

geekosaur commented 7 years ago

Some notes on that SO answer:

  1. there is clickJustFocuses = False in recent (0.11 and later) xmonad, which passes clicks through. This is not general, however.

  2. xdotool, and the equivalent functionality from XMonad.Util.Paste, uses sendEvent (man 3 XSendEvent). The big caveat is that all events sent this way are marked by the X server as synthetic, and some programs and toolkits will ignore synthetic events.

  3. xmonad uses passive pointer (and keyboard) grabs for its mouse and key bindings. This ensures that the events in question always are given to xmonad... and that nothing else can ever see them. (Clicking to focus is a separate mechanism.) You cannot bind a mouse event in the normal way and also have it go to the client. What you can do, is register interest in general mouse events (which will then be sent to xmonad as well as to the clients; see clientMask and rootMask) in the root window and/or client windows, then intercept them in handleEventHook. Note that this means xmonad will be receiving a lot of extraneous events with this method.

simlu commented 7 years ago

Ah, that was good input. I'll test out some stuff and circle back here!

This seems like a promise reference for keys: http://stackoverflow.com/questions/6605399/how-can-i-set-an-action-to-occur-on-a-key-release-in-xmonad