summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDmitry Malikov <malikov.d.y@gmail.com>2013-11-23 23:42:13 +0400
committerDmitry Malikov <malikov.d.y@gmail.com>2013-11-24 14:47:49 +0400
commitad44f794b2f36e5776026cb1a6f497e22ead15b2 (patch)
tree07c8c175b444aee094ac06314182cf739c7eb0e3
parent1563fa8473d728486b7c86a1a4f818466ab64413 (diff)
downloadxmobar-ad44f794b2f36e5776026cb1a6f497e22ead15b2.tar.gz
xmobar-ad44f794b2f36e5776026cb1a6f497e22ead15b2.tar.bz2
Get widest Rectangle instead of first one in setPosition
-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