From c7e2085ea1e8ef2f6b282daeda4d846fbf6d6087 Mon Sep 17 00:00:00 2001 From: Jan Vornberger Date: Sun, 29 Nov 2009 01:24:16 +0100 Subject: A decoration with small buttons and a supporting module Ignore-this: 2d65133bc5b9ad29bad7d06780bdaa4 darcs-hash:20091129002416-594c5-d4c577ef4ed2288a949ae89d06ada5c165c1165c.gz --- XMonad/Layout/ButtonDecoration.hs | 55 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 XMonad/Layout/ButtonDecoration.hs (limited to 'XMonad/Layout/ButtonDecoration.hs') diff --git a/XMonad/Layout/ButtonDecoration.hs b/XMonad/Layout/ButtonDecoration.hs new file mode 100644 index 0000000..43f3045 --- /dev/null +++ b/XMonad/Layout/ButtonDecoration.hs @@ -0,0 +1,55 @@ +{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-} +---------------------------------------------------------------------------- +-- | +-- Module : XMonad.Layout.ButtonDecoration +-- Copyright : (c) Jan Vornberger 2009 +-- License : BSD3-style (see LICENSE) +-- +-- Maintainer : jan.vornberger@informatik.uni-oldenburg.de +-- Stability : unstable +-- Portability : not portable +-- +-- A decoration that includes small buttons on both ends which invoke +-- various actions when clicked on: Show a window menu (see +-- "XMonad.Actions.WindowMenu"), minimize, maximize or close the window. +-- +-- Note: For maximizing and minimizing to actually work, you will need +-- to integrate "XMonad.Layout.Maximize" and "XMonad.Layout.Minimize" into your +-- setup. See the documentation of those modules for more information. +-- +----------------------------------------------------------------------------- + +module XMonad.Layout.ButtonDecoration + ( -- * Usage: + -- $usage + buttonDeco + ) where + +import XMonad +import XMonad.Layout.Decoration +import XMonad.Layout.DecorationAddons + +-- $usage +-- You can use this module with the following in your +-- @~\/.xmonad\/xmonad.hs@: +-- +-- > import XMonad.Layout.DecorationAddons +-- > import XMonad.Layout.ButtonDecoration +-- +-- Then edit your @layoutHook@ by adding the ButtonDecoration to +-- your layout: +-- +-- > myL = buttonDeco shrinkText defaultThemeWithButtons (layoutHook defaultConfig) +-- > main = xmonad defaultConfig { layoutHook = myL } +-- + +buttonDeco :: (Eq a, Shrinker s) => s -> Theme + -> l a -> ModifiedLayout (Decoration ButtonDecoration s) l a +buttonDeco s c = decoration s c $ NFD True + +data ButtonDecoration a = NFD Bool deriving (Show, Read) + +instance Eq a => DecorationStyle ButtonDecoration a where + describeDeco _ = "ButtonDeco" + decorationCatchClicksHook _ mainw dFL dFR = titleBarButtonHandler mainw dFL dFR + decorationAfterDraggingHook _ (mainw, _) decoWin = focus mainw >> handleScreenCrossing mainw decoWin >> return () -- cgit v1.2.3