diff options
| author | Josh Rahm <rahm@google.com> | 2022-11-21 12:05:03 -0700 |
|---|---|---|
| committer | Josh Rahm <rahm@google.com> | 2022-11-21 12:05:03 -0700 |
| commit | ee9be16599f20aef6d1d3fd15666c00452f85aba (patch) | |
| tree | 1aed66c1de2ce201463e3becc2d452d4a8aa2992 /src/Rahm/Desktop/Layout/Pop.hs | |
| parent | a1636c65e05d02f7d4fc408137e1d37b412ce890 (diff) | |
| download | rde-ee9be16599f20aef6d1d3fd15666c00452f85aba.tar.gz rde-ee9be16599f20aef6d1d3fd15666c00452f85aba.tar.bz2 rde-ee9be16599f20aef6d1d3fd15666c00452f85aba.zip | |
Format with ormolu.
Diffstat (limited to 'src/Rahm/Desktop/Layout/Pop.hs')
| -rw-r--r-- | src/Rahm/Desktop/Layout/Pop.hs | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/src/Rahm/Desktop/Layout/Pop.hs b/src/Rahm/Desktop/Layout/Pop.hs index a7e2762..b518ee8 100644 --- a/src/Rahm/Desktop/Layout/Pop.hs +++ b/src/Rahm/Desktop/Layout/Pop.hs @@ -4,33 +4,32 @@ -- frame in the middle of the screen, sort of like fullscreen, but only taking -- up a percentage of the screen rather than the whole screen so other windows -- are still visible, alebeit typically not usable. -module Rahm.Desktop.Layout.Pop ( - Poppable(..), - PopMessage(..), - poppable, - resizePop, - togglePop, - setPop) where - -import XMonad -import XMonad.Layout.LayoutModifier (LayoutModifier(..), ModifiedLayout(..)) -import Data.Default (Default(..)) -import qualified Rahm.Desktop.StackSet as W - +module Rahm.Desktop.Layout.Pop + ( Poppable (..), + PopMessage (..), + poppable, + resizePop, + togglePop, + setPop, + ) +where + +import Data.Default (Default (..)) import Rahm.Desktop.Layout.ReinterpretMessage +import qualified Rahm.Desktop.StackSet as W +import XMonad +import XMonad.Layout.LayoutModifier (LayoutModifier (..), ModifiedLayout (..)) -data Poppable (l :: * -> *) (a :: *) = Poppable { - -- True if the current window is popped out or not. - isPopped :: Bool - +data Poppable (l :: * -> *) (a :: *) = Poppable + { -- True if the current window is popped out or not. + isPopped :: Bool, -- Fraction of the screen width around the window. - , xFrac :: Float - + xFrac :: Float, -- Fraction of the screen height around the window. - , yFrac :: Float - - , wrap :: l a - } deriving (Show, Read, Eq, Ord) + yFrac :: Float, + wrap :: l a + } + deriving (Show, Read, Eq, Ord) data PopMessage where PopMessage :: (forall l a. Poppable l a -> Poppable l a) -> PopMessage @@ -52,27 +51,30 @@ poppable :: l a -> Poppable l a poppable = Poppable False 0.05 0.05 instance (LayoutClass l a, Eq a) => LayoutClass (Poppable l) a where - -- If the current layout is not popped, then just return what the underlying -- layout returned. - runLayout (W.Workspace - t - (Poppable True xs ys l) - a@(Just (W.focus -> focused))) - rect@(Rectangle x y w h) = do - (returned, maybeNewLayout) <- runLayout (W.Workspace t l a) rect - return - ((focused, newRect) : filter ((/=focused) . fst) returned, - Poppable True xs ys <$> maybeNewLayout) - where - wp = floor $ fromIntegral w * xs - hp = floor $ fromIntegral h * ys - newRect = Rectangle - (x + wp) - (y + hp) - (w - fromIntegral (wp * 2)) - (h - fromIntegral (hp * 2)) + runLayout + ( W.Workspace + t + (Poppable True xs ys l) + a@(Just (W.focus -> focused)) + ) + rect@(Rectangle x y w h) = do + (returned, maybeNewLayout) <- runLayout (W.Workspace t l a) rect + return + ( (focused, newRect) : filter ((/= focused) . fst) returned, + Poppable True xs ys <$> maybeNewLayout + ) + where + wp = floor $ fromIntegral w * xs + hp = floor $ fromIntegral h * ys + newRect = + Rectangle + (x + wp) + (y + hp) + (w - fromIntegral (wp * 2)) + (h - fromIntegral (hp * 2)) -- If the pop is not active, just delegate to the underlying layout. runLayout (W.Workspace t (Poppable b x y l) a) rect = do @@ -82,14 +84,12 @@ instance (LayoutClass l a, Eq a) => LayoutClass (Poppable l) a where -- If the message is a PopMessage, handle that here. handleMessage p (fromMessage -> Just (PopMessage f)) = return $ Just $ f p - -- Intercept Shrink/Expand message if the pop is active, and resize the -- pop size. handleMessage p (fromMessage -> Just mess) | isPopped p = case mess of Shrink -> handleMessage p (SomeMessage $ resizePop 0.025) Expand -> handleMessage p (SomeMessage $ resizePop (-0.025)) - -- By default just pass the message to the underlying layout. handleMessage (Poppable b x y l) mess = do maybeNewLayout <- handleMessage l mess |