module XMonad.Hooks.Minimize
(
minimizeEventHook
) where
import XMonad
import XMonad.Actions.Minimize
import XMonad.Prelude
minimizeEventHook :: Event -> X All
minimizeEventHook :: Event -> X All
minimizeEventHook ClientMessageEvent{ev_window :: Event -> Atom
ev_window = Atom
w,
ev_message_type :: Event -> Atom
ev_message_type = Atom
mt,
ev_data :: Event -> [CInt]
ev_data = [CInt]
dt} = do
Atom
a_aw <- String -> X Atom
getAtom String
"_NET_ACTIVE_WINDOW"
Atom
a_cs <- String -> X Atom
getAtom String
"WM_CHANGE_STATE"
Bool -> X () -> X ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Atom
mt Atom -> Atom -> Bool
forall a. Eq a => a -> a -> Bool
== Atom
a_aw) (X () -> X ()) -> X () -> X ()
forall a b. (a -> b) -> a -> b
$ Atom -> X ()
maximizeWindow Atom
w
Bool -> X () -> X ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Atom
mt Atom -> Atom -> Bool
forall a. Eq a => a -> a -> Bool
== Atom
a_cs) (X () -> X ()) -> X () -> X ()
forall a b. (a -> b) -> a -> b
$ do
let message :: Int
message = CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (CInt -> Int) -> ([CInt] -> CInt) -> [CInt] -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [CInt] -> CInt
forall a. [a] -> a
head ([CInt] -> Int) -> [CInt] -> Int
forall a b. (a -> b) -> a -> b
$ [CInt]
dt
Bool -> X () -> X ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Int
message Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
normalState) (X () -> X ()) -> X () -> X ()
forall a b. (a -> b) -> a -> b
$ Atom -> X ()
maximizeWindow Atom
w
Bool -> X () -> X ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Int
message Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
iconicState) (X () -> X ()) -> X () -> X ()
forall a b. (a -> b) -> a -> b
$ Atom -> X ()
minimizeWindow Atom
w
All -> X All
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool -> All
All Bool
True)
minimizeEventHook Event
_ = All -> X All
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool -> All
All Bool
True)