summaryrefslogtreecommitdiffstats
path: root/MetaTile
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-09-11 20:22:45 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-09-11 20:22:45 +0200
commitf05f53f9057508ff274f5ee51b866e68fb09824a (patch)
tree3e612f42c7e79684660e4846153057bffbd44a92 /MetaTile
parent78b64d1d34f4764fd6ddb9a9d59a25cd72793b94 (diff)
downloadmetatile-f05f53f9057508ff274f5ee51b866e68fb09824a.tar
metatile-f05f53f9057508ff274f5ee51b866e68fb09824a.zip
Set border width after running the layout
Diffstat (limited to 'MetaTile')
-rw-r--r--MetaTile/Core.hs19
-rw-r--r--MetaTile/Operations.hs9
2 files changed, 12 insertions, 16 deletions
diff --git a/MetaTile/Core.hs b/MetaTile/Core.hs
index 14c4211..e116ccf 100644
--- a/MetaTile/Core.hs
+++ b/MetaTile/Core.hs
@@ -75,7 +75,7 @@ data WindowState = WindowState
} deriving Show
instance Eq WindowState where
- (==) = (==) `on` (wsMapped &&& wsWaitingUnmap &&& wsFrame)
+ (==) = (==) `on` (wsMapped &&& wsWaitingUnmap &&& wsFrame)
-- | XState, the (mutable) window manager state.
@@ -233,25 +233,20 @@ isRoot w = (w==) <$> asks theRoot
getAtom :: String -> X Atom
getAtom str = withDisplay $ \dpy -> io $ internAtom dpy str False
-emptyWindowState :: X WindowState
-emptyWindowState = asks (defaultBorderWidth . config) >>= return . WindowState False 0 none
+emptyWindowState :: WindowState
+emptyWindowState = WindowState False 0 none (BorderWidth 0 0 0 0)
getWindowState :: Window -> X WindowState
-getWindowState w = do
- ws <- gets $ (M.lookup w) . windowState
- case ws of
- Just s -> return s
- Nothing -> emptyWindowState
+getWindowState w = gets $ M.findWithDefault emptyWindowState w . windowState
getsWindowState :: (WindowState -> a) -> Window -> X a
getsWindowState f w = f <$> getWindowState w
setWindowState :: Window -> WindowState -> X ()
setWindowState w ws = do
- emptyState <- emptyWindowState
- let f | ws == emptyState = M.delete w
- | otherwise = M.insert w ws
- modify $ \s -> s { windowState = f (windowState s) }
+ let f | ws == emptyWindowState = M.delete w
+ | otherwise = M.insert w ws
+ modify $ \s -> s { windowState = f (windowState s) }
modifyWindowState :: (WindowState -> WindowState) -> Window -> X ()
modifyWindowState f w = getWindowState w >>= return . f >>= setWindowState w
diff --git a/MetaTile/Operations.hs b/MetaTile/Operations.hs
index 1a2fd11..5b3a598 100644
--- a/MetaTile/Operations.hs
+++ b/MetaTile/Operations.hs
@@ -92,7 +92,7 @@ windows f = do
let oldvisible = concatMap (W.integrate' . W.stack . W.screenWorkspace) $ W.screens old
newwindows = W.allWindows ws \\ W.allWindows old
ws = f old
- XConf { display = d , normalBorder = nbc, focusedBorder = fbc } <- ask
+ XConf { display = d , normalBorder = nbc, focusedBorder = fbc, config = XConfig { defaultBorderWidth = bw } } <- ask
mapM_ setInitialProperties newwindows
@@ -127,7 +127,7 @@ windows f = do
let visible = map fst rects
- mapM_ (uncurry tileWindow) rects
+ mapM_ (\(w, r) -> tileWindow w r bw) rects
whenJust (W.peek ws) $ \w -> setFrameBackground d w fbc
@@ -239,12 +239,13 @@ 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 -> X ()
-tileWindow w r = withDisplay $ \d -> do
+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
+ modifyWindowState (\ws -> ws {wsBorderWidth = bw}) w
io $ moveResizeWindow d frame (rect_x r) (rect_y r) (least $ rect_width r) (least $ rect_height r)
-- ---------------------------------------------------------------------