diff options
author | Spencer Janssen <sjanssen@cse.unl.edu> | 2007-05-22 06:02:28 +0200 |
---|---|---|
committer | Spencer Janssen <sjanssen@cse.unl.edu> | 2007-05-22 06:02:28 +0200 |
commit | 41e31ab4d887405815b9e3cfed7431b3d52b3024 (patch) | |
tree | ff1ff4028a82ed82ed7abe0f33854c1971bad93b | |
parent | 9a38fd185765580e6cc0fd528abdd04dd262dd1e (diff) | |
download | metatile-41e31ab4d887405815b9e3cfed7431b3d52b3024.tar metatile-41e31ab4d887405815b9e3cfed7431b3d52b3024.zip |
Add preliminary randr support
darcs-hash:20070522040228-a5988-1ae9fc6bd773b32bc4a4c43aeab556857929fef4
-rw-r--r-- | Main.hs | 9 | ||||
-rw-r--r-- | Operations.hs | 20 |
2 files changed, 27 insertions, 2 deletions
@@ -26,7 +26,7 @@ import Graphics.X11.Xinerama (getScreenInfo) import XMonad import Config import StackSet (new) -import Operations (manage, unmanage, focus, setFocusX, full, isClient) +import Operations (manage, unmanage, focus, setFocusX, full, isClient, rescreen) -- -- The main entry point @@ -70,7 +70,7 @@ main = do -- setup initial X environment sync dpy False selectInput dpy rootw $ substructureRedirectMask .|. substructureNotifyMask - .|. enterWindowMask .|. leaveWindowMask + .|. enterWindowMask .|. leaveWindowMask .|. structureNotifyMask grabKeys dpy rootw sync dpy False @@ -171,4 +171,9 @@ handle e@(ConfigureRequestEvent {}) = withDisplay $ \dpy -> do , wc_stack_mode = fromIntegral $ ev_detail e } io $ sync dpy False +-- the root may have configured +handle e@(ConfigureEvent {ev_window = w}) = do + r <- asks theRoot + when (r == w) rescreen + handle _ = return () -- trace (eventName e) -- ignoring diff --git a/Operations.hs b/Operations.hs index 62d0d51..16a46f7 100644 --- a/Operations.hs +++ b/Operations.hs @@ -28,6 +28,7 @@ import Control.Monad.Reader import Control.Arrow import Graphics.X11.Xlib +import Graphics.X11.Xinerama (getScreenInfo) import Graphics.X11.Xlib.Extras -- --------------------------------------------------------------------- @@ -155,6 +156,25 @@ tileWindow d w r = do -- --------------------------------------------------------------------- +-- | rescreen. The screen configuration may have changed, update the state and +-- refresh the screen. +rescreen :: X () +rescreen = do + dpy <- asks display + xinesc <- io $ getScreenInfo dpy + -- TODO: This stuff is necessary because Xlib apparently caches screen + -- width/height. Find a better solution later. I hate Xlib. + let sx = maximum $ map (\r -> rect_x r + fromIntegral (rect_width r)) xinesc + sy = maximum $ map (\r -> rect_y r + fromIntegral (rect_height r)) xinesc + modify (\s -> s { xineScreens = xinesc, dimensions = (sx, sy) }) + windows $ \ws@(W.StackSet { W.current = v, W.visible = vs, W.hidden = hs }) -> + let (x:xs, ys) = splitAt (length xinesc) $ map W.workspace (v:vs) ++ hs + in ws { W.current = W.Screen x 0 + , W.visible = zipWith W.Screen xs [1 ..] + , W.hidden = ys } + +-- --------------------------------------------------------------------- + buttonsToGrab :: [Button] buttonsToGrab = [button1, button2, button3] |