aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNils Anders Danielsson <nils.anders.danielsson@gmail.com>2008-02-10 23:26:00 +0100
committerNils Anders Danielsson <nils.anders.danielsson@gmail.com>2008-02-10 23:26:00 +0100
commitd3c9eab6f617f04a5f7d57cdbb829791e72c9e4c (patch)
tree49110865c4eb50348b93e981dba15b1f7dd22b77
parentfaf96f11dedc734824056a2afa12d02c3a286cfe (diff)
downloadXMonadContrib-d3c9eab6f617f04a5f7d57cdbb829791e72c9e4c.tar.gz
XMonadContrib-d3c9eab6f617f04a5f7d57cdbb829791e72c9e4c.tar.xz
XMonadContrib-d3c9eab6f617f04a5f7d57cdbb829791e72c9e4c.zip
Fixed off-by-one error which broke strut handling for some panels.
darcs-hash:20080210222600-9990f-30f64da2f26b6673e57eb981fc4acfcbcb414744.gz
-rw-r--r--XMonad/Hooks/ManageDocks.hs23
1 files changed, 19 insertions, 4 deletions
diff --git a/XMonad/Hooks/ManageDocks.hs b/XMonad/Hooks/ManageDocks.hs
index 4a32620..b8c4a11 100644
--- a/XMonad/Hooks/ManageDocks.hs
+++ b/XMonad/Hooks/ManageDocks.hs
@@ -116,10 +116,19 @@ fi :: (Integral a, Num b) => a -> b
fi = fromIntegral
r2c :: Rectangle -> RectC
-r2c (Rectangle x y w h) = (fi x, fi y, fi x + fi w, fi y + fi h)
+r2c (Rectangle x y w h) = (fi x, fi y, fi x + fi w - 1, fi y + fi h - 1)
c2r :: RectC -> Rectangle
-c2r (x1, y1, x2, y2) = Rectangle (fi x1) (fi y1) (fi $ x2 - x1) (fi $ y2 - y1)
+c2r (x1, y1, x2, y2) = Rectangle (fi x1) (fi y1) (fi $ x2 - x1 + 1) (fi $ y2 - y1 + 1)
+
+-- TODO: Add these QuickCheck properties to the test suite, along with
+-- suitable Arbitrary instances.
+
+-- prop_r2c_c2r :: RectC -> Bool
+-- prop_r2c_c2r r = r2c (c2r r) == r
+
+-- prop_c2r_r2c :: Rectangle -> Bool
+-- prop_c2r_r2c r = c2r (r2c r) == r
-- | Adjust layout automagically.
avoidStruts :: LayoutClass l a => l a -> ModifiedLayout AvoidStruts l a
@@ -141,8 +150,13 @@ instance LayoutModifier AvoidStruts a where
data Side = L | R | T | B
+-- | (Side, height\/width, initial pixel, final pixel).
+
type Strut = (Side, CLong, CLong, CLong)
+-- | (Initial x pixel, initial y pixel,
+-- final x pixel, final y pixel).
+
type RectC = (CLong, CLong, CLong, CLong)
reduce :: RectC -> Strut -> RectC -> RectC
@@ -155,5 +169,6 @@ reduce (sx0, sy0, sx1, sy1) (s, n, l, h) (x0, y0, x1, y1) = case s of
where
mx a b = max a (b + n)
mn a b = min a (b - n)
- inRange (a, b) c = c > a && c < b
- p (a, b) = inRange (a, b) l || inRange (a, b) h || inRange (a, b) l || inRange (l, h) b
+ inRange (a, b) c = c >= a && c <= b
+ -- Does the strut range overlap (a, b)?
+ p (a, b) = inRange (a, b) l || inRange (a, b) h || inRange (l, h) a