summaryrefslogtreecommitdiffstats
path: root/XMonad.hs
diff options
context:
space:
mode:
authorDavid Roundy <droundy@darcs.net>2007-09-14 23:59:59 +0200
committerDavid Roundy <droundy@darcs.net>2007-09-14 23:59:59 +0200
commit6ba134c9e54d42c189d60a924c27921739b7c197 (patch)
tree36a2db2018d52bf48ec4b3649f3bc1b5e15f772f /XMonad.hs
parenta576ec8b32e15da3068518c867c92f208cdac293 (diff)
downloadmetatile-6ba134c9e54d42c189d60a924c27921739b7c197.tar
metatile-6ba134c9e54d42c189d60a924c27921739b7c197.zip
move Layout stuff into class (hokey first cut).
darcs-hash:20070914215959-72aca-3feae03a6560a70908ad37d28f47c8d47321008e
Diffstat (limited to 'XMonad.hs')
-rw-r--r--XMonad.hs27
1 files changed, 22 insertions, 5 deletions
diff --git a/XMonad.hs b/XMonad.hs
index 64232f6..97f4ee1 100644
--- a/XMonad.hs
+++ b/XMonad.hs
@@ -15,7 +15,7 @@
-----------------------------------------------------------------------------
module XMonad (
- X, WindowSet, WorkspaceId, ScreenId(..), ScreenDetail(..), XState(..), XConf(..), Layout(..),
+ X, WindowSet, WorkspaceId, ScreenId(..), ScreenDetail(..), XState(..), XConf(..), Layout(..), OldLayout(..), SomeLayout(..),
Typeable, Message, SomeMessage(..), fromMessage, runLayout,
runX, catchX, io, catchIO, withDisplay, withWindowSet, isRoot, getAtom, spawn, restart, trace, whenJust, whenX,
atom_WM_STATE, atom_WM_PROTOCOLS, atom_WM_DELETE_WINDOW
@@ -43,7 +43,7 @@ data XState = XState
{ windowset :: !WindowSet -- ^ workspace list
, mapped :: !(S.Set Window) -- ^ the Set of mapped windows
, waitingUnmap :: !(M.Map Window Int) -- ^ the number of expected UnmapEvents
- , layouts :: !(M.Map WorkspaceId (Layout Window, [Layout Window]))
+ , layouts :: !(M.Map WorkspaceId (SomeLayout Window, [SomeLayout Window]))
-- ^ mapping of workspaces to descriptions of their layouts
, dragging :: !(Maybe (Position -> Position -> X (), X ())) }
data XConf = XConf
@@ -131,10 +131,27 @@ atom_WM_STATE = getAtom "WM_STATE"
-- that message and the screen is not refreshed. Otherwise, 'modifyLayout'
-- returns an updated 'Layout' and the screen is refreshed.
--
-data Layout a = Layout { doLayout :: Rectangle -> Stack a -> X ([(a, Rectangle)], Maybe (Layout a))
- , modifyLayout :: SomeMessage -> X (Maybe (Layout a)) }
+data OldLayout a =
+ OldLayout { doLayout' :: Rectangle -> Stack a -> X ([(a, Rectangle)], Maybe (OldLayout a))
+ , modifyLayout' :: SomeMessage -> X (Maybe (OldLayout a)) }
-runLayout :: Layout a -> Rectangle -> StackOrNot a -> X ([(a, Rectangle)], Maybe (Layout a))
+data SomeLayout a = forall l. Layout l a => SomeLayout (l a)
+
+class Layout layout a where
+ doLayout :: layout a -> Rectangle -> Stack a -> X ([(a, Rectangle)], Maybe (layout a))
+ modifyLayout :: layout a -> SomeMessage -> X (Maybe (layout a))
+
+instance Layout OldLayout a where
+ doLayout = doLayout'
+ modifyLayout = modifyLayout'
+
+instance Layout SomeLayout a where
+ doLayout (SomeLayout l) r s = do (ars, ml') <- doLayout l r s
+ return (ars, SomeLayout `fmap` ml' )
+ modifyLayout (SomeLayout l) m = do ml' <- modifyLayout l m
+ return (SomeLayout `fmap` ml')
+
+runLayout :: Layout l a => l a -> Rectangle -> StackOrNot a -> X ([(a, Rectangle)], Maybe (l a))
runLayout l r = maybe (return ([], Nothing)) (doLayout l r)
-- | Based on ideas in /An Extensible Dynamically-Typed Hierarchy of Exceptions/,