summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAdam Vogt <vogt.adam@gmail.com>2009-04-20 02:57:32 +0200
committerAdam Vogt <vogt.adam@gmail.com>2009-04-20 02:57:32 +0200
commit0713a41374288b3caa464f7e1c5b6244ccf5c16b (patch)
tree7341af835296f63865010fd2863d36f6febc7b80
parent8b42afe1b1aec898e147a9846bedff112dcb181b (diff)
downloadxmobar-0713a41374288b3caa464f7e1c5b6244ccf5c16b.tar.gz
xmobar-0713a41374288b3caa464f7e1c5b6244ccf5c16b.tar.bz2
Accept the outermost OnScreen XPosition
Ignore-this: 9db9f39958618cf4c9ea91330f162aec Takes the outermost directive. This implementation has the potentially desirable side-effect of causing xmobar to run when given OnScreen 1, when there is only 1 screen. darcs-hash:20090420005732-1499c-280e2964039c8d3139d93cd52a0b9ab781b92bae.gz
-rw-r--r--Xmobar.hs11
1 files changed, 7 insertions, 4 deletions
diff --git a/Xmobar.hs b/Xmobar.hs
index d3c252d..2380fd1 100644
--- a/Xmobar.hs
+++ b/Xmobar.hs
@@ -40,6 +40,7 @@ import Control.Concurrent.STM
import Control.Exception hiding (handle)
import Data.Bits
import Data.Char
+import Data.Maybe(fromMaybe)
import Config
@@ -151,11 +152,11 @@ setPosition p rs ht =
BottomW R i -> (Rectangle (right i) ny (nw i) h , True)
BottomW C i -> (Rectangle (center i) ny (nw i) h , True)
Static cx cy cw ch -> (Rectangle (fi cx ) (fi cy) (fi cw) (fi ch), True)
- OnScreen _ _ -> error "Nested OnScreen positions are not allowed"
+ OnScreen _ p'' -> setPosition p'' [scr] ht
where
- (Rectangle rx ry rw rh, p') = case p of
- OnScreen i x -> (rs !! i, x)
- _ -> (head rs, p)
+ (scr@(Rectangle rx ry rw rh), p') =
+ case p of OnScreen i x -> (fromMaybe (head rs) $ safeIndex i rs, x)
+ _ -> (head rs, p)
ny = ry + fi (rh - ht)
center i = rx + (fi $ div (remwid i) 2)
right i = rx + (fi $ remwid i)
@@ -164,6 +165,8 @@ setPosition p rs ht =
nw = fi . pw . fi
h = fi ht
+ safeIndex i = lookup i . zip [0..]
+
setProperties :: Rectangle -> Config -> Display -> Window -> [Rectangle] -> IO ()
setProperties r c d w srs = do
a1 <- internAtom d "_NET_WM_STRUT_PARTIAL" False