vanadium/xmonad: use event handling to set master pane count

This commit is contained in:
Primrose 2026-01-06 22:22:57 +01:00
parent e65e37d3a9
commit 084261c58e
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA
3 changed files with 64 additions and 21 deletions

View file

@ -0,0 +1,30 @@
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
-- Wraps ResizableTall, allows setting master count to a number directly
module XMonad.Layout.SetMasterNTall
( SetMasterNTall(..)
, SetMasterN(..)
) where
import XMonad
import qualified XMonad.StackSet as W
import XMonad.Layout.ResizableTile
-- Message
data SetMasterN = SetMasterN Int
instance Message SetMasterN
-- Layout
newtype SetMasterNTall a = SetMasterNTall { unSetMasterNTall :: ResizableTall a }
deriving (Read, Show)
instance LayoutClass SetMasterNTall a where
runLayout (W.Workspace t l s) =
let ws' = W.Workspace t (unSetMasterNTall l) s
in (fmap . fmap . fmap) SetMasterNTall . runLayout ws'
handleMessage (SetMasterNTall l@(ResizableTall _n0 d f s)) mess
| Just (SetMasterN n) <- fromMessage mess = pure $ Just $ SetMasterNTall $ ResizableTall n d f s
| otherwise = (fmap . fmap) SetMasterNTall . handleMessage l $ mess
description (SetMasterNTall l) = description l