blob: cdc2f9598fe6f219e46f7548ac51e97af9072fa4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
module Internal.Submap (mapNextString, module X) where
import XMonad hiding (keys)
import Control.Monad.Fix (fix)
import XMonad.Actions.Submap as X
{- Like submap fram XMonad.Actions.Submap, but sends the string from
- XLookupString to the function rather than the KeySym.
-}
mapNextString :: (KeyMask -> String -> X a) -> X a
mapNextString fn = do
XConf { theRoot = root, display = d } <- ask
io $ grabKeyboard d root False grabModeAsync grabModeAsync currentTime
(m, str) <- io $ allocaXEvent $ \p -> fix $ \nextkey -> do
maskEvent d keyPressMask p
KeyEvent { ev_keycode = code, ev_state = m } <- getEvent p
keysym <- keycodeToKeysym d code 0
(_, str) <- lookupString (asKeyEvent p)
if isModifierKey keysym
then nextkey
else return $ (m, str)
io $ ungrabKeyboard d currentTime
fn m str
|