mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-15 04:05:53 -07:00
XMonad.Actions.WindowGo: fix a floating-related focus bug
If a floating window was focused, a cross-workspace 'raise' would cause a loop of shifting windows. Apparently the problem was 'focus' and its mouse-handling. Spencer suggested that the calls to focus be replaced with 'focusWindow', which resolved it.
This commit is contained in:
@@ -34,12 +34,12 @@ module XMonad.Actions.WindowGo (
|
|||||||
import Control.Monad (filterM)
|
import Control.Monad (filterM)
|
||||||
import Data.Char (toLower)
|
import Data.Char (toLower)
|
||||||
|
|
||||||
import XMonad (Query(), X(), withWindowSet, spawn, runQuery, liftIO, focus)
|
import XMonad (Query(), X(), withWindowSet, spawn, runQuery, liftIO)
|
||||||
import XMonad.ManageHook
|
|
||||||
import XMonad.Prompt.Shell (getBrowser, getEditor)
|
|
||||||
import qualified XMonad.StackSet as W (allWindows, peek, swapMaster)
|
|
||||||
import XMonad.Operations (windows)
|
|
||||||
import Graphics.X11 (Window)
|
import Graphics.X11 (Window)
|
||||||
|
import XMonad.ManageHook
|
||||||
|
import XMonad.Operations (windows)
|
||||||
|
import XMonad.Prompt.Shell (getBrowser, getEditor)
|
||||||
|
import qualified XMonad.StackSet as W (allWindows, peek, swapMaster, focusWindow)
|
||||||
{- $usage
|
{- $usage
|
||||||
|
|
||||||
Import the module into your @~\/.xmonad\/xmonad.hs@:
|
Import the module into your @~\/.xmonad\/xmonad.hs@:
|
||||||
@@ -99,7 +99,7 @@ raiseMaybe f thatUserQuery = withWindowSet $ \s -> do
|
|||||||
maybeResult <- filterM (runQuery thatUserQuery) (W.allWindows s)
|
maybeResult <- filterM (runQuery thatUserQuery) (W.allWindows s)
|
||||||
case maybeResult of
|
case maybeResult of
|
||||||
[] -> f
|
[] -> f
|
||||||
(x:_) -> focus x
|
(x:_) -> windows $ W.focusWindow x
|
||||||
|
|
||||||
-- | See 'runOrRaise' and 'raiseNextMaybe'. Version that allows cycling through matches.
|
-- | See 'runOrRaise' and 'raiseNextMaybe'. Version that allows cycling through matches.
|
||||||
runOrRaiseNext :: String -> Query Bool -> X ()
|
runOrRaiseNext :: String -> Query Bool -> X ()
|
||||||
@@ -121,10 +121,10 @@ raiseNextMaybe f thatUserQuery = withWindowSet $ \s -> do
|
|||||||
case ws of
|
case ws of
|
||||||
[] -> f
|
[] -> f
|
||||||
(x:_) -> let go (Just w) | (w `elem` ws) = next w $ cycle ws
|
(x:_) -> let go (Just w) | (w `elem` ws) = next w $ cycle ws
|
||||||
go _ = focus x
|
go _ = windows $ W.focusWindow x
|
||||||
in go $ W.peek s
|
in go $ W.peek s
|
||||||
where
|
where
|
||||||
next w (x:y:_) | x==w = focus y
|
next w (x:y:_) | x==w = windows $ W.focusWindow y
|
||||||
next w (_:xs) = next w xs
|
next w (_:xs) = next w xs
|
||||||
next _ _ = error "raiseNextMaybe: empty list"
|
next _ _ = error "raiseNextMaybe: empty list"
|
||||||
|
|
||||||
@@ -148,8 +148,7 @@ raiseAndDo raisef thatUserQuery afterRaise = withWindowSet $ \s -> do
|
|||||||
maybeResult <- filterM (runQuery thatUserQuery) (W.allWindows s)
|
maybeResult <- filterM (runQuery thatUserQuery) (W.allWindows s)
|
||||||
case maybeResult of
|
case maybeResult of
|
||||||
[] -> raisef
|
[] -> raisef
|
||||||
(x:_) -> do
|
(x:_) -> do windows $ W.focusWindow x
|
||||||
XMonad.focus x
|
|
||||||
afterRaise x
|
afterRaise x
|
||||||
|
|
||||||
{- | if the window is found the window is focused and the third argument is called
|
{- | if the window is found the window is focused and the third argument is called
|
||||||
@@ -157,7 +156,6 @@ raiseAndDo raisef thatUserQuery afterRaise = withWindowSet $ \s -> do
|
|||||||
runOrRaiseAndDo :: String -> Query Bool -> (Window -> X ()) -> X ()
|
runOrRaiseAndDo :: String -> Query Bool -> (Window -> X ()) -> X ()
|
||||||
runOrRaiseAndDo run query afterRaise = raiseAndDo (spawn run) query afterRaise
|
runOrRaiseAndDo run query afterRaise = raiseAndDo (spawn run) query afterRaise
|
||||||
|
|
||||||
|
|
||||||
{- | if the window is found the window is focused and set to master
|
{- | if the window is found the window is focused and set to master
|
||||||
otherwise, the first argument is called
|
otherwise, the first argument is called
|
||||||
|
|
||||||
@@ -172,5 +170,3 @@ raiseMaster raisef thatUserQuery = raiseAndDo raisef thatUserQuery (\_ -> window
|
|||||||
-}
|
-}
|
||||||
runOrRaiseMaster :: String -> Query Bool -> X ()
|
runOrRaiseMaster :: String -> Query Bool -> X ()
|
||||||
runOrRaiseMaster run query = runOrRaiseAndDo run query (\_ -> windows W.swapMaster)
|
runOrRaiseMaster run query = runOrRaiseAndDo run query (\_ -> windows W.swapMaster)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user