summaryrefslogtreecommitdiffstats
path: root/Operations.hs
diff options
context:
space:
mode:
authorSpencer Janssen <sjanssen@cse.unl.edu>2007-10-19 08:39:22 +0200
committerSpencer Janssen <sjanssen@cse.unl.edu>2007-10-19 08:39:22 +0200
commitf143d190af2fab30a3b13be0be323dc9b30695f0 (patch)
treef6ac603e635191f84555811b317bb4938f3cf885 /Operations.hs
parentdbca5b4413936ecfbd7bd15890fdc7e808a15642 (diff)
downloadmetatile-f143d190af2fab30a3b13be0be323dc9b30695f0.tar
metatile-f143d190af2fab30a3b13be0be323dc9b30695f0.zip
Ignore borders in the stored RationalRects of floating windows.
Also, add 'floatWindow' which computes the actual Rectangle for that window, including border. darcs-hash:20071019063922-a5988-dfb16a34165c4582adb8744fade852e6eb6cb9b5
Diffstat (limited to 'Operations.hs')
-rw-r--r--Operations.hs26
1 files changed, 18 insertions, 8 deletions
diff --git a/Operations.hs b/Operations.hs
index 6081775..213d34a 100644
--- a/Operations.hs
+++ b/Operations.hs
@@ -141,7 +141,7 @@ windows f = do
tiled = (W.stack . W.workspace . W.current $ this)
>>= W.filter (`M.notMember` W.floating ws)
>>= W.filter (`notElem` vis)
- (SD (Rectangle sx sy sw sh)
+ (SD sr@(Rectangle sx sy sw sh)
(gt,gb,gl,gr)) = W.screenDetail w
viewrect = Rectangle (sx + fromIntegral gl) (sy + fromIntegral gt)
(sw - fromIntegral (gl + gr)) (sh - fromIntegral (gt + gb))
@@ -156,11 +156,7 @@ windows f = do
-- now the floating windows:
-- move/resize the floating windows, if there are any
- forM_ flt $ \fw -> whenJust (M.lookup fw (W.floating ws)) $
- \(W.RationalRect rx ry rw rh) -> do
- tileWindow fw $ Rectangle
- (sx + floor (toRational sw*rx)) (sy + floor (toRational sh*ry))
- (floor (toRational sw*rw)) (floor (toRational sh*rh))
+ forM_ flt $ \fw -> whenJust (M.lookup fw (W.floating ws)) $ floatWindow sr fw
let vs = flt ++ map fst rs
io $ restackWindows d vs
@@ -246,6 +242,20 @@ tileWindow w r = withDisplay $ \d -> do
(least $ rect_width r) (least $ rect_height r)
reveal w
+-- | tileWindow. Moves and resizes w such that it fits inside the given
+-- RationalRect with respect to the reference Rectangle
+floatWindow :: Rectangle -> Window -> W.RationalRect -> X ()
+floatWindow (Rectangle sx sy sw sh) w (W.RationalRect rx ry rw rh) = do
+ d <- asks display
+ bw <- fmap wa_border_width $ io (getWindowAttributes d w)
+ -- Position and Dimension are incompatible types, so we must fromIntegral
+ -- twice
+ let bwp = fromIntegral bw :: Position
+ bwd = fromIntegral bw :: Dimension
+ tileWindow w $ Rectangle
+ (sx + floor (toRational sw*rx) - bwp) (sy + floor (toRational sh*ry) - bwp)
+ (floor (toRational sw*rw) + 2*bwd) (floor (toRational sh*rh) + 2*bwd)
+
-- ---------------------------------------------------------------------
-- | rescreen. The screen configuration may have changed (due to
@@ -548,8 +558,8 @@ floatLocation w = withDisplay $ \d -> do
bw = fi . wa_border_width $ wa
rr = W.RationalRect ((fi (wa_x wa) - fi (rect_x sr)) % fi (rect_width sr))
((fi (wa_y wa) - fi (rect_y sr)) % fi (rect_height sr))
- (fi (wa_width wa + bw*2) % fi (rect_width sr))
- (fi (wa_height wa + bw*2) % fi (rect_height sr))
+ (fi (wa_width wa - bw*2) % fi (rect_width sr))
+ (fi (wa_height wa - bw*2) % fi (rect_height sr))
return (W.screen $ sc, rr)
where fi x = fromIntegral x