From 0713a41374288b3caa464f7e1c5b6244ccf5c16b Mon Sep 17 00:00:00 2001 From: Adam Vogt Date: Mon, 20 Apr 2009 02:57:32 +0200 Subject: 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 --- Xmobar.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'Xmobar.hs') 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 -- cgit v1.2.3