From 9e88d56b03ceaf63709cbbc7bda3f20c9a1a3320 Mon Sep 17 00:00:00 2001 From: Spencer Janssen Date: Thu, 1 Nov 2007 09:21:55 +0100 Subject: Add readsLayout, remove the existential from XConfig darcs-hash:20071101082155-a5988-82be25ec6b35cb1d39e0613b3d810dfd75836098 --- XMonad.hs | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'XMonad.hs') diff --git a/XMonad.hs b/XMonad.hs index 6fcf6c1..7428c2f 100644 --- a/XMonad.hs +++ b/XMonad.hs @@ -16,8 +16,7 @@ ----------------------------------------------------------------------------- module XMonad ( - X, WindowSet, WindowSpace, WorkspaceId, ScreenId(..), ScreenDetail(..), XState(..), XConf(..), XConfig(..), LayoutClass(..), Layout(..), - Typeable, Message, SomeMessage(..), fromMessage, runLayout, LayoutMessages(..), + X, WindowSet, WindowSpace, WorkspaceId, ScreenId(..), ScreenDetail(..), XState(..), XConf(..), XConfig(..), LayoutClass(..), Layout(..), readsLayout, Typeable, Message, SomeMessage(..), fromMessage, runLayout, LayoutMessages(..), runX, catchX, userCode, io, catchIO, withDisplay, withWindowSet, isRoot, getAtom, spawn, restart, trace, whenJust, whenX, atom_WM_STATE, atom_WM_PROTOCOLS, atom_WM_DELETE_WINDOW ) where @@ -55,20 +54,18 @@ data XConf = XConf , focusedBorder :: !Pixel } -- ^ border color of the focused window -- todo, better name -data XConfig = forall l. (LayoutClass l Window, Read (l Window)) => - XConfig { normalBorderColor :: !String - , focusedBorderColor :: !String - , terminal :: !String - , layoutHook :: !(l Window) - , manageHook :: Window -> String -> String -> String -> X (WindowSet -> WindowSet) - , workspaces :: ![String] - , defaultGaps :: ![(Int,Int,Int,Int)] - , numlockMask :: KeyMask - , keys :: !(M.Map (ButtonMask,KeySym) (X ())) - , mouseBindings :: !(M.Map (ButtonMask, Button) (Window -> X ())) - , borderWidth :: !Dimension - , logHook :: !(X ()) - } +data XConfig = XConfig { normalBorderColor :: !String + , focusedBorderColor :: !String + , terminal :: !String + , layoutHook :: !(Layout Window) + , manageHook :: !(Window -> String -> String -> String -> X (WindowSet -> WindowSet)) + , workspaces :: ![String] + , defaultGaps :: ![(Int,Int,Int,Int)] + , numlockMask :: KeyMask + , keys :: !(M.Map (ButtonMask,KeySym) (X ())) + , mouseBindings :: !(M.Map (ButtonMask, Button) (Window -> X ())) + , borderWidth :: !Dimension + , logHook :: !(X ()) } type WindowSet = StackSet WorkspaceId (Layout Window) Window ScreenId ScreenDetail type WindowSpace = Workspace WorkspaceId (Layout Window) Window @@ -147,9 +144,13 @@ atom_WM_STATE = getAtom "WM_STATE" ------------------------------------------------------------------------ -- | LayoutClass handling. See particular instances in Operations.hs --- | An existential type that can hold any object that is in the LayoutClass. -data Layout a = forall l. (LayoutClass l a) => Layout (l a) +-- | An existential type that can hold any object that is in Read and LayoutClass. +data Layout a = forall l. (LayoutClass l a, Read (l a)) => Layout (l a) +-- | Using the 'Layout' as a witness, parse existentially wrapped windows +-- from a 'String' +readsLayout :: Layout a -> String -> [(Layout a, String)] +readsLayout (Layout l) s = [(Layout (asTypeOf x l), rs) | (x, rs) <- reads s] -- | The different layout modes -- -- cgit v1.2.3