aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDon Stewart <dons@galois.com>2008-02-06 20:22:32 +0100
committerDon Stewart <dons@galois.com>2008-02-06 20:22:32 +0100
commitb81991ec2356321dd24b1a8baf5bd30a19cad988 (patch)
treef9d051eaa383919d16217e9919daeb241401ba6a
parent5009f058cc0cc6ae9ea6728e14fec66646d3e412 (diff)
downloadXMonadContrib-b81991ec2356321dd24b1a8baf5bd30a19cad988.tar.gz
XMonadContrib-b81991ec2356321dd24b1a8baf5bd30a19cad988.tar.xz
XMonadContrib-b81991ec2356321dd24b1a8baf5bd30a19cad988.zip
Update to safer initColor api
darcs-hash:20080206192232-cba2c-fe41eae586cdcde8b8fa18789440175c4cdd0eaa.gz
-rw-r--r--XMonad/Prompt.hs8
-rw-r--r--XMonad/Util/Font.cpphs8
2 files changed, 9 insertions, 7 deletions
diff --git a/XMonad/Prompt.hs b/XMonad/Prompt.hs
index 8e12f22..f9e3d88 100644
--- a/XMonad/Prompt.hs
+++ b/XMonad/Prompt.hs
@@ -463,8 +463,8 @@ drawWin = do
wh = widthOfScreen scr
ht = height c
bw = promptBorderWidth c
- bgcolor <- io $ initColor d (bgColor c)
- border <- io $ initColor d (borderColor c)
+ Just bgcolor <- io $ initColor d (bgColor c)
+ Just border <- io $ initColor d (borderColor c)
p <- io $ createPixmap d w wh ht
(defaultDepthOfScreen scr)
io $ fillDrawable d p gc border bgcolor (fi bw) wh ht
@@ -569,8 +569,8 @@ drawComplWin w compl = do
scr = defaultScreenOfDisplay d
bw = promptBorderWidth c
gc = gcon st
- bgcolor <- io $ initColor d (bgColor c)
- border <- io $ initColor d (borderColor c)
+ Just bgcolor <- io $ initColor d (bgColor c)
+ Just border <- io $ initColor d (borderColor c)
(_,_,wh,ht,xx,yy) <- getComplWinDim compl
diff --git a/XMonad/Util/Font.cpphs b/XMonad/Util/Font.cpphs
index dd232f1..b6cf2ad 100644
--- a/XMonad/Util/Font.cpphs
+++ b/XMonad/Util/Font.cpphs
@@ -31,6 +31,8 @@ module XMonad.Util.Font (
import XMonad
import Foreign
+import Control.Applicative
+import Data.Maybe
#ifdef XFT
import Data.List
@@ -49,10 +51,10 @@ data XMonadFont = Core FontStruct
-- | Get the Pixel value for a named color: if an invalid name is
-- given the black pixel will be returned.
-stringToPixel :: MonadIO m => Display -> String -> m Pixel
-stringToPixel d s = liftIO $ catch getIt fallBack
+stringToPixel :: (Functor m, MonadIO m) => Display -> String -> m Pixel
+stringToPixel d s = fromMaybe fallBack <$> liftIO getIt
where getIt = initColor d s
- fallBack = const $ return $ blackPixel d (defaultScreen d)
+ fallBack = blackPixel d (defaultScreen d)
-- | Given a fontname returns the font structure. If the font name is