summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/XUtil.hsc12
-rw-r--r--src/Xmobar.hs15
2 files changed, 4 insertions, 23 deletions
diff --git a/src/XUtil.hsc b/src/XUtil.hsc
index ea051f8..558a4c5 100644
--- a/src/XUtil.hsc
+++ b/src/XUtil.hsc
@@ -28,8 +28,6 @@ module XUtil
, fi
, withColors
, DynPixel(..)
- , xrrSelectInput
- , xrrQueryExtension
) where
import Control.Concurrent
@@ -45,7 +43,6 @@ import System.Posix.Types (Fd(..))
import System.IO
#if defined XFT || defined UTF8
# if __GLASGOW_HASKELL__ < 612
-import Foreign.C
import qualified System.IO.UTF8 as UTF8 (readFile,hGetLine)
# else
import qualified System.IO as UTF8 (readFile,hGetLine)
@@ -260,12 +257,3 @@ setupLocale = withCString "" (setlocale $ #const LC_ALL) >> return ()
setupLocale :: IO ()
setupLocale = return ()
#endif
-
--- XRRSelectInput
-#include <X11/extensions/Xrandr.h>
-foreign import ccall unsafe "X11/extensions/Xrandr.h XRRSelectInput"
- xrrSelectInput :: Display -> Window -> EventMask -> IO ()
-
--- XRRQueryExtension
-foreign import ccall unsafe "X11/extensions/Xrandr.h XRRQueryExtension"
- xrrQueryExtension :: Display -> Ptr CInt -> Ptr CInt -> IO (Bool)
diff --git a/src/Xmobar.hs b/src/Xmobar.hs
index dc671fe..3083087 100644
--- a/src/Xmobar.hs
+++ b/src/Xmobar.hs
@@ -33,6 +33,7 @@ import Prelude hiding (catch)
import Graphics.X11.Xlib hiding (textExtents, textWidth)
import Graphics.X11.Xlib.Extras
import Graphics.X11.Xinerama
+import Graphics.X11.Xrandr
import Control.Arrow ((&&&))
import Control.Monad.Reader
@@ -88,28 +89,20 @@ startLoop xcfg@(XConf _ _ w _ _) vs = do
where
-- Reacts on events from X
eventer signal =
- alloca $ \ptrEventBase ->
- alloca $ \ptrErrorBase ->
allocaXEvent $ \e -> do
dpy <- openDisplay ""
- -- keyPressMask is the same value as RRScreenChangeNotifyMask
- xrrSelectInput dpy (defaultRootWindow dpy) keyPressMask
+ xrrSelectInput dpy (defaultRootWindow dpy) rrScreenChangeNotifyMask
selectInput dpy w (exposureMask .|. structureNotifyMask)
- _ <- xrrQueryExtension dpy ptrEventBase ptrErrorBase
- xrrEventBase <- peek ptrEventBase
-
forever $ do
nextEvent' dpy e
ev <- getEvent e
case ev of
ConfigureEvent {} -> putMVar signal Reposition
ExposeEvent {} -> putMVar signal Wakeup
- _ ->
- -- 0 is the value of RRScreenChangeNotify
- when ( (fromIntegral (ev_event_type ev) - xrrEventBase) == 0)
- $ putMVar signal Reposition
+ RRScreenChangeNotifyEvent {} -> putMVar signal Reposition
+ _ -> return ()
-- | Send signal to eventLoop every time a var is updated
checker :: TVar [String] -> [String] -> [[(Maybe ThreadId, TVar String)]] -> MVar SignalType -> IO ()