diff options
-rw-r--r-- | src/Bitmap.hs | 1 | ||||
-rw-r--r-- | src/Parsers.hs | 3 | ||||
-rw-r--r-- | src/XUtil.hsc | 24 | ||||
-rw-r--r-- | src/Xmobar.hs | 16 | ||||
-rw-r--r-- | xmobar.cabal | 2 |
5 files changed, 5 insertions, 41 deletions
diff --git a/src/Bitmap.hs b/src/Bitmap.hs index 8a86f92..6e4eed5 100644 --- a/src/Bitmap.hs +++ b/src/Bitmap.hs @@ -6,7 +6,6 @@ module Bitmap import Control.Monad import Data.Map hiding (foldr, map, filter) import Graphics.X11.Xlib -import Graphics.X11.Xlib.Extras import System.Directory (doesFileExist) import System.Mem.Weak ( addFinalizer ) import XGraphic diff --git a/src/Parsers.hs b/src/Parsers.hs index 4703733..9872a63 100644 --- a/src/Parsers.hs +++ b/src/Parsers.hs @@ -21,7 +21,6 @@ module Parsers ) where import Config -import Types import Runnable import Commands @@ -29,6 +28,8 @@ import qualified Data.Map as Map import Text.ParserCombinators.Parsec import Text.ParserCombinators.Parsec.Perm +data Widget = Icon String | Text String + type ColorString = String -- | Runs the string parser diff --git a/src/XUtil.hsc b/src/XUtil.hsc index 720e895..164a309 100644 --- a/src/XUtil.hsc +++ b/src/XUtil.hsc @@ -17,8 +17,6 @@ module XUtil , initFont , initCoreFont , initUtf8Font - , loadBitmap - , drawBitmap , textExtents , textWidth , printString @@ -41,10 +39,7 @@ import qualified Graphics.X11.Xlib as Xlib (textExtents, textWidth) import Graphics.X11.Xlib.Extras import System.Mem.Weak ( addFinalizer ) import System.Posix.Types (Fd(..)) -import System.Directory (doesFileExist) import System.IO -import XGraphic -import Types #if defined XFT || defined UTF8 # if __GLASGOW_HASKELL__ < 612 @@ -158,25 +153,6 @@ textExtents (Xft xftfont) _ = do return (ascent, descent) #endif -loadBitmap :: Display -> Drawable -> FilePath -> IO (Maybe Bitmap) -loadBitmap d w p = do - exist <- doesFileExist p - if exist - then do - (bw, bh, bp, _, _) <- readBitmapFile d w p - addFinalizer bp (freePixmap d bp) - return $ Just $ Bitmap bw bh bp - else - return Nothing - -drawBitmap :: Display -> Drawable -> XFont -> GC -> String -> String - -> Position -> Position -> Bitmap -> IO () -drawBitmap d p _ gc fc bc x y i = do - withColors d [fc, bc] $ \[fc', bc'] -> do - setForeground d gc fc' - setBackground d gc bc' - 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 -> String -> IO () printString d p (Core fs) gc fc bc x y s = do diff --git a/src/Xmobar.hs b/src/Xmobar.hs index b7355c4..04f0770 100644 --- a/src/Xmobar.hs +++ b/src/Xmobar.hs @@ -43,12 +43,12 @@ import Control.Exception (handle, SomeException(..)) import Data.Bits import Data.Map hiding (foldr, map, filter) +import Bitmap import Config import Parsers import Commands import Runnable import Signal -import Types import Window import XUtil import ColorCache @@ -230,18 +230,6 @@ updateString conf v = do let l:c:r:_ = s ++ repeat "" io $ mapM (parseString conf) [l, c, r] -updateCache :: Display -> Window -> Map FilePath Bitmap -> [[(Widget, String)]] -> IO (Map FilePath Bitmap) -updateCache dpy win cache ps = do - let paths = map (\(Icon p, _) -> p) . concatMap (filter icons) $ ps - icons (Icon _, _) = True - icons _ = False - foldM (\m path -> if member path m - then return m - else do bitmap <- io $ loadBitmap dpy win path - case bitmap of - Nothing -> return m - Just bmap -> return $ insert path bmap m) cache paths - -- $print -- | Draws in and updates the window @@ -299,5 +287,5 @@ printStrings dr gc fontst offs a sl@((s,c,l):xs) = do (f, _) -> (f, bgColor conf) case s of (Text t) -> io $ printString d dr fontst gc fc bc offset valign t - (Icon p) -> io $ maybe (return ()) (drawBitmap d dr fontst gc fc bc offset valign) (lookup p (iconS r)) + (Icon p) -> io $ maybe (return ()) (drawBitmap d dr gc fc bc offset valign) (lookup p (iconS r)) printStrings dr gc fontst (offs + l) a xs diff --git a/xmobar.cabal b/xmobar.cabal index 3f2ecd2..6a1cbb8 100644 --- a/xmobar.cabal +++ b/xmobar.cabal @@ -74,7 +74,7 @@ executable xmobar hs-source-dirs: src main-is: Main.hs other-modules: - Xmobar, Config, Parsers, Commands, Localize, XGraphic, + Xmobar, Bitmap, Config, Parsers, Commands, Localize, XGraphic, XUtil, StatFS, Runnable, ColorCache, Window, Signal, Plugins, Plugins.BufferedPipeReader, Plugins.CommandReader, Plugins.Date, Plugins.EWMH, |