From 85e6d51f04828c05cd23ca9dcd5aa59cb893c12d Mon Sep 17 00:00:00 2001 From: Spencer Janssen Date: Mon, 30 Apr 2007 07:47:15 +0200 Subject: Add XConf for values that don't change. darcs-hash:20070430054715-a5988-a74f5e2868f47443a69b0cd821fa690e43a4a7e1.gz --- Main.hs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'Main.hs') 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) -- cgit v1.2.3