mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-07-30 19:51:51 -07:00
Fix bug in L.TrackFloating
Addresses the comment that: If the focus goes from the floating layer to tiling by deleting a floating window, it's again the master window that gets focus, not the remembered window.
This commit is contained in:
@@ -29,6 +29,7 @@ module XMonad.Layout.TrackFloating
|
|||||||
|
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Data.List
|
import Data.List
|
||||||
|
import Data.Maybe
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
|
||||||
import XMonad
|
import XMonad
|
||||||
@@ -36,19 +37,22 @@ import XMonad.Layout.LayoutModifier
|
|||||||
import qualified XMonad.StackSet as W
|
import qualified XMonad.StackSet as W
|
||||||
|
|
||||||
|
|
||||||
data TrackFloating a = TrackFloating (Maybe Window)
|
data TrackFloating a = TrackFloating
|
||||||
deriving (Read,Show)
|
{ _wasFloating :: Bool,
|
||||||
|
_tiledFocus :: Maybe Window }
|
||||||
|
deriving (Read,Show,Eq)
|
||||||
|
|
||||||
|
|
||||||
instance LayoutModifier TrackFloating Window where
|
instance LayoutModifier TrackFloating Window where
|
||||||
modifyLayoutWithUpdate (TrackFloating mw) ws@(W.Workspace{ W.stack = ms }) r
|
modifyLayoutWithUpdate os@(TrackFloating wasF mw) ws@(W.Workspace{ W.stack = ms }) r
|
||||||
= do
|
= do
|
||||||
winset <- gets windowset
|
winset <- gets windowset
|
||||||
let sTotal = W.stack $ W.workspace $ W.current winset
|
let sCur = fmap W.focus $ W.stack $ W.workspace $ W.current winset
|
||||||
|
isF = fmap (`M.member` W.floating winset) sCur
|
||||||
newStack
|
newStack
|
||||||
-- focus is floating, so use the remembered focus point
|
-- focus is floating, so use the remembered focus point
|
||||||
| Just sTotal' <- sTotal,
|
| Just isF' <- isF,
|
||||||
W.focus sTotal' `M.member` W.floating winset,
|
isF' || wasF,
|
||||||
Just w <- mw,
|
Just w <- mw,
|
||||||
Just s <- ms,
|
Just s <- ms,
|
||||||
Just ns <- find ((==) w . W.focus)
|
Just ns <- find ((==) w . W.focus)
|
||||||
@@ -56,15 +60,14 @@ instance LayoutModifier TrackFloating Window where
|
|||||||
= Just ns
|
= Just ns
|
||||||
| otherwise
|
| otherwise
|
||||||
= ms
|
= ms
|
||||||
newState
|
newState = case isF of
|
||||||
| Just sTotal' <- sTotal
|
Just True -> mw
|
||||||
= if W.focus sTotal' `M.member` W.floating winset
|
Just False | Just f <- sCur -> Just f
|
||||||
then mw
|
_ -> Nothing
|
||||||
else Just (W.focus sTotal')
|
|
||||||
| otherwise
|
|
||||||
= Nothing
|
|
||||||
ran <- runLayout ws{ W.stack = newStack } r
|
ran <- runLayout ws{ W.stack = newStack } r
|
||||||
return (ran, guard (newState /= mw) >> Just (TrackFloating newState))
|
return (ran,
|
||||||
|
let n = TrackFloating (fromMaybe False isF) newState
|
||||||
|
in guard (n /= os) >> Just n)
|
||||||
|
|
||||||
|
|
||||||
{- | Apply to your layout in a config like:
|
{- | Apply to your layout in a config like:
|
||||||
@@ -79,5 +82,5 @@ Interactions with some layout modifiers (ex. decorations, minimizing) are
|
|||||||
unknown but likely unpleasant.
|
unknown but likely unpleasant.
|
||||||
-}
|
-}
|
||||||
trackFloating :: l a -> ModifiedLayout TrackFloating l a
|
trackFloating :: l a -> ModifiedLayout TrackFloating l a
|
||||||
trackFloating layout = ModifiedLayout (TrackFloating Nothing) layout
|
trackFloating layout = ModifiedLayout (TrackFloating False Nothing) layout
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user