improve the vertical centring in X.A.GridSelect

This commit is contained in:
Sam Doshi
2017-02-18 13:46:30 +00:00
parent b1dee9b0b4
commit a79a116934
2 changed files with 8 additions and 1 deletions

View File

@@ -10,6 +10,10 @@
### Bug Fixes and Minor Changes
* `XMonad.Actions.GridSelect`
- The vertical centring of text in each cell has been improved.
* `XMonad.Util.WindowProperties`
- Added the ability to test if a window has a tag from

View File

@@ -341,7 +341,10 @@ drawWinBox win font (fg,bg) bc ch cw text x y cp =
(\n -> do size <- liftIO $ textWidthXMF dpy font n
return $ size > (fromInteger (cw-(2*cp))))
text
printStringXMF dpy win font gc bg fg (fromInteger (x+cp)) (fromInteger (y+(div ch 2))) stext
-- calculate the offset to vertically centre the text based on the ascender and descender
(asc,desc) <- liftIO $ textExtentsXMF font stext
let offset = ((ch - fromIntegral (asc + desc)) `div` 2) + fromIntegral asc
printStringXMF dpy win font gc bg fg (fromInteger (x+cp)) (fromInteger (y+offset)) stext
liftIO $ freeGC dpy gc
liftIO $ freeGC dpy bordergc