
Hello xmonad world. My current desktop setup includes remote control unit, which sends keyboard events (for example, it sends Ctrl-P on Pause button). I want to handle such keypresses differently than keypresses from usual keyboard. For example, currently, if I press Ctrl-P on keyboard or Pause on the remote control, when Firefox window is active, both actions open Print dialog. But I want to run, for example, "mpc pause" on Pause button. AFAIK, one way to differ key/button press events from different devices is to use XInput X11 extension. That extension might allow us to do many other funny things; for example, we could get pressure value from wacom tablets, and so on. Technically, XInput support for XMonad will require FFI bindings to XInput client library (-lXi) and changes in events processing in xmonad core. Maybe, there should be new field in XMonad config, in addition to `keys' and `mouseBindings', to specify XInput events handlers. Currently i'm working on xinput FFI bindings. Questions are: * Could such changes in xmonad core events processing be accepted for xmonad-core? Note that they will introduce new system library dependency (-lXi in addition to existing -lX11). * What features of XInput might be useful for XMonad? For example, I don't know what to do with pressure value in window manager, but maybe someone knows? Any other thoughts are welcome too. With best regards, Ilya Portnov.

On Fri, Aug 31, 2012 at 12:19 PM, Ilya Portnov
Questions are: * Could such changes in xmonad core events processing be accepted for xmonad-core? Note that they will introduce new system library dependency (-lXi in addition to existing -lX11).
I'm wondering how much could be done with an extension, and some evil in the handleEventHook that acts like a filter. (Modifier, the base type of the modifier mask for both keys and mouse buttons, is a CUInt; we would have to be careful of bits taken by Xkb to represent level shifts.) * What features of XInput might be useful for XMonad? For example, I don't
know what to do with pressure value in window manager, but maybe someone knows?
I think that would have to be handled separately; there is no sane way to integrate ranges, such as you would need for pressure sensitivity, into the existing mouse event definition. On the other hand, it'd not be enormously difficult to add a pressureBinding mechanism via the handleEventHook... except for the remaining issue. Which is that all of this is done via X11 events, and there is no extension mechanism in Graphics.X11.Extras.Event to deal with even the core events it decided to ignore, much less extension events. (Other aspects of extensions can be handled by hooks; for example, configuring and enabling XInput events can be done from the startup hook.) The X11 bindings really need a significant overhaul; I have a growing list of braindamage that needs to be fixed (unfortunately it's on the machine I had to put into storage again a couple months ago and not expected to usefully come back out for another month or so...). -- brandon s allbery allbery.b@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms

31.08.2012 22:48, Brandon Allbery wrote:
On Fri, Aug 31, 2012 at 12:19 PM, Ilya Portnov
wrote: Questions are: * Could such changes in xmonad core events processing be accepted for xmonad-core? Note that they will introduce new system library dependency (-lXi in addition to existing -lX11).
I'm wondering how much could be done with an extension, and some evil in the handleEventHook that acts like a filter. (Modifier, the base type of the modifier mask for both keys and mouse buttons, is a CUInt; we would have to be careful of bits taken by Xkb to represent level shifts.)
One problem in handling XInput events using handleEventHook is... that's simply impossible with current Graphics.X11.Xlib.Extras.Event datatype definition. That type does not include even XGenericEventCookie variant. So, XInput events are not supported by X11 package at all (no data types, no XInput structures parsing, no FFI bindings...). It's technically possible to patch X11 package to add all needed XInput bindings into it; one point will be introducing new system library dependency for X11 package. Maybe, the best way is to add only data type declarations into Graphics.X11.Xlib.Extras (XGenericEvent variant of Event type and a bunch of data types for specific XInput events). All other (FFI bindings, structures parsing) will go to separate package. What's current state of X11 package? If anyone of it's developers are here: any thoughts on above? Another problem is XInput-specific. Once you call XISelectEvents (which is analogous to standard X11 XSelectInput call), X server will not send `normal' X11 event messages (XKeyEvent, XButtonEvent) for keyboard/mouse, only XInput-specific events (XGenericCookieEvent) are sent for keyboard/mouse. So, if we want to support old configs, we need to change xmonad main event processing loop to filter XInput mouse/keyboard events and pass them to user-specified handlers (`keys' and `mouseBindings' config fields). Otherwise, users will need to process all mouse/keyboard events in handleEventHook. With best regards, Ilya Portnov.

On Fri, Aug 31, 2012 at 2:32 PM, Ilya Portnov
One problem in handling XInput events using handleEventHook is... that's simply impossible with current Graphics.X11.Xlib.Extras.Event datatype definition. That type does not include even XGenericEventCookie variant. So, XInput events are not supported by X11 package at all (no data types, no XInput structures parsing, no FFI bindings...).
...as I noted at the end of my message. My proposed solution is more a way to make the raw event available so an extension library can be used to add events without future changes to the X11 binding. Another problem is XInput-specific. Once you call XISelectEvents (which is
analogous to standard X11 XSelectInput call), X server will not send `normal' X11 event messages (XKeyEvent, XButtonEvent) for keyboard/mouse, only XInput-specific events (XGenericCookieEvent) are sent for keyboard/mouse. So, if we want to support old configs, we need to change xmonad main
This was what I meant by filtering; we'd be essentially replacing the original event with a modified one that the core does recognize. Unfortunately it has just occurred to me we can't do this as it's currently defined... bleh. We need to give more thought to core extensibility. -- brandon s allbery allbery.b@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms

Quoting Ilya Portnov
What's current state of X11 package? If anyone of it's developers are here: any thoughts on above?
The previous maintainer disappeared. Just to enable progress, I stuck the code up on github, and once in a while I check if somebody has submitted any patches and apply them, then make a release if necessary. I am currently not actively writing code for the X11 bindings. I'm happy applying any patches that extend the X11 bindings' usefulness without changing (system) dependencies. Unless somebody else objects (xmonad may be the only actual user of the X11 library =), I think even adding system dependencies isn't that big of a deal. ~d
participants (3)
-
Brandon Allbery
-
Ilya Portnov
-
wagnerdm@seas.upenn.edu