From bec143183692b260bd02fc982952b31c672f2f29 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Sat, 22 Jan 2011 15:53:26 +0100 Subject: Wee refactoring --- src/Xmobar.hs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/Xmobar.hs') 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) -- cgit v1.2.3