summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2013-11-25 00:57:04 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2013-11-25 00:57:04 +0100
commit5bbb923bf9e166640ac2c131f21d18623c28ffc9 (patch)
treea93295ba35985cc5e723f3ccff1e4c6cb500523b /src
parent21782da09df74bb96128636c10f55bff135d66af (diff)
parentad44f794b2f36e5776026cb1a6f497e22ead15b2 (diff)
downloadxmobar-5bbb923bf9e166640ac2c131f21d18623c28ffc9.tar.gz
xmobar-5bbb923bf9e166640ac2c131f21d18623c28ffc9.tar.bz2
Merge dmalikov's feature/set-position
Diffstat (limited to 'src')
-rw-r--r--src/Window.hs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/Window.hs b/src/Window.hs
index 89a4ca9..3fdb923 100644
--- a/src/Window.hs
+++ b/src/Window.hs
@@ -22,7 +22,9 @@ import Graphics.X11.Xlib.Extras
import Graphics.X11.Xinerama
import Foreign.C.Types (CLong)
-import Data.Maybe(fromMaybe)
+import Data.Function (on)
+import Data.List (maximumBy)
+import Data.Maybe (fromMaybe)
import System.Posix.Process (getProcessID)
import Config
@@ -72,8 +74,8 @@ setPosition p rs ht =
OnScreen _ p'' -> setPosition p'' [scr] ht
where
(scr@(Rectangle rx ry rw rh), p') =
- case p of OnScreen i x -> (fromMaybe (head rs) $ safeIndex i rs, x)
- _ -> (head rs, p)
+ case p of OnScreen i x -> (fromMaybe (broadest rs) $ safeIndex i rs, x)
+ _ -> (broadest rs, p)
ny = ry + fi (rh - ht)
center i = rx + fi (div (remwid i) 2)
right i = rx + fi (remwid i)
@@ -87,6 +89,7 @@ setPosition p rs ht =
mh h' = max (fi h') h
ny' h' = ry + fi (rh - mh h')
safeIndex i = lookup i . zip [0..]
+ broadest = maximumBy (compare `on` rect_width)
setProperties :: Config -> Display -> Window -> IO ()
setProperties c d w = do