mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
MagicFocus: reimplement as a LayoutModifier, fix bug (MagicFocus didn't pass on messages to underlying layouts)
This commit is contained in:
parent
929c9a1b56
commit
a1fce4af5a
@ -16,40 +16,39 @@
|
|||||||
module XMonad.Layout.MagicFocus
|
module XMonad.Layout.MagicFocus
|
||||||
(-- * Usage
|
(-- * Usage
|
||||||
-- $usage
|
-- $usage
|
||||||
MagicFocus(MagicFocus)
|
magicFocus
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import XMonad
|
import XMonad
|
||||||
import XMonad.StackSet
|
import XMonad.StackSet
|
||||||
|
import XMonad.Layout.LayoutModifier
|
||||||
|
|
||||||
-- $usage
|
-- $usage
|
||||||
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
|
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
|
||||||
--
|
--
|
||||||
-- > import XMonad.Layout.MagicFocus
|
-- > import XMonad.Layout.MagicFocus
|
||||||
--
|
--
|
||||||
-- Then edit your @layoutHook@ by adding the MagicFocus layout
|
-- Then edit your @layoutHook@ by adding the magicFocus layout
|
||||||
-- modifier:
|
-- modifier:
|
||||||
--
|
--
|
||||||
-- > myLayouts = MagicFocus (Tall 1 (3/100) (1/2)) ||| Full ||| etc..
|
-- > myLayouts = magicFocus (Tall 1 (3/100) (1/2)) ||| Full ||| etc..
|
||||||
-- > main = xmonad defaultConfig { layoutHook = myLayouts }
|
-- > main = xmonad defaultConfig { layoutHook = myLayouts }
|
||||||
--
|
--
|
||||||
-- For more detailed instructions on editing the layoutHook see:
|
-- For more detailed instructions on editing the layoutHook see:
|
||||||
--
|
--
|
||||||
-- "XMonad.Doc.Extending#Editing_the_layout_hook"
|
-- "XMonad.Doc.Extending#Editing_the_layout_hook"
|
||||||
|
|
||||||
data MagicFocus l a = MagicFocus (l a) deriving ( Show , Read )
|
-- | Create a new layout which automagically puts the focused window
|
||||||
|
-- in the master area.
|
||||||
|
magicFocus :: l a -> ModifiedLayout MagicFocus l a
|
||||||
|
magicFocus = ModifiedLayout MagicFocus
|
||||||
|
|
||||||
instance (LayoutClass l Window) => LayoutClass (MagicFocus l) Window where
|
data MagicFocus a = MagicFocus deriving (Show, Read)
|
||||||
doLayout = magicFocus
|
|
||||||
|
|
||||||
magicFocus :: LayoutClass l Window => MagicFocus l Window -> Rectangle
|
instance LayoutModifier MagicFocus Window where
|
||||||
-> Stack Window -> X ([(Window, Rectangle)], Maybe (MagicFocus l Window))
|
modifyLayout MagicFocus (Workspace i l s) r =
|
||||||
magicFocus (MagicFocus l) r s =
|
withWindowSet $ \wset ->
|
||||||
withWindowSet $ \wset -> do
|
runLayout (Workspace i l (s >>= \st -> Just $ swap st (peek wset))) r
|
||||||
(ws,nl) <- runLayout (Workspace "" l (Just . swap s $ peek wset)) r
|
|
||||||
case nl of
|
|
||||||
Nothing -> return (ws, Nothing)
|
|
||||||
Just l' -> return (ws, Just $ MagicFocus l')
|
|
||||||
|
|
||||||
swap :: (Eq a) => Stack a -> Maybe a -> Stack a
|
swap :: (Eq a) => Stack a -> Maybe a -> Stack a
|
||||||
swap (Stack f u d) focused | Just f == focused = Stack f [] (reverse u ++ d)
|
swap (Stack f u d) focused | Just f == focused = Stack f [] (reverse u ++ d)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user