summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Roundy <droundy@darcs.net>2007-09-20 20:15:06 +0200
committerDavid Roundy <droundy@darcs.net>2007-09-20 20:15:06 +0200
commit71a7d6bd1426c61e5ecb3556b2d6d10bea488128 (patch)
tree8f6bf5d931b4a199af536227f11ded06cec022f0
parent6de39ed25a10ecc4a9fa2a933cd214296228e57c (diff)
downloadmetatile-71a7d6bd1426c61e5ecb3556b2d6d10bea488128.tar
metatile-71a7d6bd1426c61e5ecb3556b2d6d10bea488128.zip
define readLayout to create a SomeLayout based on a set of possible layout types.
darcs-hash:20070920181506-72aca-3c50146a45158f168b89c989897c616fc453f816
-rw-r--r--XMonad.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/XMonad.hs b/XMonad.hs
index a9253c9..e611c31 100644
--- a/XMonad.hs
+++ b/XMonad.hs
@@ -15,7 +15,7 @@
-----------------------------------------------------------------------------
module XMonad (
- X, WindowSet, WorkspaceId, ScreenId(..), ScreenDetail(..), XState(..), XConf(..), Layout(..), SomeLayout(..),
+ X, WindowSet, WorkspaceId, ScreenId(..), ScreenDetail(..), XState(..), XConf(..), Layout(..), SomeLayout(..), readLayout,
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
@@ -137,6 +137,12 @@ instance Show (SomeLayout a) where
instance Read (SomeLayout a) where
readsPrec _ _ = [] -- We can't read an existential type!!!
+readLayout :: [SomeLayout a] -> String -> [(SomeLayout a, String)]
+readLayout ls s = concatMap rl ls
+ where rl (SomeLayout x) = map (\(l,s') -> (SomeLayout l,s')) $ rl' x
+ rl' :: Layout l a => l a -> [(l a,String)]
+ rl' _ = reads s
+
class (Show (layout a), Read (layout a)) => Layout layout a where
doLayout :: layout a -> Rectangle -> Stack a -> X ([(a, Rectangle)], Maybe (layout a))
modifyLayout :: layout a -> SomeMessage -> X (Maybe (layout a))