mirror of
https://github.com/xmonad/xmonad.git
synced 2025-08-01 20:51:55 -07:00
define readLayout to create a SomeLayout based on a set of possible layout types.
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
module XMonad (
|
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,
|
Typeable, Message, SomeMessage(..), fromMessage, runLayout,
|
||||||
runX, catchX, io, catchIO, withDisplay, withWindowSet, isRoot, getAtom, spawn, restart, trace, whenJust, whenX,
|
runX, catchX, io, catchIO, withDisplay, withWindowSet, isRoot, getAtom, spawn, restart, trace, whenJust, whenX,
|
||||||
atom_WM_STATE, atom_WM_PROTOCOLS, atom_WM_DELETE_WINDOW
|
atom_WM_STATE, atom_WM_PROTOCOLS, atom_WM_DELETE_WINDOW
|
||||||
@@ -137,6 +137,12 @@ instance Show (SomeLayout a) where
|
|||||||
instance Read (SomeLayout a) where
|
instance Read (SomeLayout a) where
|
||||||
readsPrec _ _ = [] -- We can't read an existential type!!!
|
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
|
class (Show (layout a), Read (layout a)) => Layout layout a where
|
||||||
doLayout :: layout a -> Rectangle -> Stack a -> X ([(a, Rectangle)], Maybe (layout a))
|
doLayout :: layout a -> Rectangle -> Stack a -> X ([(a, Rectangle)], Maybe (layout a))
|
||||||
modifyLayout :: layout a -> SomeMessage -> X (Maybe (layout a))
|
modifyLayout :: layout a -> SomeMessage -> X (Maybe (layout a))
|
||||||
|
Reference in New Issue
Block a user