From 5f1312128d87961231d5431af0885711a01cd120 Mon Sep 17 00:00:00 2001 From: David Roundy Date: Sat, 23 Jun 2007 23:09:52 +0200 Subject: make everything work with new doLayout. This modifies all the contrib modules to work (so far as I know) with the new contrib layout. The exception is the LayoutHooks module, which isn't used. It exports an API that is inherently unsafe, so far as I can tell (and always has been). darcs-hash:20070623210952-72aca-1993ca13dc6996b59fedacc271c03fbaf87eabaa.gz --- Decoration.hs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'Decoration.hs') diff --git a/Decoration.hs b/Decoration.hs index 6b63475..2543af9 100644 --- a/Decoration.hs +++ b/Decoration.hs @@ -24,7 +24,7 @@ import Control.Monad.Reader ( asks ) import Graphics.X11.Xlib import Graphics.X11.Xlib.Extras ( Event(AnyEvent,ButtonEvent), ev_subwindow, ev_event_type, ev_window ) -import XMonadContrib.LayoutHooks +import XMonadContrib.LayoutHelpers ( ModLay, layoutModify, idModDo ) import XMonad import Operations ( UnDoLayout(UnDoLayout) ) @@ -33,19 +33,19 @@ import Operations ( UnDoLayout(UnDoLayout) ) -- You can use this module for writing other extensions. -- See, for instance, "XMonadContrib.Tabbed" -newDecoration :: Window -> Rectangle -> Int -> Pixel -> Pixel -> String - -> (Display -> Window -> GC -> FontStruct -> X ()) -> X () -> X Window -newDecoration decfor (Rectangle x y w h) th fg bg fn draw click = do +newDecoration :: Window -> Rectangle -> Int -> Pixel -> Pixel + -> (Display -> Window -> GC -> X ()) -> X () -> X Window +newDecoration decfor (Rectangle x y w h) th fg bg draw click = do d <- asks display rt <- asks theRoot win <- io $ createSimpleWindow d rt x y w h (fromIntegral th) fg bg io $ selectInput d win $ exposureMask .|. buttonPressMask io $ mapWindow d win - let hook :: SomeMessage -> X Bool - hook sm | Just e <- fromMessage sm = handle_event e >> return True - | Just UnDoLayout == fromMessage sm = io (destroyWindow d win) >> return False - | otherwise = return True + let hook :: SomeMessage -> X (Maybe (ModLay a)) + hook sm | Just e <- fromMessage sm = handle_event e >> return Nothing + | Just UnDoLayout == fromMessage sm = io (destroyWindow d win) >> return (Just id) + | otherwise = return Nothing handle_event (ButtonEvent {ev_subwindow = thisw,ev_event_type = t}) | t == buttonPress && thisw == win = click @@ -56,9 +56,7 @@ newDecoration decfor (Rectangle x y w h) th fg bg fn draw click = do | thisw == decfor && t == propertyNotify = withGC win fn draw handle_event _ = return () - addLayoutMessageHook hook - - return win + return $ layoutModify idModDo hook l -- FIXME: withGC should use bracket (but can't, unless draw is an IO thing) withGC :: Drawable -> String -> (Display -> Drawable -> GC -> FontStruct -> X ()) -> X () -- cgit v1.2.3