From 026a1a36b85fe2e424562f5f32fc00ebc281d856 Mon Sep 17 00:00:00 2001 From: Andrea Rossato Date: Tue, 2 Oct 2007 08:26:40 +0200 Subject: XUtils: added releaseFont darcs-hash:20071002062640-32816-570d19b8341745b4376b6287462d5daa0f2f1774.gz --- XUtils.hs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'XUtils.hs') diff --git a/XUtils.hs b/XUtils.hs index 4971462..c06cde4 100644 --- a/XUtils.hs +++ b/XUtils.hs @@ -17,6 +17,7 @@ module XMonadContrib.XUtils ( -- $usage stringToPixel , initFont + , releaseFont , createNewWindow , showWindow , hideWindow @@ -57,6 +58,11 @@ initFont s = do where getIt d = loadQueryFont d s fallBack d = const $ loadQueryFont d "-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*" +releaseFont :: FontStruct -> X () +releaseFont fs = do + d <- asks display + io $ freeFont d fs + -- | Create a simple window given a rectangle. If Nothing is given -- only the exposureMask will be set, otherwise the Just value. -- Use 'showWindow' to map and hideWindow to unmap. @@ -105,11 +111,11 @@ data Align = AlignCenter | AlignRight | AlignLeft -- | Return the string x and y 'Position' in a 'Rectangle', given a -- 'FontStruct' and the 'Align'ment stringPosition :: FontStruct -> Rectangle -> Align -> String -> (Position,Position) -stringPosition fs (Rectangle _ _ w h) al s = (x',y') +stringPosition fs (Rectangle _ _ w h) al s = (x,y) where width = textWidth fs s (_,a,d,_) = textExtents fs s - y' = fi $ ((h - fi (a + d)) `div` 2) + fi a - x' = case al of + y = fi $ ((h - fi (a + d)) `div` 2) + fi a + x = case al of AlignCenter -> fi (w `div` 2) - fi (width `div` 2) AlignLeft -> 1 AlignRight -> fi (w - (fi width + 1)) -- cgit v1.2.3