diff options
author | Spencer Janssen <sjanssen@cse.unl.edu> | 2007-10-05 05:41:02 +0200 |
---|---|---|
committer | Spencer Janssen <sjanssen@cse.unl.edu> | 2007-10-05 05:41:02 +0200 |
commit | b09d25945938bca44061f572669772190bd125d1 (patch) | |
tree | bff32a0badad0962d7cb3956d9e7c83243070681 | |
parent | d26efdf84f8cc97f1e749463234e0b6b23577ed4 (diff) | |
download | xmonad-b09d25945938bca44061f572669772190bd125d1.tar.gz xmonad-b09d25945938bca44061f572669772190bd125d1.tar.xz xmonad-b09d25945938bca44061f572669772190bd125d1.zip |
Move grabButtons/Keys into X
darcs-hash:20071005034102-a5988-fb2b9080382d62b3486ba53d019b5baf7e7f4b01.gz
-rw-r--r-- | Main.hs | 35 |
1 files changed, 18 insertions, 17 deletions
@@ -81,14 +81,15 @@ main = do sync dpy False selectInput dpy rootw $ substructureRedirectMask .|. substructureNotifyMask .|. enterWindowMask .|. leaveWindowMask .|. structureNotifyMask - grabKeys dpy rootw - grabButtons dpy rootw - - sync dpy False allocaXEvent $ \e -> runX cf st $ do + grabKeys + grabButtons + + io $ sync dpy False + -- bootstrap the windowset, Operations.windows will identify all -- the windows in winset as new and set initial properties for -- those windows @@ -126,23 +127,25 @@ scan dpy rootw = do && (wa_map_state wa == waIsViewable || ic) -- | Grab the keys back -grabKeys :: Display -> Window -> IO () -grabKeys dpy rootw = do - ungrabKey dpy anyKey anyModifier rootw +grabKeys :: X () +grabKeys = do + XConf { display = dpy, theRoot = rootw } <- ask + let grab kc m = io $ grabKey dpy kc m rootw True grabModeAsync grabModeAsync + io $ ungrabKey dpy anyKey anyModifier rootw forM_ (M.keys keys) $ \(mask,sym) -> do - kc <- keysymToKeycode dpy sym + kc <- io $ keysymToKeycode dpy sym -- "If the specified KeySym is not defined for any KeyCode, -- XKeysymToKeycode() returns zero." when (kc /= '\0') $ mapM_ (grab kc . (mask .|.)) extraModifiers - where grab kc m = grabKey dpy kc m rootw True grabModeAsync grabModeAsync -grabButtons :: Display -> Window -> IO () -grabButtons dpy rootw = do - ungrabButton dpy anyButton anyModifier rootw +grabButtons :: X () +grabButtons = do + XConf { display = dpy, theRoot = rootw } <- ask + let grab button mask = io $ grabButton dpy button mask rootw False buttonPressMask + grabModeAsync grabModeSync none none + io $ ungrabButton dpy anyButton anyModifier rootw mapM_ (\(m,b) -> mapM_ (grab b . (m .|.)) extraModifiers) (M.keys mouseBindings) - where grab button mask = grabButton dpy button mask rootw False buttonPressMask - grabModeAsync grabModeSync none none -- --------------------------------------------------------------------- -- | Event handler. Map X events onto calls into Operations.hs, which @@ -185,9 +188,7 @@ handle (UnmapEvent {ev_window = w, ev_send_event = synthetic}) = whenX (isClient -- set keyboard mapping handle e@(MappingNotifyEvent {}) = do io $ refreshKeyboardMapping e - when (ev_request e == mappingKeyboard) $ withDisplay $ \dpy -> do - rootw <- asks theRoot - io $ grabKeys dpy rootw + when (ev_request e == mappingKeyboard) grabKeys -- handle button release, which may finish dragging. handle e@(ButtonEvent {ev_event_type = t}) |