diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-09-11 04:05:32 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-09-11 04:05:32 +0200 |
commit | b2d0396faf5a2ae3cb5e6a6a7ef52d94a524783f (patch) | |
tree | 20fd4705fdf004085cb443229776c6ffc4befb9b | |
parent | 44e16cb55e3564ac40b6d8ce107680bdf0dc29bc (diff) | |
download | metatile-b2d0396faf5a2ae3cb5e6a6a7ef52d94a524783f.tar metatile-b2d0396faf5a2ae3cb5e6a6a7ef52d94a524783f.zip |
Handle windows correctly on startup
-rw-r--r-- | XMonad/Main.hsc | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/XMonad/Main.hsc b/XMonad/Main.hsc index 4c00b20..03195ae 100644 --- a/XMonad/Main.hsc +++ b/XMonad/Main.hsc @@ -148,7 +148,7 @@ xmonad initxmc = do windows . const . foldr W.delete winset $ W.allWindows winset \\ ws -- manage the as-yet-unmanaged windows - mapM_ manage (ws \\ W.allWindows winset) + mapM_ (\w -> reparent w >> manage w) (ws \\ W.allWindows winset) userCode $ startupHook initxmc @@ -212,11 +212,13 @@ handle (DestroyWindowEvent {ev_window = w}) = do -- We track expected unmap events in waitingUnmap. We ignore this event unless -- it is synthetic or we are not expecting an unmap notification from a window. -handle (UnmapEvent {ev_window = w, ev_send_event = synthetic}) = whenX (isClient w) $ do - e <- getsWindowState wsWaitingUnmap w - if (synthetic || e == 0) - then unmanage w >> hideParent w - else modifyWindowState (\ws -> ws { wsWaitingUnmap = (wsWaitingUnmap ws) - 1 }) w +handle UnmapEvent {ev_window = w, ev_send_event = synthetic, ev_event = we} = whenX (isClient w) $ do + rootw <- asks theRoot + when (we /= rootw) $ do + e <- getsWindowState wsWaitingUnmap w + if (synthetic || e == 0) + then unmanage w >> hideParent w + else modifyWindowState (\ws -> ws { wsWaitingUnmap = (wsWaitingUnmap ws) - 1 }) w -- set keyboard mapping handle e@(MappingNotifyEvent {}) = do @@ -311,33 +313,33 @@ handle e = broadcastMessage e -- trace (eventName e) -- ignoring reparent :: Window -> X () reparent w = withDisplay $ \dpy -> do - rootw <- asks theRoot - p <- asks normalBorder - noFrame <- getsWindowState ((==none) . wsFrame) w - when noFrame $ do - trace $ "reparent: " ++ show w - frame <- io $ allocaSetWindowAttributes $ \swa -> do - set_background_pixel swa p - set_border_pixel swa p - set_override_redirect swa True - createWindow dpy rootw (-1) (-1) 1 1 0 copyFromParent inputOutput (Visual nullPtr) (cWBackPixel.|.cWBorderPixel.|.cWOverrideRedirect) swa - io $ do - mapWindow dpy frame - reparentWindow dpy w frame 0 0 - modifyWindowState (\ws -> ws { wsFrame = frame }) w + rootw <- asks theRoot + p <- asks normalBorder + noFrame <- getsWindowState ((==none) . wsFrame) w + when noFrame $ do + trace $ "reparent: " ++ show w + frame <- io $ allocaSetWindowAttributes $ \swa -> do + set_background_pixel swa p + set_border_pixel swa p + set_override_redirect swa True + createWindow dpy rootw (-1) (-1) 1 1 0 copyFromParent inputOutput (Visual nullPtr) (cWBackPixel.|.cWBorderPixel.|.cWOverrideRedirect) swa + io $ do + unmapWindow dpy w + reparentWindow dpy w frame 0 0 + modifyWindowState (\ws -> ws { wsFrame = frame }) w hideParent :: Window -> X () hideParent w = withDisplay $ \dpy -> do - frame <- getsWindowState wsFrame w - when (frame /= none) $ io $ unmapWindow dpy frame + frame <- getsWindowState wsFrame w + when (frame /= none) $ io $ unmapWindow dpy frame unparent :: Window -> X () unparent w = withDisplay $ \dpy -> do - trace $ "unparent: " ++ show w - frame <- getsWindowState wsFrame w - when (frame /= none) $ do - io $ destroyWindow dpy frame - modifyWindowState (\ws -> ws { wsFrame = none }) w + frame <- getsWindowState wsFrame w + when (frame /= none) $ do + trace $ "unparent: " ++ show w + io $ destroyWindow dpy frame + modifyWindowState (\ws -> ws { wsFrame = none }) w -- --------------------------------------------------------------------- -- IO stuff. Doesn't require any X state |