summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2011-01-22 15:53:26 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2011-01-22 15:53:26 +0100
commitbec143183692b260bd02fc982952b31c672f2f29 (patch)
treeb03f2a6302b1836ad939fd7ec4dc2d0a98bcc010 /src
parent2f2f2ebc4d25a5ae5c6fb9f8e4200dc547e94bc2 (diff)
downloadxmobar-bec143183692b260bd02fc982952b31c672f2f29.tar.gz
xmobar-bec143183692b260bd02fc982952b31c672f2f29.tar.bz2
Wee refactoring
Diffstat (limited to 'src')
-rw-r--r--src/Xmobar.hs10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/Xmobar.hs b/src/Xmobar.hs
index 566f8e8..15abca3 100644
--- a/src/Xmobar.hs
+++ b/src/Xmobar.hs
@@ -74,7 +74,7 @@ instance Exception WakeUp
-- | The event loop
eventLoop :: XConf -> [[(Maybe ThreadId, TVar String)]] -> IO ()
-eventLoop xc@(XConf d _ w fs c) v = block $ do
+eventLoop xc@(XConf d _ w fs c) vs = block $ do
tv <- atomically $ newTVar []
t <- myThreadId
ct <- forkIO (checker t tv [] `catch` \(SomeException _) -> return ())
@@ -83,16 +83,14 @@ eventLoop xc@(XConf d _ w fs c) v = block $ do
-- interrupt the drawing thread every time a var is updated
checker t tvar ov = do
nval <- atomically $ do
- nv <- mapM concatV v
+ nv <- mapM concatV vs
guard (nv /= ov)
writeTVar tvar nv
return nv
throwTo t WakeUp
checker t tvar nval
- concatV xs = do
- s <- mapM (readTVar . snd) xs
- return $ concat s
+ concatV = fmap concat . mapM (readTVar . snd)
-- Continuously wait for a timer interrupt or an expose event
go tv ct = do
@@ -108,7 +106,7 @@ eventLoop xc@(XConf d _ w fs c) v = block $ do
killThread ct
destroyWindow d w
(r',w') <- createWin d fs c
- eventLoop (XConf d r' w' fs c) v
+ eventLoop (XConf d r' w' fs c) vs
handle tvar _ (ExposeEvent {}) = runX xc (updateWin tvar)