mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-13 19:25:52 -07:00
A hook to handle minimize/restore window manager hints.
XMonad.Hooks.Minimize handles both minimize and restore messages. Handling restore messages was already done in RestoreMinimized, which this module intends to replace.
This commit is contained in:
XMonad
xmonad-contrib.cabal@@ -50,7 +50,7 @@ import XMonad.Hooks.EwmhDesktops
|
||||
import XMonad.Hooks.ManageDocks
|
||||
import XMonad.Hooks.ManageHelpers
|
||||
import XMonad.Hooks.PositionStoreHooks
|
||||
import XMonad.Hooks.RestoreMinimized
|
||||
import XMonad.Hooks.Minimize
|
||||
import XMonad.Hooks.ServerMode
|
||||
import XMonad.Hooks.WorkspaceByPos
|
||||
|
||||
@@ -205,7 +205,7 @@ bluetileConfig =
|
||||
logHook = currentWorkspaceOnTop >> ewmhDesktopsLogHook,
|
||||
handleEventHook = ewmhDesktopsEventHook
|
||||
`mappend` fullscreenEventHook
|
||||
`mappend` restoreMinimizedEventHook
|
||||
`mappend` minimizeEventHook
|
||||
`mappend` serverModeEventHook' bluetileCommands
|
||||
`mappend` positionStoreEventHook,
|
||||
workspaces = bluetileWorkspaces,
|
||||
|
@@ -382,13 +382,17 @@ Here is a list of the modules found in @XMonad.Hooks@:
|
||||
* "XMonad.Hooks.ManageHelpers": provide helper functions to be used
|
||||
in @manageHook@.
|
||||
|
||||
* "XMonad.Hooks.Minimize":
|
||||
Handles window manager hints to minimize and restore windows. Use
|
||||
this with XMonad.Layout.Minimize.
|
||||
|
||||
* "XMonad.Hooks.Place":
|
||||
Automatic placement of floating windows.
|
||||
|
||||
* "XMonad.Hooks.RestoreMinimized":
|
||||
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).
|
||||
|
||||
* "XMonad.Hooks.Script":
|
||||
Provides a simple interface for running a ~\/.xmonad\/hooks script with the
|
||||
|
53
XMonad/Hooks/Minimize.hs
Normal file
53
XMonad/Hooks/Minimize.hs
Normal file
@@ -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)
|
@@ -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).
|
||||
--
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
|
@@ -62,8 +62,8 @@ import Foreign.C.Types (CLong)
|
||||
-- the keyboard. Include 'BW.boringWindows' in your layout hook and see the
|
||||
-- documentation of "XMonad.Layout.BoringWindows" on how to modify your keybindings.
|
||||
--
|
||||
-- Also see "XMonad.Hooks.RestoreMinimized" if you want to be able to restore
|
||||
-- minimized windows from your taskbar.
|
||||
-- Also see "XMonad.Hooks.Minimize" if you want to be able to minimize
|
||||
-- and restore windows from your taskbar.
|
||||
|
||||
data Minimize a = Minimize [Window] (M.Map Window W.RationalRect) deriving ( Read, Show )
|
||||
minimize :: LayoutClass l Window => l Window -> ModifiedLayout Minimize l Window
|
||||
|
@@ -145,6 +145,7 @@ library
|
||||
XMonad.Hooks.InsertPosition
|
||||
XMonad.Hooks.ManageDocks
|
||||
XMonad.Hooks.ManageHelpers
|
||||
XMonad.Hooks.Minimize
|
||||
XMonad.Hooks.Place
|
||||
XMonad.Hooks.PositionStoreHooks
|
||||
XMonad.Hooks.RestoreMinimized
|
||||
|
Reference in New Issue
Block a user