mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
LayoutModifier: reimplement ModifiedLayout using runLayout and more
- change modifyLayout type to get the Workspace - updated ResizeScreen and ManageDocks accordingly.
This commit is contained in:
parent
9ac91e3a15
commit
3ca4966b06
@ -122,9 +122,9 @@ data ToggleStruts = ToggleStruts deriving (Read,Show,Typeable)
|
|||||||
instance Message ToggleStruts
|
instance Message ToggleStruts
|
||||||
|
|
||||||
instance LayoutModifier AvoidStruts a where
|
instance LayoutModifier AvoidStruts a where
|
||||||
modifyLayout (AvoidStruts b) l r s = do
|
modifyLayout (AvoidStruts b) w r = do
|
||||||
nr <- if b then fmap ($ r) calcGap else return r
|
nr <- if b then fmap ($ r) calcGap else return r
|
||||||
doLayout l nr s
|
runLayout w nr
|
||||||
|
|
||||||
handleMess (AvoidStruts b ) m
|
handleMess (AvoidStruts b ) m
|
||||||
| Just ToggleStruts <- fromMessage m = return $ Just $ AvoidStruts (not b)
|
| Just ToggleStruts <- fromMessage m = return $ Just $ AvoidStruts (not b)
|
||||||
|
@ -21,7 +21,7 @@ module XMonad.Layout.LayoutModifier (
|
|||||||
) where
|
) where
|
||||||
|
|
||||||
import XMonad
|
import XMonad
|
||||||
import XMonad.StackSet ( Stack )
|
import XMonad.StackSet ( Stack, Workspace (..) )
|
||||||
|
|
||||||
-- $usage
|
-- $usage
|
||||||
-- Use LayoutModifier to help write easy Layouts.
|
-- Use LayoutModifier to help write easy Layouts.
|
||||||
@ -33,9 +33,9 @@ import XMonad.StackSet ( Stack )
|
|||||||
-- "XMonad.Layout.Magnifier", "XMonad.Layout.NoBorder",
|
-- "XMonad.Layout.Magnifier", "XMonad.Layout.NoBorder",
|
||||||
|
|
||||||
class (Show (m a), Read (m a)) => LayoutModifier m a where
|
class (Show (m a), Read (m a)) => LayoutModifier m a where
|
||||||
modifyLayout :: (LayoutClass l a) => m a -> l a -> Rectangle
|
modifyLayout :: (LayoutClass l a) => m a -> Workspace WorkspaceId (l a) a
|
||||||
-> Stack a -> X ([(a, Rectangle)], Maybe (l a))
|
-> Rectangle -> X ([(a, Rectangle)], Maybe (l a))
|
||||||
modifyLayout _ l r s = doLayout l r s
|
modifyLayout _ w r = runLayout w r
|
||||||
handleMess :: m a -> SomeMessage -> X (Maybe (m a))
|
handleMess :: m a -> SomeMessage -> X (Maybe (m a))
|
||||||
handleMess m mess | Just Hide <- fromMessage mess = doUnhook
|
handleMess m mess | Just Hide <- fromMessage mess = doUnhook
|
||||||
| Just ReleaseResources <- fromMessage mess = doUnhook
|
| Just ReleaseResources <- fromMessage mess = doUnhook
|
||||||
@ -67,20 +67,16 @@ class (Show (m a), Read (m a)) => LayoutModifier m a where
|
|||||||
x <> y = x ++ " " ++ y
|
x <> y = x ++ " " ++ y
|
||||||
|
|
||||||
instance (LayoutModifier m a, LayoutClass l a) => LayoutClass (ModifiedLayout m l) a where
|
instance (LayoutModifier m a, LayoutClass l a) => LayoutClass (ModifiedLayout m l) a where
|
||||||
doLayout (ModifiedLayout m l) r s =
|
runLayout (Workspace i (ModifiedLayout m l) ms) r =
|
||||||
do (ws, ml') <- modifyLayout m l r s
|
do (ws, ml') <- modifyLayout m (Workspace i l ms) r
|
||||||
(ws', mm') <- redoLayout m r s ws
|
(ws', mm') <- case ms of
|
||||||
let ml'' = case mm' of
|
Just s -> redoLayout m r s ws
|
||||||
Just m' -> Just $ (ModifiedLayout m') $ maybe l id ml'
|
Nothing -> emptyLayoutMod m r ws
|
||||||
Nothing -> ModifiedLayout m `fmap` ml'
|
|
||||||
return (ws', ml'')
|
|
||||||
emptyLayout (ModifiedLayout m l) r =
|
|
||||||
do (ws, ml') <- emptyLayout l r
|
|
||||||
(ws',mm') <- emptyLayoutMod m r ws
|
|
||||||
let ml'' = case mm' of
|
let ml'' = case mm' of
|
||||||
Just m' -> Just $ (ModifiedLayout m') $ maybe l id ml'
|
Just m' -> Just $ (ModifiedLayout m') $ maybe l id ml'
|
||||||
Nothing -> ModifiedLayout m `fmap` ml'
|
Nothing -> ModifiedLayout m `fmap` ml'
|
||||||
return (ws', ml'')
|
return (ws', ml'')
|
||||||
|
|
||||||
handleMessage (ModifiedLayout m l) mess =
|
handleMessage (ModifiedLayout m l) mess =
|
||||||
do mm' <- handleMessOrMaybeModifyIt m mess
|
do mm' <- handleMessOrMaybeModifyIt m mess
|
||||||
ml' <- case mm' of
|
ml' <- case mm' of
|
||||||
|
@ -63,14 +63,14 @@ data ResizeScreen a = ResizeScreen ResizeMode Int
|
|||||||
data ResizeMode = T | B | L | R deriving (Read, Show)
|
data ResizeMode = T | B | L | R deriving (Read, Show)
|
||||||
|
|
||||||
instance LayoutModifier ResizeScreen a where
|
instance LayoutModifier ResizeScreen a where
|
||||||
modifyLayout m l rect@(Rectangle x y w h) s
|
modifyLayout m ws rect@(Rectangle x y w h)
|
||||||
| ResizeScreen L i <- m = resize $ Rectangle (x + fi i) y (w - fi i) h
|
| ResizeScreen L i <- m = resize $ Rectangle (x + fi i) y (w - fi i) h
|
||||||
| ResizeScreen R i <- m = resize $ Rectangle x y (w - fi i) h
|
| ResizeScreen R i <- m = resize $ Rectangle x y (w - fi i) h
|
||||||
| ResizeScreen T i <- m = resize $ Rectangle x (y + fi i) w (h - fi i)
|
| ResizeScreen T i <- m = resize $ Rectangle x (y + fi i) w (h - fi i)
|
||||||
| ResizeScreen B i <- m = resize $ Rectangle x y w (h - fi i)
|
| ResizeScreen B i <- m = resize $ Rectangle x y w (h - fi i)
|
||||||
| WithNewScreen r <- m = resize r
|
| WithNewScreen r <- m = resize r
|
||||||
| otherwise = resize rect
|
| otherwise = resize rect
|
||||||
where resize nr = doLayout l nr s
|
where resize nr = runLayout ws nr
|
||||||
|
|
||||||
pureMess (ResizeScreen d _) m
|
pureMess (ResizeScreen d _) m
|
||||||
| Just (SetTheme t) <- fromMessage m = Just $ ResizeScreen d (fi $ decoHeight t)
|
| Just (SetTheme t) <- fromMessage m = Just $ ResizeScreen d (fi $ decoHeight t)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user