Respecting the Window Manager Input Hint

Hello, I'm developing a scientific instrument which runs Gentoo Linux and uses Haskell for running the measurements. The device also uses XMonad for window management. Because the device has a touchscreen instead of a physical keyboard, I would like to use the the on-screen-keyboard: onboard [1]. The way onboard is supposed to work is that you move the focus to the window that needs input and then click on one of the onboard keys. Onboard will then generate an X11 event that will be send to the window that has focus. For correct operation, it's crucial that onboard does not get focus itself because then the key events will be send to itself! To prevent getting focus, onboard gives a hint to the window manager to not accept focus. $ xprop # (click on the onboard window) ... WM_HINTS(WM_HINTS): Client accepts input or input focus: False ... Unfortunately xmonad does not respect this hint by focusing the onboard window anyway when my pointer enters it. How can I prevent this? Possible solutions: * Use a manage hook that removes onboard from xmonad management so that it won't get focus anymore: className =? "Onboard" --> doIgnore While this solves my problem this has the disadvantage that the onboard window is not managed anymore. * Use XMonad.Layout.BoringWindows and the code in the recent thread on "focus handling". Unfortunately I didn't get this to work. (Maybe I have to put some more time into this) * Patch xmonad to respect the Window Manager Input Hint by not giving focus to windows that don't want't to get focus. How difficult would this be? regards, Bas [1] https://wiki.ubuntu.com/Accessibility/Projects/onBoard

The attached patch does what I want. It only sets the input focus when the window needs it: hunk ./XMonad/Operations.hs 330 -- If we ungrab buttons on the root window, we lose our mouse bindings. whenX (not <$> isRoot w) $ setButtonGrab False w - io $ do setInputFocus dpy w revertToPointerRoot 0 + io $ do needsInput <- liftM wmh_input $ getWMHints dpy w + when needsInput $ setInputFocus dpy w revertToPointerRoot 0 -- raiseWindow dpy w Can anybody review this? Also see: http://tronche.com/gui/x/xlib/ICC/client-to-window-manager/wm-hints.html regards, Bas

Excerpts from Bas van Dijk's message of Wed Feb 03 03:57:31 -0700 2010:
.. <snip>
For correct operation, it's crucial that onboard does not get focus itself because then the key events will be send to itself! To prevent getting focus, onboard gives a hint to the window manager to not accept focus.
$ xprop # (click on the onboard window) ... WM_HINTS(WM_HINTS): Client accepts input or input focus: False ...
Unfortunately xmonad does not respect this hint by focusing the onboard window anyway when my pointer enters it.
How can I prevent this?
Possible solutions:
* Use a manage hook that removes onboard from xmonad management so that it won't get focus anymore: className =? "Onboard" --> doIgnore While this solves my problem this has the disadvantage that the onboard window is not managed anymore.
* Use XMonad.Layout.BoringWindows and the code in the recent thread on "focus handling". Unfortunately I didn't get this to work. (Maybe I have to put some more time into this)
In my experience these are painful if any windows are floating, as it's difficult to track which windows cover which as z-order gets shuffled. (Not familiar with recent thread, though, just "standard" boring BoringWindows.)
* Patch xmonad to respect the Window Manager Input Hint by not giving focus to windows that don't want't to get focus. How difficult would this be?
Warning, these are quick responses, not thought through very deeply; hopfully they are helpful. ;-) Might be worth trying out the patches posted on issue 177 on the tracker [177]; there are ones applicable to recent darcs or to a darcs get of tag 0.9 xmonad core. While issue 177 doesn't mention onboard app specifically, nor the WM_HINTS focus alerting method you describe, those patches enabled proper operation of similar apps, like scim input and Cellwriter input panel. Hopefully they work for you even without modification, but worth a look. For an example of reading state from wm hints in handleEventHook, see fullscreenEventHook in contrib, in darcs version of XMonad.Hooks.EwmhDesktops. This might be helpful coupled with boring approach if you did decide to go that route. [177] http://code.google.com/p/xmonad/issues/detail?id=177 -- wmw

On Wed, Feb 3, 2010 at 6:10 PM, Wirt Wolff
Might be worth trying out the patches posted on issue 177 on the tracker
It was definitely worth trying out the latest patch in issue 177 from vogt.adam because it completely solves my bug! (Note that both vogt's and my patch only call setInputFocus when the input hint is set.) I will add a comment to issue 177 indicating that the latest patch also makes onboard work correctly. Thanks very much, Bas
participants (2)
-
Bas van Dijk
-
Wirt Wolff