From 2b260b3524c69b62736f96993b2d746c562dd40b Mon Sep 17 00:00:00 2001 From: Stefan O'Rear Date: Sun, 3 Jun 2007 22:31:53 +0200 Subject: Correctly handle resize requests (-12 +22) Xmonad now implements resize requests in a consistent manner. * If the window is FLOATING, we implement the program's request, and correctly update the StackSet; so it will keep the new size. This should work correctly even for non-current windows. * Otherwise, we ignore the request. As per ICCCM, we send a fake ConfigureNotify containing the new (unchanged) geometry. This is perfectly ICCCM compliant, and if it breaks your client, it's your own fault. This patch requires setConfigureEvent, which is added to X11-extras by a patch approximately contemporaneous with this one. darcs-hash:20070603203153-e3110-48f345cd3686f06fbe8ba30a6d851e7c8f44fe98 --- Main.hs | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'Main.hs') diff --git a/Main.hs b/Main.hs index 1d759e9..467c630 100644 --- a/Main.hs +++ b/Main.hs @@ -16,6 +16,7 @@ import Data.Bits import qualified Data.Map as M import Control.Monad.Reader +import Control.Monad.State import System.Environment (getArgs) @@ -25,7 +26,7 @@ import Graphics.X11.Xinerama (getScreenInfo) import XMonad import Config -import StackSet (new) +import StackSet (new, floating) import Operations -- @@ -181,17 +182,26 @@ handle e@(CrossingEvent {ev_event_type = t}) when (ev_window e == rootw && not (ev_same_screen e)) $ setFocusX rootw -- configure a window -handle e@(ConfigureRequestEvent {}) = withDisplay $ \dpy -> do - io $ configureWindow dpy (ev_window e) (ev_value_mask e) $ WindowChanges - { wc_x = ev_x e - , wc_y = ev_y e - , wc_width = ev_width e - , wc_height = ev_height e - , wc_border_width = ev_border_width e - , wc_sibling = ev_above e - -- this fromIntegral is only necessary with the old X11 version that uses - -- Int instead of CInt. TODO delete it when there is a new release of X11 - , wc_stack_mode = fromIntegral $ ev_detail e } +handle e@(ConfigureRequestEvent {ev_window = w}) = withDisplay $ \dpy -> do + floating <- gets $ M.member w . floating . windowset + rootw <- asks theRoot + wa <- io $ getWindowAttributes dpy w + + if floating + then do io $ configureWindow dpy w (ev_value_mask e) $ WindowChanges + { wc_x = ev_x e + , wc_y = ev_y e + , wc_width = ev_width e + , wc_height = ev_height e + , wc_border_width = fromIntegral borderWidth + , wc_sibling = ev_above e + , wc_stack_mode = ev_detail e } + float w + else io $ allocaXEvent $ \ev -> do + setEventType ev configureNotify + setConfigureEvent ev w w + (wa_x wa) (wa_y wa) (wa_width wa) (wa_height wa) (ev_border_width e) none (wa_override_redirect wa) + sendEvent dpy w False 0 ev io $ sync dpy False -- the root may have configured -- cgit v1.2.3