From bba4b08bb0056d44c3d1535e08ed0a32ed060f1f Mon Sep 17 00:00:00 2001 From: Martin Perner Date: Tue, 30 Aug 2011 21:06:57 +0200 Subject: Init commit handle doesn't get all events. simple c program and simple haskell program are getting all of them. there must be something in xmobar which catches about 3 of the screenchange events ... --- src/XUtil.hsc | 6 ++++++ src/Xmobar.hs | 11 ++++++++++- xmobar.cabal | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/XUtil.hsc b/src/XUtil.hsc index d5bb591..6511b10 100644 --- a/src/XUtil.hsc +++ b/src/XUtil.hsc @@ -28,6 +28,7 @@ module XUtil , fi , withColors , DynPixel(..) + , xrrSelectInput ) where import Control.Concurrent @@ -257,3 +258,8 @@ setupLocale = withCString "" (setlocale $ #const LC_ALL) >> return () setupLocale :: IO () setupLocale = return () #endif + +-- XRRSelectInput +#include +foreign import ccall unsafe "X11/extensions/Xrandr.h XRRSelectInput" + xrrSelectInput :: Display -> Window -> EventMask -> IO () diff --git a/src/Xmobar.hs b/src/Xmobar.hs index eb7a1dd..f0c00cb 100644 --- a/src/Xmobar.hs +++ b/src/Xmobar.hs @@ -103,6 +103,7 @@ eventLoop xc@(XConf d _ w fs c) vs = block $ do -- event hanlder handle _ ct (ConfigureEvent {ev_window = win}) = do rootw <- rootWindow d (defaultScreen d) + putStrLn "Configure" when (win == rootw) $ block $ do killThread ct destroyWindow d w @@ -111,7 +112,13 @@ eventLoop xc@(XConf d _ w fs c) vs = block $ do handle tvar _ (ExposeEvent {}) = runX xc (updateWin tvar) - handle _ _ _ = return () + -- this catches the RRScreenChangeNotify + handle _ ct _ = block $ do + putStrLn "ScreenChange" + killThread ct + destroyWindow d w + (r',w') <- createWin d fs c + eventLoop (XConf d r' w' fs c) vs -- $command @@ -141,6 +148,8 @@ createWin d fs c = do (r,o) = setPosition (position c) srs (fi ht) win <- newWindow d (defaultScreenOfDisplay d) rootw r o selectInput d win (exposureMask .|. structureNotifyMask) + -- RRScreenChangeNotifyMask has the same value as keyPressMask + xrrSelectInput d rootw (keyPressMask) setProperties r c d win srs when (lowerOnStart c) (lowerWindow d win) mapWindow d win diff --git a/xmobar.cabal b/xmobar.cabal index ecafe1d..bb46101 100644 --- a/xmobar.cabal +++ b/xmobar.cabal @@ -82,6 +82,7 @@ executable xmobar if true ghc-options: -funbox-strict-fields -Wall + extra-libraries: Xrandr if impl (ghc == 6.10.1) && arch (x86_64) ghc-options: -O0 -- cgit v1.2.3