summaryrefslogtreecommitdiffstats
path: root/Main.hs
diff options
context:
space:
mode:
authorSpencer Janssen <sjanssen@cse.unl.edu>2007-04-30 07:47:15 +0200
committerSpencer Janssen <sjanssen@cse.unl.edu>2007-04-30 07:47:15 +0200
commitbf5fefaac019d75d100d7e02bee48d03c90260aa (patch)
tree1a20f535ae3c91f51e7483a31301783bf5364214 /Main.hs
parent5b66269e136b49ed72c16c7b278c59fed9c18998 (diff)
downloadmetatile-bf5fefaac019d75d100d7e02bee48d03c90260aa.tar
metatile-bf5fefaac019d75d100d7e02bee48d03c90260aa.zip
Add XConf for values that don't change.
darcs-hash:20070430054715-a5988-a74f5e2868f47443a69b0cd821fa690e43a4a7e1
Diffstat (limited to 'Main.hs')
-rw-r--r--Main.hs16
1 files changed, 10 insertions, 6 deletions
diff --git a/Main.hs b/Main.hs
index e1d5c90..00f1948 100644
--- a/Main.hs
+++ b/Main.hs
@@ -21,6 +21,7 @@ import Graphics.X11.Xlib.Extras
import Graphics.X11.Xinerama
import Control.Monad.State
+import Control.Monad.Reader
import qualified StackSet as W
@@ -44,7 +45,7 @@ main = do
nbc <- initcolor normalBorderColor
fbc <- initcolor focusedBorderColor
- let st = XState
+ let cf = XConf
{ display = dpy
, xineScreens = xinesc
, theRoot = rootw
@@ -53,12 +54,14 @@ main = do
-- fromIntegral needed for X11 versions that use Int instead of CInt.
, dimensions = (fromIntegral (displayWidth dpy dflt),
fromIntegral (displayHeight dpy dflt))
- , workspace = W.empty workspaces (length xinesc)
, defaultLayoutDesc = startingLayoutDesc
- , layoutDescs = M.empty
, normalBorder = nbc
, focusedBorder = fbc
}
+ st = XState
+ { workspace = W.empty workspaces (length xinesc)
+ , layoutDescs = M.empty
+ }
xSetErrorHandler -- in C, I'm too lazy to write the binding
@@ -73,7 +76,7 @@ main = do
ws <- scan dpy rootw
allocaXEvent $ \e ->
- runX st $ do
+ runX cf st $ do
mapM_ manage ws
forever $ handle =<< xevent dpy e
where
@@ -170,12 +173,13 @@ handle e@(CrossingEvent {ev_window = w, ev_event_type = t})
-- left a window, check if we need to focus root
handle e@(CrossingEvent {ev_event_type = t})
| t == leaveNotify
- = do rootw <- gets theRoot
+ = do rootw <- asks theRoot
when (ev_window e == rootw && not (ev_same_screen e)) $ setFocus rootw
-- configure a window
handle e@(ConfigureRequestEvent {ev_window = w}) = do
- XState { display = dpy, workspace = ws } <- get
+ dpy <- asks display
+ ws <- gets workspace
when (W.member w ws) $ -- already managed, reconfigure (see client:configure()
trace ("Reconfigure already managed window: " ++ show w)