summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSpencer Janssen <sjanssen@cse.unl.edu>2008-08-06 22:50:29 +0200
committerSpencer Janssen <sjanssen@cse.unl.edu>2008-08-06 22:50:29 +0200
commit9816ff2e0dbb51dded121fb69768555d65f0421c (patch)
tree4f0f9100f3cb869b8cf230100c690440def2fc3c
parent25886ea48e9083240ce09f42755f6ef11455e51f (diff)
downloadxmobar-9816ff2e0dbb51dded121fb69768555d65f0421c.tar.gz
xmobar-9816ff2e0dbb51dded121fb69768555d65f0421c.tar.bz2
Add Support for positioning on certain screens
darcs-hash:20080806205029-a5988-84ceb56437a40b7213082922f55339e31059597a.gz
-rw-r--r--Config.hs3
-rw-r--r--Xmobar.hs14
2 files changed, 12 insertions, 5 deletions
diff --git a/Config.hs b/Config.hs
index 1f4cab1..764b85c 100644
--- a/Config.hs
+++ b/Config.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE CPP #-}
+
-----------------------------------------------------------------------------
-- |
-- Module : Xmobar.Config
@@ -54,6 +56,7 @@ data XPosition = Top
| Bottom
| BottomW Align Int
| Static {xpos, ypos, width, height :: Int}
+ | OnScreen Int XPosition
deriving ( Read, Eq )
data Align = L | R | C deriving ( Read, Eq )
diff --git a/Xmobar.hs b/Xmobar.hs
index fdc2446..5abdf86 100644
--- a/Xmobar.hs
+++ b/Xmobar.hs
@@ -128,20 +128,20 @@ startCommand (com,s,ss)
createWin :: Display -> XFont -> Config -> IO (Rectangle,Window)
createWin d fs c = do
let dflt = defaultScreen d
- sr:_ <- getScreenInfo d
+ srs <- getScreenInfo d
rootw <- rootWindow d dflt
(as,ds) <- textExtents fs "0"
let ht = as + ds + 4
- (r,o) = setPosition (position c) sr (fi ht)
+ (r,o) = setPosition (position c) srs (fi ht)
win <- newWindow d (defaultScreenOfDisplay d) rootw r o
selectInput d win (exposureMask .|. structureNotifyMask)
setProperties r c d win
mapWindow d win
return (r,win)
-setPosition :: XPosition -> Rectangle -> Dimension -> (Rectangle,Bool)
-setPosition p (Rectangle rx ry rw rh) ht =
- case p of
+setPosition :: XPosition -> [Rectangle] -> Dimension -> (Rectangle,Bool)
+setPosition p rs ht =
+ case p' of
Top -> (Rectangle rx ry rw h , True)
TopW L i -> (Rectangle rx ry (nw i) h , True)
TopW R i -> (Rectangle (right i) ry (nw i) h , True)
@@ -151,7 +151,11 @@ setPosition p (Rectangle rx ry rw rh) 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"
where
+ (Rectangle rx ry rw rh, p') = case p of
+ OnScreen i x -> (rs !! i, x)
+ _ -> (head rs, p)
ny = ry + fi (rh - ht)
center i = rx + (fi $ div (remwid i) 2)
right i = rx + (fi $ remwid i)