X.L.MagicFocus: always use focused as master

Instead of searching for the currently focused window across workspaces,
make it so there is never any window above focus on the Stack that is
given to the modified layout.

Closes #657.
This commit is contained in:
d3adb5
2021-11-27 17:06:27 -03:00
parent 3d71669b0a
commit 97beb3efc7
2 changed files with 10 additions and 7 deletions

View File

@@ -37,6 +37,12 @@
- Fixed navigation getting "stuck" in certain situations for - Fixed navigation getting "stuck" in certain situations for
widescreen resolutions. widescreen resolutions.
* `XMonad.Layout.MagicFocus`
- The focused window will always be at the master area in the stack being
passed onto the modified layout, even when focus leaves the workspace
using the modified layout.
## 0.17.0 (October 27, 2021) ## 0.17.0 (October 27, 2021)
### Breaking Changes ### Breaking Changes

View File

@@ -57,14 +57,11 @@ magicFocus = ModifiedLayout MagicFocus
data MagicFocus a = MagicFocus deriving (Show, Read) data MagicFocus a = MagicFocus deriving (Show, Read)
instance LayoutModifier MagicFocus Window where instance LayoutModifier MagicFocus Window where
modifyLayout MagicFocus (W.Workspace i l s) r = modifyLayout MagicFocus (W.Workspace i l s) =
withWindowSet $ \wset -> runLayout (W.Workspace i l (s >>= Just . shift))
runLayout (W.Workspace i l (s >>= \st -> Just $ swap st (W.peek wset))) r
swap :: (Eq a) => W.Stack a -> Maybe a -> W.Stack a shift :: (Eq a) => W.Stack a -> W.Stack a
swap (W.Stack f u d) focused shift (W.Stack f u d) = W.Stack f [] (reverse u ++ d)
| Just f == focused = W.Stack f [] (reverse u ++ d)
| otherwise = W.Stack f u d
-- | An eventHook that overrides the normal focusFollowsMouse. When the mouse -- | An eventHook that overrides the normal focusFollowsMouse. When the mouse
-- it moved to another window, that window is replaced as the master, and the -- it moved to another window, that window is replaced as the master, and the