From e2e0e1b5de04531e0e85387499fe78f4ee2fdecf Mon Sep 17 00:00:00 2001 From: trupill Date: Wed, 31 Mar 2010 11:38:08 +0200 Subject: image_buttons Ignore-this: 418dbf488435c7c803695407557eecfb * Added a XMonad.Util.Image module to manipulate simple images and show them into an X drawable * Added the possibility of using image buttons instead of plain text buttons into the title bar * Added a XMonad.Layout.ImageButtonDecoration as an example of how to use the image buttons darcs-hash:20100331093808-a84fe-e6d3ce505f7656eef13f0c0609a8d236d9cd8d25.gz --- XMonad/Layout/WindowSwitcherDecoration.hs | 36 ++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'XMonad/Layout/WindowSwitcherDecoration.hs') diff --git a/XMonad/Layout/WindowSwitcherDecoration.hs b/XMonad/Layout/WindowSwitcherDecoration.hs index e38abd4..34f1ab4 100644 --- a/XMonad/Layout/WindowSwitcherDecoration.hs +++ b/XMonad/Layout/WindowSwitcherDecoration.hs @@ -3,6 +3,7 @@ -- | -- Module : XMonad.Layout.WindowSwitcherDecoration -- Copyright : (c) Jan Vornberger 2009 +-- Alejandro Serrano 2010 -- License : BSD3-style (see LICENSE) -- -- Maintainer : jan.vornberger@informatik.uni-oldenburg.de @@ -18,12 +19,14 @@ module XMonad.Layout.WindowSwitcherDecoration ( -- * Usage: -- $usage windowSwitcherDecoration, - windowSwitcherDecorationWithButtons + windowSwitcherDecorationWithButtons, + windowSwitcherDecorationWithImageButtons ) where import XMonad import XMonad.Layout.Decoration import XMonad.Layout.DecorationAddons +import XMonad.Layout.ImageButtonDecoration import XMonad.Layout.DraggingVisualizer import qualified XMonad.StackSet as S import Control.Monad @@ -52,6 +55,16 @@ import Foreign.C.Types(CInt) -- > myL = windowSwitcherDecorationWithButtons shrinkText defaultThemeWithButtons (draggingVisualizer $ layoutHook defaultConfig) -- > main = xmonad defaultConfig { layoutHook = myL } -- +-- Additionaly, there is a version of the decoration that contains image buttons like +-- "XMonad.Layout.ImageButtonDecoration". To use that version, you will need to +-- import "XMonad.Layout.ImageButtonDecoration" as well and modify your @layoutHook@ +-- in the following way: +-- +-- > import XMonad.Layout.ImageButtonDecoration +-- > +-- > myL = windowSwitcherDecorationWithImageButtons shrinkText defaultThemeWithImageButtons (draggingVisualizer $ layoutHook defaultConfig) +-- > main = xmonad defaultConfig { layoutHook = myL } +-- windowSwitcherDecoration :: (Eq a, Shrinker s) => s -> Theme -> l a -> ModifiedLayout (Decoration WindowSwitcherDecoration s) l a @@ -75,6 +88,27 @@ instance Eq a => DecorationStyle WindowSwitcherDecoration a where unless hasCrossed $ do sendMessage $ DraggingStopped performWindowSwitching mainw +-- Note: the image button code is duplicated from the above +-- because the title bar handle is different + +windowSwitcherDecorationWithImageButtons :: (Eq a, Shrinker s) => s -> Theme + -> l a -> ModifiedLayout (Decoration ImageWindowSwitcherDecoration s) l a +windowSwitcherDecorationWithImageButtons s c = decoration s c $ IWSD True + +data ImageWindowSwitcherDecoration a = IWSD Bool deriving (Show, Read) + +instance Eq a => DecorationStyle ImageWindowSwitcherDecoration a where + describeDeco _ = "ImageWindowSwitcherDeco" + + decorationCatchClicksHook (IWSD withButtons) mainw dFL dFR = if withButtons + then imageTitleBarButtonHandler mainw dFL dFR + else return False + decorationWhileDraggingHook _ ex ey (mainw, r) x y = handleTiledDraggingInProgress ex ey (mainw, r) x y + decorationAfterDraggingHook _ (mainw, _) decoWin = do focus mainw + hasCrossed <- handleScreenCrossing mainw decoWin + unless hasCrossed $ do sendMessage $ DraggingStopped + performWindowSwitching mainw + handleTiledDraggingInProgress :: CInt -> CInt -> (Window, Rectangle) -> Position -> Position -> X () handleTiledDraggingInProgress ex ey (mainw, r) x y = do let rect = Rectangle (x - (fi ex - rect_x r)) -- cgit v1.2.3