From 0f0a99e3559a97889b0422f4dd9f0bedc5acaeb9 Mon Sep 17 00:00:00 2001 From: Andrea Rossato Date: Sun, 27 Jan 2008 14:02:19 +0000 Subject: [PATCH] LayoutModifier add a modifyLayout Many layouts are written as layout modifiers because they need to change the stack of the rectangle before executing doLayout. This is a major source of bugs. all layout modifiers should be using the LayoutModifier class. This method (modifyLayout) can be used to manipulate the rectangle and the stack before running doLayout by the layout modifier. --- XMonad/Layout/LayoutModifier.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/XMonad/Layout/LayoutModifier.hs b/XMonad/Layout/LayoutModifier.hs index 933b4e7a..46cabd69 100644 --- a/XMonad/Layout/LayoutModifier.hs +++ b/XMonad/Layout/LayoutModifier.hs @@ -33,6 +33,9 @@ import XMonad.StackSet ( Stack ) -- "XMonad.Layout.Magnifier", "XMonad.Layout.NoBorder", class (Show (m a), Read (m a)) => LayoutModifier m a where + modifyLayout :: (LayoutClass l a) => m a -> l a -> Rectangle + -> Stack a -> X ([(a, Rectangle)], Maybe (l a)) + modifyLayout _ l r s = doLayout l r s handleMess :: m a -> SomeMessage -> X (Maybe (m a)) handleMess m mess | Just Hide <- fromMessage mess = doUnhook | Just ReleaseResources <- fromMessage mess = doUnhook @@ -61,7 +64,7 @@ class (Show (m a), Read (m a)) => LayoutModifier m a where instance (LayoutModifier m a, LayoutClass l a) => LayoutClass (ModifiedLayout m l) a where doLayout (ModifiedLayout m l) r s = - do (ws, ml') <- doLayout l r s + do (ws, ml') <- modifyLayout m l r s (ws', mm') <- redoLayout m r s ws let ml'' = case mm' of Just m' -> Just $ (ModifiedLayout m') $ maybe l id ml'