diff options
| author | Josh Rahm <joshuarahm@gmail.com> | 2021-11-02 23:49:25 -0600 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2022-10-09 12:19:45 -0600 |
| commit | a517023d22958022cc9fb0a303b26df660da9aa8 (patch) | |
| tree | 1ad7987eed067511f69a838767d2fabb686b3e29 /src/Internal/Layout.hs | |
| parent | 6f831fdf58715087a609d4743cbcdd1ed5bb52cc (diff) | |
| download | rde-a517023d22958022cc9fb0a303b26df660da9aa8.tar.gz rde-a517023d22958022cc9fb0a303b26df660da9aa8.tar.bz2 rde-a517023d22958022cc9fb0a303b26df660da9aa8.zip | |
Add ability to flip the layout with mod-f.
Diffstat (limited to 'src/Internal/Layout.hs')
| -rw-r--r-- | src/Internal/Layout.hs | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/src/Internal/Layout.hs b/src/Internal/Layout.hs index 2339cca..aa3df1a 100644 --- a/src/Internal/Layout.hs +++ b/src/Internal/Layout.hs @@ -1,6 +1,7 @@ {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-} module Internal.Layout where +import Control.Arrow (second) import XMonad.Hooks.ManageDocks import XMonad.Layout.Circle import XMonad.Layout.Accordion @@ -20,26 +21,54 @@ import qualified XMonad.StackSet as W myLayout = ModifiedLayout (Zoomable False 0.05 0.05) $ - spacingRaw True (Border 5 5 5 5) True (Border 5 5 5 5) True $ avoidStruts $ - spiral (6/7) ||| - Tall 1 (3/100) (1/2) ||| - ThreeCol 1 (3/100) (1/2) ||| - Full ||| - Grid ||| - Dishes 2 (1/6) + ModifiedLayout (Flippable False) $ + spacingRaw True (Border 5 5 5 5) True (Border 5 5 5 5) True $ avoidStruts $ + spiral (6/7) ||| + Tall 1 (3/100) (1/2) ||| + ThreeCol 1 (3/100) (1/2) ||| + Full ||| + Grid ||| + Dishes 2 (1/6) data ResizeZoom = ShrinkZoom | ExpandZoom deriving (Typeable) instance Message ResizeZoom where +data Flippable a = Flippable Bool -- True if flipped + deriving (Show, Read) + +data FlipLayout = FlipLayout deriving (Typeable) + data Zoomable a = Zoomable Bool Float Float -- True if zooming in on the focused window. deriving (Show, Read) data ToggleZoom = ToggleZoom deriving (Typeable) +instance Message FlipLayout where + instance Message ToggleZoom where +instance (Eq a) => LayoutModifier Flippable a where + pureModifier (Flippable flip) (Rectangle _ _ sw _) stack returned = + if flip + then (map (second doFlip) returned, Nothing) + else (returned, Nothing) + where + doFlip (Rectangle x y w h) = Rectangle (fromIntegral sw - x - fromIntegral w) y w h + + pureMess (Flippable flip) message = + case fromMessage message of + Just FlipLayout -> Just (Flippable (not flip)) + Nothing -> Nothing + + modifyDescription (Flippable flipped) underlying = + let descr = description underlying in + if flipped + then descr ++ " Flipped" + else descr + + instance (Eq a) => LayoutModifier Zoomable a where redoLayout (Zoomable doit ws hs) (Rectangle x y w h) stack returned = if doit |