From f3b1977043a8736ac856d4477b485ee441a4342f Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 17 Sep 2013 05:32:29 +0200 Subject: Keep track of the current desired frame bounds in the frame state This saved a few round-trips to the X server and is preparation for the window confinement feature. --- MetaTile/Operations.hs | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'MetaTile/Operations.hs') diff --git a/MetaTile/Operations.hs b/MetaTile/Operations.hs index 4edf67b..acd9898 100644 --- a/MetaTile/Operations.hs +++ b/MetaTile/Operations.hs @@ -126,7 +126,7 @@ windows f = do let visible = map fst3 rects - mapM_ (uncurry3 tileWindow) rects + mapM_ (uncurry3 tileWindow') rects whenJust (W.peek ws) $ \w -> setFrameBackground d w fbc @@ -181,11 +181,10 @@ hide w = whenX (getsWindowState wsMapped w) $ withDisplay $ \d -> do modifyWindowState (\ws -> ws { wsMapped = False , wsWaitingUnmap = (wsWaitingUnmap ws) + 1 }) w -configureClientWindow :: Window -> X () -configureClientWindow w = withDisplay $ \d -> do +configure :: Window -> X () +configure w = withDisplay $ \d -> do frame <- getsWindowState wsFrame w - Just bw <- getsFrameState fsBorderWidth frame - (_, x, y, width, height, _, _) <- io $ getGeometry d frame + Just (FrameState { fsBounds = Rectangle x y width height, fsBorderWidth = bw }) <- getFrameState frame let least1 n = max 1 n x' = x + (fi $ bwLeft bw) y' = y + (fi $ bwTop bw) @@ -193,6 +192,8 @@ configureClientWindow w = withDisplay $ \d -> do height' = least1 (height - bwTop bw - bwBottom bw) io $ do moveResizeWindow d w (fi $ bwLeft bw) (fi $ bwTop bw) width' height' + moveResizeWindow d frame x y (least1 width) (least1 height) + -- send absolute ConfigureNotify allocaXEvent $ \event -> do setEventType event configureNotify @@ -209,7 +210,7 @@ reveal w = withDisplay $ \d -> do setWMState w normalState io $ mapWindow d w whenX (isClient w) $ do - configureClientWindow w + configure w getsWindowState wsFrame w >>= io . mapWindow d modifyWindowState (\ws -> ws { wsMapped = True }) w @@ -239,14 +240,11 @@ clearEvents mask = withDisplay $ \d -> io $ do -- | tileWindow. Moves and resizes w such that it fits inside the given -- rectangle, including its border. -tileWindow :: Window -> Rectangle -> BorderWidth -> X () -tileWindow w r bw = withDisplay $ \d -> do - -- give all windows at least 1x1 pixels - let least x | x <= 0 = 1 - | otherwise = x - frame <- getsWindowState wsFrame w - modifyFrameState (\fs -> fs {fsBorderWidth = bw}) frame - io $ moveResizeWindow d frame (rect_x r) (rect_y r) (least $ rect_width r) (least $ rect_height r) +tileWindow :: Window -> Rectangle -> X () +tileWindow w r = getsWindowState wsFrame w >>= modifyFrameState (\fs -> fs {fsBounds = r}) + +tileWindow' :: Window -> Rectangle -> BorderWidth -> X () +tileWindow' w r bw = getsWindowState wsFrame w >>= modifyFrameState (\fs -> fs {fsBounds = r, fsBorderWidth = bw}) -- --------------------------------------------------------------------- -- cgit v1.2.3