button - XMonad/Submap: how do I accept both KeyPressEvent (keyboard presses) and ButtonPressEvent (mouse clicks)? -


i wish modify xmonad.actions.submap accepts both keyboard , mouse events (for example, left clicking might set action, or abort submap). figured first step grab , ungrab mouse buttons:

-- | given 'data.map.map' key bindings x () actions, return --   action waits user keypress , executes --   corresponding action, or nothing if key not found in --   map. -- --   executes default action def if key not match of keybindings. submapdefault :: x () -> m.map (keymask, keysym) (x ()) -> x () submapdefault def keys =     xconf { theroot = root, display = d } <- ask      io $ grabkeyboard d root false grabmodeasync grabmodeasync currenttime      -- added: grab mouse buttons     -- make difference whether it's buttonpressmask or buttonreleasemask?     io $ grabbutton dply button1 anymodifier root true buttonpressmask grabmodeasync grabmodeasync none none     io $ grabbutton dply button3 anymodifier root true buttonpressmask grabmodeasync grabmodeasync none none       (m, s) <- io $ allocaxevent $ \p -> fix $ \nextkey ->         maskevent d keypressmask p         keyevent { ev_keycode = code, ev_state = m } <- getevent p         keysym <- keycodetokeysym d code 0         if ismodifierkey keysym             nextkey             else return (m, keysym)     -- remove num lock mask , xkb group state bits     m' <- cleanmask $ m .&. ((1 `shiftl` 12) - 1)       -- added: ungrab mouse buttons     io $ ungrabbutton dply button1 anymodifier root      io $ ungrabbutton dply button3 anymodifier root       io $ ungrabkeyboard d currenttime      maybe def id (m.lookup (m', s) keys) 

however, don't understand how adjust code in middle, accept either keypress or buttonpress events. appreciated.


edit: best of knowledge:

  1. replacing maskevent d keypressmask p maskevent d (keypressmask + buttonpressmask) p might starting point, i'm not sure go there.

  2. i don't understand fix.

original question: it's evident code meant grab second key if first modifier. since fix f yields value x such f x = x, wouldn't fix terminate upon modifier, yielding whatever nextkey @ time? don't how there supposed fixed point non-modifier key; (m, keysym) supposed equal nextkey?

evaluating alternate definition fix' f = f (fix' f), like:

do   maskevent d keypressmask p   keyevent { ev_keycode = code, ev_state = m } <- getevent p   keysym <- keycodetokeysym d code 0   if ismodifierkey keysym       (fix' \nextkey -> ...)       else return (m, keysym)    maskevent d keypressmask p   keyevent { ev_keycode = code, ev_state = m } <- getevent p   keysym <- keycodetokeysym d code 0   if ismodifierkey keysym       (do               maskevent d keypressmask p               keyevent { ev_keycode = code, ev_state = m } <- getevent p               keysym <- keycodetokeysym d code 0               if ismodifierkey keysym                   (fix' \nextkey -> ...)                   else return (m, keysym))       else return (m, keysym) 

so suppose same thing on , on until ismodifierkey keysym false.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -