From 341dea590795b0a855e43489a8ed6a85719afeb5 Mon Sep 17 00:00:00 2001 From: Tomas Janousek Date: Mon, 1 Feb 2021 00:31:32 +0000 Subject: [PATCH] Call xrrUpdateConfiguration to sync Xlib's view of screen config Xrandrint.h says: /* * if a configure notify on the root is recieved, or * an XRRScreenChangeNotify is recieved, * XRRUpdateConfiguration should be called to update the X library's * view of the screen configuration; it will also invalidate the cache * provided by XRRScreenConfig and XRRConfig, and force a round trip * when next used. Returns invalid status if not an event type * the library routine understand. */ If any user code needs that info/cache to be correct, we need to call this. --- src/XMonad/Main.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/XMonad/Main.hs b/src/XMonad/Main.hs index 6a80cd4..507094e 100644 --- a/src/XMonad/Main.hs +++ b/src/XMonad/Main.hs @@ -24,7 +24,7 @@ import qualified Data.Map as M import qualified Data.Set as S import Control.Monad.Reader import Control.Monad.State -import Data.Maybe (fromMaybe) +import Data.Maybe (fromMaybe, isJust) import Data.Monoid (getAll) import Graphics.X11.Xlib hiding (refreshKeyboardMapping) @@ -48,6 +48,7 @@ import Paths_xmonad (version) import Data.Version (showVersion) import Graphics.X11.Xinerama (compiledWithXinerama) +import Graphics.X11.Xrandr (xrrQueryExtension, xrrUpdateConfiguration) ------------------------------------------------------------------------ @@ -261,8 +262,11 @@ launch initxmc drs = do userCode $ startupHook initxmc + rrData <- io $ xrrQueryExtension dpy + let rrUpdate = when (isJust rrData) . void . xrrUpdateConfiguration + -- main loop, for all you HOF/recursion fans out there. - forever $ prehandle =<< io (nextEvent dpy e >> getEvent e) + forever $ prehandle =<< io (nextEvent dpy e >> rrUpdate e >> getEvent e) return () where