diff options
author | jao <jao@gnu.org> | 2015-03-20 02:27:57 +0100 |
---|---|---|
committer | jao <jao@gnu.org> | 2015-03-20 02:27:57 +0100 |
commit | 90e6cd0407313858daef2eb6ecfd5cd04a2a72a8 (patch) | |
tree | 120b7fd7985217231615ce02a9f9391bc2d1baf3 | |
parent | bb406692011a78cb15414ec58e21487e927a597a (diff) | |
download | xmobar-90e6cd0407313858daef2eb6ecfd5cd04a2a72a8.tar.gz xmobar-90e6cd0407313858daef2eb6ecfd5cd04a2a72a8.tar.bz2 |
Fixes for vertical alignment and border drawing
-rw-r--r-- | src/Window.hs | 14 | ||||
-rw-r--r-- | src/XUtil.hsc | 4 | ||||
-rw-r--r-- | src/Xmobar.hs | 7 |
3 files changed, 13 insertions, 12 deletions
diff --git a/src/Window.hs b/src/Window.hs index 95ad3a3..ffb3e45 100644 --- a/src/Window.hs +++ b/src/Window.hs @@ -1,7 +1,7 @@ ----------------------------------------------------------------------------- -- | -- Module : Window --- Copyright : (c) 2011-14 Jose A. Ortega Ruiz +-- Copyright : (c) 2011-15 Jose A. Ortega Ruiz -- : (c) 2012 Jochen Keil -- License : BSD-style (see LICENSE) -- @@ -171,15 +171,18 @@ drawBorder b lw d p gc c wi ht = case b of TopB -> drawBorder (TopBM 0) lw d p gc c wi ht BottomB -> drawBorder (BottomBM 0) lw d p gc c wi ht FullB -> drawBorder (FullBM 0) lw d p gc c wi ht - TopBM m -> sf >> sla >> drawLine d p gc 0 (fi m + boff) (fi wi) (fi m + boff) + TopBM m -> sf >> sla >> + drawLine d p gc 0 (fi m + boff) (fi wi) (fi m + boff) BottomBM m -> let rw = fi ht - fi m + boff in sf >> sla >> drawLine d p gc 0 rw (fi wi) rw - FullBM m -> let pad = 2 * fi m + 2 * fi boff'; mp = fi m + fi boff' in - sf >> sla >> drawRectangle d p gc mp mp (wi - pad) (ht - pad) + FullBM m -> let mp = fi m + pad = 2 * fi mp + fi lw + in sf >> sla >> + drawRectangle d p gc mp mp (wi - pad + 1) (ht - pad) where sf = setForeground d gc c sla = setLineAttributes d gc (fi lw) lineSolid capNotLast joinMiter boff = borderOffset b lw - boff' = calcBorderOffset lw :: Int +-- boff' = calcBorderOffset lw :: Int hideWindow :: Display -> Window -> IO () hideWindow d w = do @@ -209,4 +212,3 @@ borderOffset b lw = calcBorderOffset :: (Integral a) => Int -> a calcBorderOffset = ceiling . (/2) . toDouble where toDouble = fi :: (Integral a) => a -> Double - diff --git a/src/XUtil.hsc b/src/XUtil.hsc index 5d177c5..914ebdd 100644 --- a/src/XUtil.hsc +++ b/src/XUtil.hsc @@ -184,8 +184,8 @@ printString dpy drw fs@(Xft fonts) _ fc bc x y s al = do when (al == 255) $ do (a,d) <- textExtents fs s gi <- xftTxtExtents' dpy fonts s - drawXftRect draw bc' x (y - a + 1) (xglyphinfo_xOff gi) (a + d) - drawXftString' draw fc' fonts (toInteger x) (toInteger y) s + drawXftRect draw bc' x (y - a) (xglyphinfo_xOff gi) (a + d + 1) + drawXftString' draw fc' fonts (toInteger x) (toInteger (y - 1)) s #endif diff --git a/src/Xmobar.hs b/src/Xmobar.hs index 12dc1de..680dd89 100644 --- a/src/Xmobar.hs +++ b/src/Xmobar.hs @@ -306,7 +306,7 @@ drawInWin wr@(Rectangle _ _ wid ht) ~[left,center,right] = do printStrings p gc fs 1 L =<< strLn left printStrings p gc fs 1 R =<< strLn right printStrings p gc fs 1 C =<< strLn center - -- draw 1 pixel border if requested + -- draw border if requested io $ drawBorder (border c) (borderWidth c) d p gc bdcolor wid ht -- copy the pixmap with the new string to the window io $ copyArea d p w gc 0 0 wid ht 0 0 @@ -322,9 +322,8 @@ verticalOffset ht (Text t) fontst conf | textOffset conf > -1 = return $ fi (textOffset conf) | otherwise = do (as,ds) <- io $ textExtents fontst t - let bwidth = borderOffset (border conf) (borderWidth conf) - verticalMargin = fi ht - fi (as + ds) - 2 * fi (abs bwidth) - return $ fi ht - fi ds - (verticalMargin `div` 2) + bwidth - 1 + let margin = (fi ht - fi (as + ds)) `div` 2 + return $ fi ht - margin - fi ds - 1 verticalOffset ht (Icon _) _ conf | iconOffset conf > -1 = return $ fi (iconOffset conf) | otherwise = return $ fi (ht `div` 2) - 1 |