diff options
author | David Roundy <droundy@darcs.net> | 2007-10-26 23:06:43 +0200 |
---|---|---|
committer | David Roundy <droundy@darcs.net> | 2007-10-26 23:06:43 +0200 |
commit | 6ea2b579cf1efa261ab728ce1139f908a9dc7f8d (patch) | |
tree | f61b6440faf45743519ef138779a5cd64ca795a1 | |
parent | 852e3088e05236bd94cb4e3ec15dfffba4b91f62 (diff) | |
download | XMonadContrib-6ea2b579cf1efa261ab728ce1139f908a9dc7f8d.tar.gz XMonadContrib-6ea2b579cf1efa261ab728ce1139f908a9dc7f8d.tar.xz XMonadContrib-6ea2b579cf1efa261ab728ce1139f908a9dc7f8d.zip |
allow use of multiple toggles in ToggleLayouts.
darcs-hash:20071026210643-72aca-459a76755ceaf8406a7add95f77f4d33f533d6eb.gz
-rw-r--r-- | ToggleLayouts.hs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/ToggleLayouts.hs b/ToggleLayouts.hs index 5f76380..a48ff15 100644 --- a/ToggleLayouts.hs +++ b/ToggleLayouts.hs @@ -25,13 +25,21 @@ import Operations ( LayoutMessages(Hide, ReleaseResources) ) -- $usage -- Use toggleLayouts to toggle between two layouts. --- import XMonadContrib.ToggleLayouts, and add to your layoutHook something like +-- +-- import XMonadContrib.ToggleLayouts +-- +-- and add to your layoutHook something like +-- -- > layoutHook = Layout $ toggleLayouts (noBorders Full) $ Select layouts +-- -- and a key binding like -- > , ((modMask .|. controlMask, xK_space), sendMessage ToggleLayout) +-- +-- or a key binding like +-- > , ((modMask .|. controlMask, xK_space), sendMessage (Toggle "Full")) data ToggleLayouts lt lf a = ToggleLayouts Bool (lt a) (lf a) deriving (Read,Show) -data ToggleLayout = ToggleLayout deriving (Read,Show,Typeable) +data ToggleLayout = ToggleLayout | Toggle String deriving (Read,Show,Typeable) instance Message ToggleLayout toggleLayouts :: (LayoutClass lt a, LayoutClass lf a) => lt a -> lf a -> ToggleLayouts lt lf a @@ -57,11 +65,21 @@ instance (LayoutClass lt a, LayoutClass lf a) => LayoutClass (ToggleLayouts lt l | Just ToggleLayout <- fromMessage m = do mlt' <- handleMessage lt (SomeMessage Hide) let lt' = maybe lt id mlt' return $ Just $ ToggleLayouts False lt' lf + | Just (Toggle d) <- fromMessage m, + d == description lt || d == description lf = + do mlt' <- handleMessage lt (SomeMessage Hide) + let lt' = maybe lt id mlt' + return $ Just $ ToggleLayouts False lt' lf | otherwise = do mlt' <- handleMessage lt m return $ fmap (\lt' -> ToggleLayouts True lt' lf) mlt' handleMessage (ToggleLayouts False lt lf) m | Just ToggleLayout <- fromMessage m = do mlf' <- handleMessage lf (SomeMessage Hide) let lf' = maybe lf id mlf' return $ Just $ ToggleLayouts True lt lf' + | Just (Toggle d), + d == description lt || d == description lf <- fromMessage m = + do mlf' <- handleMessage lf (SomeMessage Hide) + let lf' = maybe lf id mlf' + return $ Just $ ToggleLayouts True lt lf' | otherwise = do mlf' <- handleMessage lf m return $ fmap (\lf' -> ToggleLayouts False lt lf') mlf' |