diff options
author | Jan Vornberger <jan.vornberger@informatik.uni-oldenburg.de> | 2010-07-28 00:48:41 +0200 |
---|---|---|
committer | Jan Vornberger <jan.vornberger@informatik.uni-oldenburg.de> | 2010-07-28 00:48:41 +0200 |
commit | ab0d160ac877c9719dd8112e6f06312f3cd69d6c (patch) | |
tree | b3e9b26a52f7a1981645090e4f72eea340a9cff9 /XMonad | |
parent | 5217c7c613b3559c65db9de11aec1b744df062cb (diff) | |
download | XMonadContrib-ab0d160ac877c9719dd8112e6f06312f3cd69d6c.tar.gz XMonadContrib-ab0d160ac877c9719dd8112e6f06312f3cd69d6c.tar.xz XMonadContrib-ab0d160ac877c9719dd8112e6f06312f3cd69d6c.zip |
Minimize: Replaced calls to 'sendMessage' (BW.focusDown) and 'windows' with alternative methods
Ignore-this: 67257480b7b93181967a806fedf6fbc5
Calling these functions during message handling results in the loss of layout state.
This fixes a number of bugs related to the combination of X.L.Minimize with a decoration.
darcs-hash:20100727224841-594c5-c8ddec3ae634ec96103e332433066b5173a0002a.gz
Diffstat (limited to 'XMonad')
-rw-r--r-- | XMonad/Actions/WindowMenu.hs | 2 | ||||
-rw-r--r-- | XMonad/Config/Bluetile.hs | 2 | ||||
-rw-r--r-- | XMonad/Hooks/Minimize.hs | 2 | ||||
-rw-r--r-- | XMonad/Layout/DecorationAddons.hs | 2 | ||||
-rw-r--r-- | XMonad/Layout/ImageButtonDecoration.hs | 2 | ||||
-rw-r--r-- | XMonad/Layout/Minimize.hs | 21 |
6 files changed, 17 insertions, 14 deletions
diff --git a/XMonad/Actions/WindowMenu.hs b/XMonad/Actions/WindowMenu.hs index d59cddc..8edc1c9 100644 --- a/XMonad/Actions/WindowMenu.hs +++ b/XMonad/Actions/WindowMenu.hs @@ -62,7 +62,7 @@ windowMenu = withFocused $ \w -> do actions = [ ("Cancel menu", return ()) , ("Close" , kill) , ("Maximize" , sendMessage $ maximizeRestore w) - , ("Minimize" , sendMessage $ MinimizeWin w) + , ("Minimize" , minimizeWindow w) ] ++ [ ("Move to " ++ tag, windows $ W.shift tag) | tag <- tags ] diff --git a/XMonad/Config/Bluetile.hs b/XMonad/Config/Bluetile.hs index 10b0f45..d80e70c 100644 --- a/XMonad/Config/Bluetile.hs +++ b/XMonad/Config/Bluetile.hs @@ -141,7 +141,7 @@ bluetileKeys conf@(XConfig {XMonad.modMask = modMask'}) = M.fromList $ , ((modMask' , xK_z), withFocused (sendMessage . maximizeRestore)) -- Minimizing - , ((modMask', xK_m ), withFocused (\f -> sendMessage (MinimizeWin f))) + , ((modMask', xK_m ), withFocused minimizeWindow) , ((modMask' .|. shiftMask, xK_m ), sendMessage RestoreNextMinimizedWin) ] ++ diff --git a/XMonad/Hooks/Minimize.hs b/XMonad/Hooks/Minimize.hs index e293e6d..dd9567c 100644 --- a/XMonad/Hooks/Minimize.hs +++ b/XMonad/Hooks/Minimize.hs @@ -47,7 +47,7 @@ minimizeEventHook (ClientMessageEvent {ev_window = w, when (mt == a_cs) $ do let message = fromIntegral . head $ dt when (message == normalState) $ sendMessage (RestoreMinimizedWin w) - when (message == iconicState) $ sendMessage (MinimizeWin w) + when (message == iconicState) $ minimizeWindow w return (All True) minimizeEventHook _ = return (All True) diff --git a/XMonad/Layout/DecorationAddons.hs b/XMonad/Layout/DecorationAddons.hs index 9192e54..6d751ec 100644 --- a/XMonad/Layout/DecorationAddons.hs +++ b/XMonad/Layout/DecorationAddons.hs @@ -62,7 +62,7 @@ titleBarButtonHandler mainw distFromLeft distFromRight = do then focus mainw >> sendMessage (maximizeRestore mainw) >> return True else if (fi distFromRight >= minimizeButtonOffset && fi distFromRight <= minimizeButtonOffset + buttonSize) - then focus mainw >> sendMessage (MinimizeWin mainw) >> return True + then focus mainw >> minimizeWindow mainw >> return True else return False action diff --git a/XMonad/Layout/ImageButtonDecoration.hs b/XMonad/Layout/ImageButtonDecoration.hs index c8d8453..23c6cc3 100644 --- a/XMonad/Layout/ImageButtonDecoration.hs +++ b/XMonad/Layout/ImageButtonDecoration.hs @@ -158,7 +158,7 @@ imageTitleBarButtonHandler mainw distFromLeft distFromRight = do then focus mainw >> sendMessage (maximizeRestore mainw) >> return True else if (fi distFromRight >= minimizeButtonOffset && fi distFromRight <= minimizeButtonOffset + buttonSize) - then focus mainw >> sendMessage (MinimizeWin mainw) >> return True + then focus mainw >> minimizeWindow mainw >> return True else return False action diff --git a/XMonad/Layout/Minimize.hs b/XMonad/Layout/Minimize.hs index aced551..e206ac5 100644 --- a/XMonad/Layout/Minimize.hs +++ b/XMonad/Layout/Minimize.hs @@ -18,7 +18,8 @@ module XMonad.Layout.Minimize ( -- * Usage -- $usage minimize, - MinimizeMsg(..) + minimizeWindow, + MinimizeMsg(RestoreMinimizedWin,RestoreNextMinimizedWin) ) where import XMonad @@ -47,7 +48,7 @@ import Foreign.C.Types (CLong) -- -- In the key-bindings, do something like: -- --- > , ((modm, xK_m ), withFocused (\f -> sendMessage (MinimizeWin f))) +-- > , ((modm, xK_m ), withFocused minimizeWindow) -- > , ((modm .|. shiftMask, xK_m ), sendMessage RestoreNextMinimizedWin) -- -- The first action will minimize the focused window, while the second one will restore @@ -75,6 +76,8 @@ data MinimizeMsg = MinimizeWin Window deriving (Typeable, Eq) instance Message MinimizeMsg +minimizeWindow :: Window -> X () +minimizeWindow w = sendMessage (MinimizeWin w) >> BW.focusDown setMinimizedState :: Window -> Int -> (CLong -> [CLong] -> [CLong]) -> X () setMinimizedState win st f = do @@ -103,34 +106,34 @@ instance LayoutModifier Minimize Window where handleMess (Minimize minimized unfloated) m | Just (MinimizeWin w) <- fromMessage m, not (w `elem` minimized) = do - BW.focusDown setMinimized w ws <- gets windowset case M.lookup w (W.floating ws) of Nothing -> return $ Just $ Minimize (w:minimized) unfloated Just r -> do - (windows . W.sink) w + modify (\s -> s { windowset = W.sink w ws}) return $ Just $ Minimize (w:minimized) (M.insert w r unfloated) | Just (RestoreMinimizedWin w) <- fromMessage m = do setNotMinimized w case M.lookup w unfloated of Nothing -> return $ Just $ Minimize (minimized \\ [w]) unfloated Just r -> do - (windows . (W.float w)) r + ws <- gets windowset + modify (\s -> s { windowset = W.float w r ws}) return $ Just $ Minimize (minimized \\ [w]) (M.delete w unfloated) - | Just RestoreNextMinimizedWin <- fromMessage m = + | Just RestoreNextMinimizedWin <- fromMessage m = do + ws <- gets windowset if not (null minimized) then case M.lookup (head minimized) unfloated of Nothing -> do let w = head minimized setNotMinimized w - focus w + modify (\s -> s { windowset = W.focusWindow w ws}) return $ Just $ Minimize (tail minimized) unfloated Just r -> do let w = head minimized setNotMinimized w - (windows . (W.float w)) r - focus w + modify (\s -> s { windowset = (W.focusWindow w . W.float w r) ws}) return $ Just $ Minimize (tail minimized) (M.delete w unfloated) else return Nothing | Just BW.UpdateBoring <- fromMessage m = do |