aboutsummaryrefslogtreecommitdiffstats
path: root/Decoration.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Decoration.hs')
-rw-r--r--Decoration.hs20
1 files changed, 9 insertions, 11 deletions
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 ()