xmonad-0.6: A tiling window managerSource codeContentsIndex
XMonad.Core
Portabilitynot portable, uses cunning newtype deriving
Stabilityunstable
Maintainersjanssen@cse.unl.edu
Description
The X monad, a state monad transformer over IO, for the window manager state, and support routines.
Synopsis
data X a
type WindowSet = StackSet WorkspaceId (Layout Window) Window ScreenId ScreenDetail
type WindowSpace = Workspace WorkspaceId (Layout Window) Window
type WorkspaceId = String
newtype ScreenId = S Int
data ScreenDetail = SD {
screenRect :: !Rectangle
statusGap :: !(Int, Int, Int, Int)
}
data XState = XState {
windowset :: !WindowSet
mapped :: !(Set Window)
waitingUnmap :: !(Map Window Int)
dragging :: !(Maybe (Position -> Position -> X (), X ()))
}
data XConf = XConf {
display :: Display
config :: !(XConfig Layout)
theRoot :: !Window
normalBorder :: !Pixel
focusedBorder :: !Pixel
keyActions :: !(Map (KeyMask, KeySym) (X ()))
buttonActions :: !(Map (KeyMask, Button) (Window -> X ()))
}
data XConfig l = XConfig {
normalBorderColor :: !String
focusedBorderColor :: !String
terminal :: !String
layoutHook :: !(l Window)
manageHook :: !ManageHook
workspaces :: ![String]
defaultGaps :: ![(Int, Int, Int, Int)]
numlockMask :: !KeyMask
modMask :: !KeyMask
keys :: !(XConfig Layout -> Map (ButtonMask, KeySym) (X ()))
mouseBindings :: !(XConfig Layout -> Map (ButtonMask, Button) (Window -> X ()))
borderWidth :: !Dimension
logHook :: !(X ())
focusFollowsMouse :: !Bool
}
class Show (layout a) => LayoutClass layout a where
doLayout :: layout a -> Rectangle -> Stack a -> X ([(a, Rectangle)], Maybe (layout a))
pureLayout :: layout a -> Rectangle -> Stack a -> [(a, Rectangle)]
handleMessage :: layout a -> SomeMessage -> X (Maybe (layout a))
pureMessage :: layout a -> SomeMessage -> Maybe (layout a)
description :: layout a -> String
data Layout a = forall l . (LayoutClass l a, Read (l a)) => Layout (l a)
readsLayout :: Layout a -> String -> [(Layout a, String)]
Typeable (typeOf)
class Typeable a => Message a
data SomeMessage = forall a . Message a => SomeMessage a
fromMessage :: Message m => SomeMessage -> Maybe m
runLayout :: LayoutClass l a => l a -> Rectangle -> Maybe (Stack a) -> X ([(a, Rectangle)], Maybe (l a))
data LayoutMessages
= Hide
| ReleaseResources
runX :: XConf -> XState -> X a -> IO (a, XState)
catchX :: X a -> X a -> X a
userCode :: X () -> X ()
io :: MonadIO m => IO a -> m a
catchIO :: IO () -> X ()
doubleFork :: MonadIO m => IO () -> m ()
withDisplay :: (Display -> X a) -> X a
withWindowSet :: (WindowSet -> X a) -> X a
isRoot :: Window -> X Bool
runOnWorkspaces :: (WindowSpace -> X WindowSpace) -> X ()
broadcastMessage :: Message a => a -> X ()
getAtom :: String -> X Atom
spawn :: MonadIO m => String -> m ()
restart :: String -> Bool -> X ()
getXMonadDir :: MonadIO m => m String
recompile :: MonadIO m => Bool -> m Bool
trace :: MonadIO m => String -> m ()
whenJust :: Monad m => Maybe a -> (a -> m ()) -> m ()
whenX :: X Bool -> X () -> X ()
atom_WM_STATE :: X Atom
atom_WM_PROTOCOLS :: X Atom
atom_WM_DELETE_WINDOW :: X Atom
type ManageHook = Query (Endo WindowSet)
newtype Query a = Query (ReaderT Window X a)
runManageHook :: ManageHook -> Window -> X (WindowSet -> WindowSet)
Documentation
data X a Source

The X monad, a StateT transformer over IO encapsulating the window manager state

Dynamic components may be retrieved with get, static components with ask. With newtype deriving we get readers and state monads instantiated on XConf and XState automatically.

show/hide Instances
type WindowSet = StackSet WorkspaceId (Layout Window) Window ScreenId ScreenDetailSource
type WindowSpace = Workspace WorkspaceId (Layout Window) WindowSource
type WorkspaceId = StringSource
Virtual workspace indicies
newtype ScreenId Source
Physical screen indicies
Constructors
S Int
show/hide Instances
data ScreenDetail Source
The Rectangle with screen dimensions and the list of gaps
Constructors
SD
screenRect :: !Rectangle
statusGap :: !(Int, Int, Int, Int)width of status bar on the screen
show/hide Instances
data XState Source
XState, the window manager state. Just the display, width, height and a window list
Constructors
XState
windowset :: !WindowSetworkspace list
mapped :: !(Set Window)the Set of mapped windows
waitingUnmap :: !(Map Window Int)the number of expected UnmapEvents
dragging :: !(Maybe (Position -> Position -> X (), X ()))
show/hide Instances
data XConf Source
Constructors
XConf
display :: Displaythe X11 display
config :: !(XConfig Layout)initial user configuration
theRoot :: !Windowthe root window
normalBorder :: !Pixelborder color of unfocused windows
focusedBorder :: !Pixelborder color of the focused window
keyActions :: !(Map (KeyMask, KeySym) (X ()))a mapping of key presses to actions
buttonActions :: !(Map (KeyMask, Button) (Window -> X ()))a mapping of button presses to actions
show/hide Instances
data XConfig l Source
Constructors
XConfig
normalBorderColor :: !StringNon focused windows border color. Default: "#dddddd"
focusedBorderColor :: !StringFocused windows border color. Default: "#ff0000"
terminal :: !StringThe preferred terminal application. Default: "xterm"
layoutHook :: !(l Window)The available layouts
manageHook :: !ManageHookThe action to run when a new window is opened
workspaces :: ![String]The list of workspaces' names
defaultGaps :: ![(Int, Int, Int, Int)]The list of gaps, per screen
numlockMask :: !KeyMaskThe numlock modifier
modMask :: !KeyMaskthe mod modifier
keys :: !(XConfig Layout -> Map (ButtonMask, KeySym) (X ()))The key binding: a map from key presses and actions
mouseBindings :: !(XConfig Layout -> Map (ButtonMask, Button) (Window -> X ()))The mouse bindings
borderWidth :: !DimensionThe border width
logHook :: !(X ())The action to perform when the windows set is changed
focusFollowsMouse :: !BoolWhether window entry events can change focus
class Show (layout a) => LayoutClass layout a whereSource

The different layout modes

doLayout: given a Rectangle and a Stack, layout the stack elements inside the given Rectangle. If an element is not given a Rectangle by doLayout, then it is not shown on screen. Windows are restacked according to the order they are returned by doLayout.

Methods
doLayout :: layout a -> Rectangle -> Stack a -> X ([(a, Rectangle)], Maybe (layout a))Source
Given a Rectangle in which to place the windows, and a Stack of windows, return a list of windows and their corresponding Rectangles. The order of windows in this list should be the desired stacking order. Also return a modified layout, if this layout needs to be modified (e.g. if we keep track of the windows we have displayed).
pureLayout :: layout a -> Rectangle -> Stack a -> [(a, Rectangle)]Source
This is a pure version of doLayout, for cases where we don't need access to the X monad to determine how to layout the windows, and we don't need to modify our layout itself.
handleMessage :: layout a -> SomeMessage -> X (Maybe (layout a))Source
handleMessage performs message handling for that layout. If handleMessage returns Nothing, then the layout did not respond to that message and the screen is not refreshed. Otherwise, handleMessage returns an updated Layout and the screen is refreshed.
pureMessage :: layout a -> SomeMessage -> Maybe (layout a)Source
Respond to a message by (possibly) changing our layout, but taking no other action. If the layout changes, the screen will be refreshed.
description :: layout a -> StringSource
This should be a human-readable string that is used when selecting layouts by name.
show/hide Instances
data Layout a Source

LayoutClass handling. See particular instances in Operations.hs

An existential type that can hold any object that is in Read and LayoutClass.

Constructors
forall l . (LayoutClass l a, Read (l a)) => Layout (l a)
show/hide Instances
readsLayout :: Layout a -> String -> [(Layout a, String)]Source
Using the Layout as a witness, parse existentially wrapped windows from a String
Typeable (typeOf)
class Typeable a => Message a Source

Based on ideas in An Extensible Dynamically-Typed Hierarchy of Exceptions, Simon Marlow, 2006. Use extensible messages to the handleMessage handler.

User-extensible messages must be a member of this class.

show/hide Instances
data SomeMessage Source
A wrapped value of some type in the Message class.
Constructors
forall a . Message a => SomeMessage a
fromMessage :: Message m => SomeMessage -> Maybe mSource
And now, unwrap a given, unknown Message type, performing a (dynamic) type check on the result.
runLayout :: LayoutClass l a => l a -> Rectangle -> Maybe (Stack a) -> X ([(a, Rectangle)], Maybe (l a))Source
This calls doLayout if there are any windows to be laid out.
data LayoutMessages Source
LayoutMessages are core messages that all layouts (especially stateful layouts) should consider handling.
Constructors
Hidesent when a layout becomes non-visible
ReleaseResourcessent when xmonad is exiting or restarting
show/hide Instances
runX :: XConf -> XState -> X a -> IO (a, XState)Source
Run the X monad, given a chunk of X monad code, and an initial state Return the result, and final state
catchX :: X a -> X a -> X aSource
Run in the X monad, and in case of exception, and catch it and log it to stderr, and run the error case.
userCode :: X () -> X ()Source
Execute the argument, catching all exceptions. Either this function or catchX should be used at all callsites of user customized code.
io :: MonadIO m => IO a -> m aSource

General utilities

Lift an IO action into the X monad

catchIO :: IO () -> X ()Source
Lift an IO action into the X monad. If the action results in an IO exception, log the exception to stderr and continue normal execution.
doubleFork :: MonadIO m => IO () -> m ()Source
Double fork and execute an IO action (usually one of the exec family of functions)
withDisplay :: (Display -> X a) -> X aSource
Run a monad action with the current display settings
withWindowSet :: (WindowSet -> X a) -> X aSource
Run a monadic action with the current stack set
isRoot :: Window -> X BoolSource
True if the given window is the root window
runOnWorkspaces :: (WindowSpace -> X WindowSpace) -> X ()Source
This is basically a map function, running a function in the X monad on each workspace with the output of that function being the modified workspace.
broadcastMessage :: Message a => a -> X ()Source
Send a message to all visible layouts, without necessarily refreshing. This is how we implement the hooks, such as UnDoLayout.
getAtom :: String -> X AtomSource
Wrapper for the common case of atom internment
spawn :: MonadIO m => String -> m ()Source
spawn. Launch an external application
restart :: String -> Bool -> X ()Source
restart name resume. Attempt to restart xmonad by executing the program name. If resume is True, restart with the current window state. When executing another window manager, resume should be False.
getXMonadDir :: MonadIO m => m StringSource
Return the path to ~/.xmonad.
recompile :: MonadIO m => Bool -> m BoolSource

'recompile force', recompile ~/.xmonad/xmonad.hs when any of the following apply: * force is True * the xmonad executable does not exist * the xmonad executable is older than xmonad.hs

The -i flag is used to restrict recompilation to the xmonad.hs file only.

Compilation errors (if any) are logged to ~/.xmonad/xmonad.errors. If GHC indicates failure with a non-zero exit code, an xmessage displaying that file is spawned.

False is returned if there is compilation errors.

trace :: MonadIO m => String -> m ()Source
A trace for the X monad. Logs a string to stderr. The result may be found in your .xsession-errors file
whenJust :: Monad m => Maybe a -> (a -> m ()) -> m ()Source
Run a side effecting action with the current workspace. Like when but
whenX :: X Bool -> X () -> X ()Source
Conditionally run an action, using a X event to decide
atom_WM_STATE :: X AtomSource
atom_WM_PROTOCOLS :: X AtomSource
atom_WM_DELETE_WINDOW :: X AtomSource
Common non-predefined atoms
type ManageHook = Query (Endo WindowSet)Source
newtype Query a Source
Constructors
Query (ReaderT Window X a)
show/hide Instances
runManageHook :: ManageHook -> Window -> X (WindowSet -> WindowSet)Source
Produced by Haddock version 2.4.2