diff options
-rw-r--r-- | src/XUtil.hsc | 7 | ||||
-rw-r--r-- | src/Xmobar.hs | 10 | ||||
-rw-r--r-- | xmobar.cabal | 13 |
3 files changed, 23 insertions, 7 deletions
diff --git a/src/XUtil.hsc b/src/XUtil.hsc index 558a4c5..b736c9c 100644 --- a/src/XUtil.hsc +++ b/src/XUtil.hsc @@ -2,10 +2,11 @@ ----------------------------------------------------------------------------- -- | -- Module : XUtil --- Copyright : (C) 2007, 2011 Andrea Rossato +-- Copyright : (C) 2007 Andrea Rossato +-- (C) 2011, 2012 Jose Antonio Ortega Ruiz -- License : BSD3 -- --- Maintainer : andrea.rossato@unitn.it +-- Maintainer : jao@gnu.org -- Stability : unstable -- Portability : unportable -- @@ -34,7 +35,7 @@ import Control.Concurrent import Control.Monad.Trans import Data.IORef import Foreign -import Foreign.C.Types +-- import Foreign.C.Types import Graphics.X11.Xlib hiding (textExtents, textWidth) import qualified Graphics.X11.Xlib as Xlib (textExtents, textWidth) import Graphics.X11.Xlib.Extras diff --git a/src/Xmobar.hs b/src/Xmobar.hs index 2358a20..c348f99 100644 --- a/src/Xmobar.hs +++ b/src/Xmobar.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DeriveDataTypeable, CPP #-} ----------------------------------------------------------------------------- -- | -- Module : Xmobar @@ -84,7 +84,11 @@ startLoop xcfg@(XConf _ _ w _ _) vs = do sig <- setupSignalHandler _ <- forkIO (checker tv [] vs sig `catch` \(SomeException _) -> void (putStrLn "Thread checker failed")) +#ifdef THREADED_RUNTIME + _ <- forkOS (eventer sig `catch` +#else _ <- forkIO (eventer sig `catch` +#endif \(SomeException _) -> void (putStrLn "Thread eventer failed")) eventLoop tv xcfg sig where @@ -97,7 +101,11 @@ startLoop xcfg@(XConf _ _ w _ _) vs = do selectInput dpy w (exposureMask .|. structureNotifyMask) forever $ do +#ifdef THREADED_RUNTIME + nextEvent dpy e +#else nextEvent' dpy e +#endif ev <- getEvent e case ev of ConfigureEvent {} -> putMVar signal Reposition diff --git a/xmobar.cabal b/xmobar.cabal index e80e8b3..db935f7 100644 --- a/xmobar.cabal +++ b/xmobar.cabal @@ -65,6 +65,10 @@ flag with_mpris description: MPRIS v1, v2 support default: False +flag with_threaded + description: Use threaded runtime + default: False + executable xmobar hs-source-dirs: src main-is: Main.hs @@ -89,9 +93,12 @@ executable xmobar ghc-options: -funbox-strict-fields -Wall extra-libraries: Xrandr - -- Use --disable-optimization configure flag - -- if impl (ghc == 6.10.1) && arch (x86_64) - -- ghc-options: -O0 + if flag(with_threaded) + -- -threaded is a workaround 100% CPU busy loop + -- (http://hackage.haskell.org/trac/ghc/ticket/4934) + -- See also comments in https://github.com/jaor/xmobar/pull/36 + ghc-options: -threaded + cpp-options: -DTHREADED_RUNTIME if impl (ghc >= 6.12.1) ghc-options: -fno-warn-unused-do-bind |