summaryrefslogtreecommitdiffhomepage
path: root/src/XUtil.hsc
diff options
context:
space:
mode:
authorAlexander Polakov <plhk@sdf.org>2013-02-02 04:59:36 +0400
committerAlexander Polakov <plhk@sdf.org>2013-02-03 15:41:09 +0400
commit7160bbed9870247268469330c18a5e7708eb12a3 (patch)
treee29110929981f40c825ee09f2786897b1d2d9670 /src/XUtil.hsc
parent5c6cb344e0221b20b38ce1decf03029e9051417b (diff)
downloadxmobar-7160bbed9870247268469330c18a5e7708eb12a3.tar.gz
xmobar-7160bbed9870247268469330c18a5e7708eb12a3.tar.bz2
Implement icon caching
Diffstat (limited to 'src/XUtil.hsc')
-rw-r--r--src/XUtil.hsc21
1 files changed, 5 insertions, 16 deletions
diff --git a/src/XUtil.hsc b/src/XUtil.hsc
index 3c9f799..720e895 100644
--- a/src/XUtil.hsc
+++ b/src/XUtil.hsc
@@ -17,6 +17,8 @@ module XUtil
, initFont
, initCoreFont
, initUtf8Font
+ , loadBitmap
+ , drawBitmap
, textExtents
, textWidth
, printString
@@ -73,11 +75,6 @@ hGetLineSafe = UTF8.hGetLine
hGetLineSafe = hGetLine
#endif
-data Bitmap = Bitmap { width :: Dimension
- , height :: Dimension
- , pixmap :: Pixmap
- }
-
-- Hide the Core Font/Xft switching here
data XFont = Core FontStruct
| Utf8 FontSet
@@ -181,30 +178,22 @@ drawBitmap d p _ gc fc bc x y i = do
io $ copyPlane d (pixmap i) p gc 0 0 (width i) (height i) x (y - (fi $ height i)) 1
printString :: Display -> Drawable -> XFont -> GC -> String -> String
- -> Position -> Position -> Widget -> IO ()
-printString d p fs gc fc bc x y w = do
- case w of
- (Text s) -> printString' d p fs gc fc bc x y s
- (Icon i) -> do bitmap <- loadBitmap d p i
- forM_ bitmap $ drawBitmap d p fs gc fc bc x y
-
-printString' :: Display -> Drawable -> XFont -> GC -> String -> String
-> Position -> Position -> String -> IO ()
-printString' d p (Core fs) gc fc bc x y s = do
+printString d p (Core fs) gc fc bc x y s = do
setFont d gc $ fontFromFontStruct fs
withColors d [fc, bc] $ \[fc', bc'] -> do
setForeground d gc fc'
setBackground d gc bc'
drawImageString d p gc x y s
-printString' d p (Utf8 fs) gc fc bc x y s =
+printString d p (Utf8 fs) gc fc bc x y s =
withColors d [fc, bc] $ \[fc', bc'] -> do
setForeground d gc fc'
setBackground d gc bc'
io $ wcDrawImageString d p fs gc x y s
#ifdef XFT
-printString' dpy drw fs@(Xft font) _ fc bc x y s = do
+printString dpy drw fs@(Xft font) _ fc bc x y s = do
(a,d) <- textExtents fs s
gi <- xftTxtExtents dpy font s
withDrawingColors dpy drw fc bc $ \draw -> \fc' -> \bc' ->