diff options
author | Justin Bogner <mail@justinbogner.com> | 2010-06-16 07:11:24 +0200 |
---|---|---|
committer | Justin Bogner <mail@justinbogner.com> | 2010-06-16 07:11:24 +0200 |
commit | 6933eb1d3e2b98eac9a165b4007c32629849985c (patch) | |
tree | 2320b84478257cfed3a96f8aadbbe28453f85049 /XMonad/Hooks | |
parent | 49fe8baf11846db67486ad348b443717702f4001 (diff) | |
download | XMonadContrib-6933eb1d3e2b98eac9a165b4007c32629849985c.tar.gz XMonadContrib-6933eb1d3e2b98eac9a165b4007c32629849985c.tar.xz XMonadContrib-6933eb1d3e2b98eac9a165b4007c32629849985c.zip |
A hook to handle minimize/restore window manager hints.
Ignore-this: c562ce1df81bce9a7dc5e7fe2dc67a43
XMonad.Hooks.Minimize handles both minimize and restore
messages. Handling restore messages was already done in
RestoreMinimized, which this module intends to replace.
darcs-hash:20100616051124-18f27-729a41e41728de0e8c32f53032633d34b92ebf0f.gz
Diffstat (limited to 'XMonad/Hooks')
-rw-r--r-- | XMonad/Hooks/Minimize.hs | 53 | ||||
-rw-r--r-- | XMonad/Hooks/RestoreMinimized.hs | 6 |
2 files changed, 56 insertions, 3 deletions
diff --git a/XMonad/Hooks/Minimize.hs b/XMonad/Hooks/Minimize.hs new file mode 100644 index 0000000..e293e6d --- /dev/null +++ b/XMonad/Hooks/Minimize.hs @@ -0,0 +1,53 @@ +---------------------------------------------------------------------------- +-- | +-- Module : XMonad.Hooks.Minimize +-- Copyright : (c) Justin Bogner 2010 +-- License : BSD3-style (see LICENSE) +-- +-- Maintainer : Justin Bogner <mail@justinbogner.com> +-- Stability : unstable +-- Portability : not portable +-- +-- Handles window manager hints to minimize and restore windows. Use +-- this with XMonad.Layout.Minimize. +-- +----------------------------------------------------------------------------- + +module XMonad.Hooks.Minimize + ( -- * Usage + -- $usage + minimizeEventHook + ) where + +import Data.Monoid +import Control.Monad(when) + +import XMonad +import XMonad.Layout.Minimize + +-- $usage +-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: +-- +-- > import XMonad.Hooks.Minimize +-- > import XMonad.Layout.Minimize +-- > +-- > myHandleEventHook = minimizeEventHook +-- > myLayout = minimize (Tall 1 (3/100) (1/2)) ||| Full ||| etc.. +-- > main = xmonad defaultConfig { layoutHook = myLayout +-- > , handleEventHook = myHandleEventHook } + +minimizeEventHook :: Event -> X All +minimizeEventHook (ClientMessageEvent {ev_window = w, + ev_message_type = mt, + ev_data = dt}) = do + a_aw <- getAtom "_NET_ACTIVE_WINDOW" + a_cs <- getAtom "WM_CHANGE_STATE" + + when (mt == a_aw) $ sendMessage (RestoreMinimizedWin w) + when (mt == a_cs) $ do + let message = fromIntegral . head $ dt + when (message == normalState) $ sendMessage (RestoreMinimizedWin w) + when (message == iconicState) $ sendMessage (MinimizeWin w) + + return (All True) +minimizeEventHook _ = return (All True) diff --git a/XMonad/Hooks/RestoreMinimized.hs b/XMonad/Hooks/RestoreMinimized.hs index 42cf8fb..3759ce5 100644 --- a/XMonad/Hooks/RestoreMinimized.hs +++ b/XMonad/Hooks/RestoreMinimized.hs @@ -8,9 +8,9 @@ -- Stability : unstable -- Portability : not portable -- --- Lets you restore minimized windows (see "XMonad.Layout.Minimize") --- by selecting them on a taskbar (listens for _NET_ACTIVE_WINDOW --- and WM_CHANGE_STATE). +-- (Deprecated: Use XMonad.Hooks.Minimize) Lets you restore minimized +-- windows (see "XMonad.Layout.Minimize") by selecting them on a +-- taskbar (listens for _NET_ACTIVE_WINDOW and WM_CHANGE_STATE). -- ----------------------------------------------------------------------------- |