Center main window on thicc ultrawide

This commit is contained in:
elkowar 2020-12-25 17:48:15 +01:00
parent f9677f940e
commit f983d4d559
2 changed files with 68 additions and 25 deletions

View file

@ -99,6 +99,8 @@ import qualified Data.Bifunctor
import Data.Bifunctor import Data.Bifunctor
import GHC.IO.Unsafe (unsafePerformIO) import GHC.IO.Unsafe (unsafePerformIO)
import qualified Data.List.NonEmpty import qualified Data.List.NonEmpty
import Control.Monad (msum)
import XMonad.Layout.LayoutModifier
{-# ANN module "HLint: ignore Redundant $" #-} {-# ANN module "HLint: ignore Redundant $" #-}
{-# ANN module "HLint: ignore Redundant bracket" #-} {-# ANN module "HLint: ignore Redundant bracket" #-}
{-# ANN module "HLint: ignore Move brackets to avoid $" #-} {-# ANN module "HLint: ignore Move brackets to avoid $" #-}
@ -163,43 +165,50 @@ instance Shrinker EmptyShrinker where
shrinkIt _ _ = [] :: [String] shrinkIt _ _ = [] :: [String]
myLayout = noBorders $ avoidStruts myLayout = noBorders
$ smartBorders . avoidStruts
-- $ FancyBorders.fancyBorders borderTheme . smartBorders
$ MTog.mkToggle1 MTog.FULL . MTog.mkToggle1 MTog.FULL
$ ToggleLayouts.toggleLayouts (rename "Tabbed" . makeTabbed . spacingAndGaps $ ResizableTall 1 (3/100) (1/2) []) . ToggleLayouts.toggleLayouts tabbedTall
$ MTog.mkToggle1 WINDOWDECORATION . MTog.mkToggle1 WINDOWDECORATION
$ draggingVisualizer . draggingVisualizer
$ layoutHintsToCenter . layoutHintsToCenter
$ layouts $ layouts
where where
-- | if the screen is wider than 1900px it's horizontal, so use horizontal layouts. -- | if the screen is wider than 1900px it's horizontal, so use horizontal layouts.
-- if it's not, it's vertical, so use layouts for vertical screens. -- if it's not, it's vertical, so use layouts for vertical screens.
layouts = PerScreen.ifWider 1900 horizScreenLayouts vertScreenLayouts layouts = PerScreen.ifWider 1900 (PerScreen.ifWider 3000 chonkyScreenLayouts horizScreenLayouts) vertScreenLayouts
horizScreenLayouts = chonkyScreenLayouts = (rn "UltraTall" $ withGaps $ centeredIfSingle 0.6 resizableThreeCol) ||| horizScreenLayouts
(rename "Tall" $ spacingAndGaps $ mouseResizableTile {draggerType = BordersDragger})
||| (rename "Horizon" $ spacingAndGaps $ mouseResizableTileMirrored {draggerType = BordersDragger}) horizScreenLayouts =
||| (rename "BSP" $ spacingAndGaps $ borderResize $ emptyBSP) (rn "Tall" $ withGaps $ mouseResizableTile {draggerType = BordersDragger})
||| (rename "ThreeCol" $ makeTabbed $ spacingAndGaps $ ResizableThreeColMid 1 (3/100) (1/2) []) ||| (rn "Horizon" $ withGaps $ mouseResizableTileMirrored {draggerType = BordersDragger})
||| (rename "TabbedRow" $ makeTabbed $ spacingAndGaps $ zoomRow) ||| (rn "BSP" $ withGaps $ borderResize $ emptyBSP)
||| (rn "ThreeCol" $ mkTabbed $ withGaps $ resizableThreeCol)
||| (rn "TabbedRow" $ mkTabbed $ withGaps $ zoomRow)
vertScreenLayouts = vertScreenLayouts =
((rename "ThreeCol" $ makeTabbed $ spacingAndGaps $ Mirror $ reflectHoriz $ ThreeColMid 1 (3/100) (1/2)) ((rn "ThreeCol" $ mkTabbed $ withGaps $ Mirror $ reflectHoriz $ ThreeColMid 1 (3/100) (1/2))
||| (rename "Horizon" $ spacingAndGaps $ mouseResizableTileMirrored {draggerType = BordersDragger})) ||| (rn "Horizon" $ withGaps $ mouseResizableTileMirrored {draggerType = BordersDragger}))
-- | Simple tall layout with tab support
tabbedTall = rn "Tabbed" . mkTabbed . withGaps $ ResizableTall 1 (3/100) (1/2) []
-- | Specific instance of ResizableThreeCol
resizableThreeCol = ResizableThreeColMid 1 (3/100) (1/2) []
borderTheme = FancyBorders.FancyBordersTheme { FancyBorders.outerColor = "#282828" rn n = renamed [Replace n]
, FancyBorders.intBorderWidth = 2
}
rename n = renamed [Replace n] withGaps = spacingRaw False border True border True
spacingAndGaps = let gap = 15 -- gap = 20 where gap = 15
border = Border gap gap gap gap border = Border gap gap gap gap
in spacingRaw False border True border True
-- | transform a layout into supporting tabs -- | transform a layout into supporting tabs
makeTabbed layout = BoringWindows.boringWindows . windowNavigation . addTabs shrinkText myTabTheme $ subLayout [] Simplest $ layout mkTabbed layout = BoringWindows.boringWindows . windowNavigation . addTabs shrinkText myTabTheme $ subLayout [] Simplest $ layout
-- LayoutModifier and layout definitions ---------- {{{
-- | window decoration layout modifier. this needs you to add `dragginVisualizer` yourself -- | window decoration layout modifier. this needs you to add `dragginVisualizer` yourself
data WINDOWDECORATION = WINDOWDECORATION deriving (Read, Show, Eq, Typeable) data WINDOWDECORATION = WINDOWDECORATION deriving (Read, Show, Eq, Typeable)
@ -209,6 +218,39 @@ instance MTog.Transformer WINDOWDECORATION Window where
(const x) (const x)
-- | Layout modifier that tells layouts to only use a percentage of the screen, leaving space on the sides.
newtype Smaller a = Smaller Double
deriving (Show, Read)
instance LayoutModifier Smaller a where
modifyLayout (Smaller ratio) workspace rect = runLayout workspace (rectangleCenterPiece ratio rect)
-- | Layout Modifier that places a window in the center of the screen,
-- leaving room on the left and right, if there is only a single window
newtype CenteredIfSingle a = CenteredIfSingle Double deriving (Show, Read)
instance LayoutModifier CenteredIfSingle Window where
pureModifier (CenteredIfSingle ratio) r _ [(onlyWindow, _)] = ([(onlyWindow, rectangleCenterPiece ratio r)], Nothing)
pureModifier _ _ _ winRects = (winRects, Nothing)
-- | Layout Modifier that places a window in the center of the screen,
-- leaving room on the left and right, if there is only a single window
centeredIfSingle :: Double -> l a -> ModifiedLayout CenteredIfSingle l a
centeredIfSingle ratio = ModifiedLayout (CenteredIfSingle ratio)
-- | Give the center piece of a rectangle by taking the given percentage
-- of the rectangle and taking that in the middle.
rectangleCenterPiece :: Double -> Rectangle -> Rectangle
rectangleCenterPiece ratio (Rectangle rx ry rw rh) = Rectangle start ry width rh
where
sides = floor $ ((fi rw) * (1.0 - ratio)) / 2
start = (fi rx) + sides
width = fi $ (fi rw) - (sides * 2)
fi :: (Integral a, Num b) => a -> b
fi = fromIntegral
-- }}}
-- }}} -- }}}

View file

@ -24,6 +24,7 @@ in
discord discord
pinta pinta
espanso espanso
barrier
#hyper-haskell #hyper-haskell
]; ];