aboutsummaryrefslogtreecommitdiffstats
path: root/XUtils.hs
diff options
context:
space:
mode:
authorAndrea Rossato <andrea.rossato@unibz.it>2007-10-02 08:26:40 +0200
committerAndrea Rossato <andrea.rossato@unibz.it>2007-10-02 08:26:40 +0200
commit026a1a36b85fe2e424562f5f32fc00ebc281d856 (patch)
tree556a85bc87088690f3ff03fbaffbdc0b41925de4 /XUtils.hs
parentc09690ba218077b5b2818b447edd7f8577d1d294 (diff)
downloadXMonadContrib-026a1a36b85fe2e424562f5f32fc00ebc281d856.tar.gz
XMonadContrib-026a1a36b85fe2e424562f5f32fc00ebc281d856.tar.xz
XMonadContrib-026a1a36b85fe2e424562f5f32fc00ebc281d856.zip
XUtils: added releaseFont
darcs-hash:20071002062640-32816-570d19b8341745b4376b6287462d5daa0f2f1774.gz
Diffstat (limited to '')
-rw-r--r--XUtils.hs12
1 files changed, 9 insertions, 3 deletions
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))