From 5bce29df834e19c0512d57b4e236f5b7c4c6ea10 Mon Sep 17 00:00:00 2001 From: Don Stewart Date: Thu, 8 Mar 2007 14:05:17 +0100 Subject: stub for MappingNotifyEvent, based on dwm. But the X11-extras binding for this event needs doing (sjanssen?) darcs-hash:20070308130517-9c5c1-83193a446a74e9a50467a4f52aeb71632e4d8a64.gz --- Main.hs | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) (limited to 'Main.hs') diff --git a/Main.hs b/Main.hs index 176631a..4be96b4 100644 --- a/Main.hs +++ b/Main.hs @@ -72,7 +72,7 @@ main = do r <- io $ rootWindow dpy dflt io $ do selectInput dpy r (substructureRedirectMask .|. substructureNotifyMask) sync dpy False - registerKeys dpy r + grabKeys dpy r (_, _, ws) <- io $ queryTree dpy r forM_ ws $ \w -> do wa <- io $ getWindowAttributes dpy w @@ -86,19 +86,42 @@ main = do e <- io $ allocaXEvent $ \ev -> nextEvent dpy ev >> getEvent ev handle e - -- register keys - registerKeys dpy r = forM_ (M.keys keys) $ \(m,s) -> io $ do - kc <- keysymToKeycode dpy s - grabKey dpy kc m r True grabModeAsync grabModeAsync +-- | Grab the keys back +grabKeys :: Display -> Window -> W () +grabKeys dpy r = forM_ (M.keys keys) $ \(m,s) -> io $ do + kc <- keysymToKeycode dpy s + grabKey dpy kc m r True grabModeAsync grabModeAsync -- -- | handle. Handle X events +-- dwm handles: +-- +-- [ButtonPress] = buttonpress, +-- [ConfigureRequest] = configurerequest, +-- [DestroyNotify] = destroynotify, +-- [EnterNotify] = enternotify, +-- [LeaveNotify] = leavenotify, +-- [Expose] = expose, +-- [KeyPress] = keypress, +-- [MappingNotify] = mappingnotify, +-- [MapRequest] = maprequest, +-- [PropertyNotify] = propertynotify, +-- [UnmapNotify] = unmapnotify -- handle :: Event -> W () handle (MapRequestEvent {window = w}) = manage w handle (DestroyWindowEvent {window = w}) = unmanage w handle (UnmapEvent {window = w}) = unmanage w +handle (MappingNotifyEvent {window = w}) = do + trace $ "Got mapping notify event for window: " ++ show w + +{- +, mapping= m@(r,_,_)}) = do + io $ refreshKeyboardMapping m + when (r == mappingKeyboard) $ withDisplay $ \d -> grabKeys d w +-} + handle (KeyEvent {event_type = t, state = m, keycode = code}) | t == keyPress = withDisplay $ \dpy -> do s <- io $ keycodeToKeysym dpy code 0 @@ -117,7 +140,15 @@ handle e@(ConfigureRequestEvent {}) = do } io $ sync dpy False -handle e = trace (eventName e) -- return () +-- Typical events I see still unhandled: +-- ConfigureNotify +-- MapNotify +-- CreateNotify +-- KeyRelease +-- +-- In particular, ConfigureNotify and MapNotify a lot on firefox +-- +handle e = trace (eventName e) -- --------------------------------------------------------------------- -- Managing windows -- cgit v1.2.3