From 464caa4bd8fa8c71f2dc1928f6a2ec0a5a392f55 Mon Sep 17 00:00:00 2001 From: "pastorelli.mario" Date: Thu, 16 Aug 2012 17:30:32 +0200 Subject: ewmh-eventhook-custom Ignore-this: 95176f6d955d74321c28caafda63faa0 Add ewmhDesktopsEventHookCustom, a generalized version of ewmhDesktopsEventHook that takes a sort function as argument. This sort function should be the same used by the LogHook. darcs-hash:20120816153032-2383e-19bbca44d0d0b39996c2e46fb2c3ebd9470ce746.gz --- XMonad/Hooks/EwmhDesktops.hs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'XMonad/Hooks') diff --git a/XMonad/Hooks/EwmhDesktops.hs b/XMonad/Hooks/EwmhDesktops.hs index 46490ea..b3bed77 100644 --- a/XMonad/Hooks/EwmhDesktops.hs +++ b/XMonad/Hooks/EwmhDesktops.hs @@ -20,6 +20,7 @@ module XMonad.Hooks.EwmhDesktops ( ewmhDesktopsLogHook, ewmhDesktopsLogHookCustom, ewmhDesktopsEventHook, + ewmhDesktopsEventHookCustom, fullscreenEventHook ) where @@ -117,18 +118,22 @@ ewmhDesktopsLogHookCustom f = withWindowSet $ \s -> do -- * _NET_WM_DESKTOP (move windows to other desktops) -- -- * _NET_ACTIVE_WINDOW (activate another window, changing workspace if needed) --- -ewmhDesktopsEventHook :: Event -> X All -ewmhDesktopsEventHook e = handle e >> return (All True) +ewmhDesktopsEventHook = ewmhDesktopsEventHookCustom id + +-- | +-- Generalized version of ewmhDesktopsEventHook that allows an arbitrary +-- user-specified function to transform the workspace list (post-sorting) +ewmhDesktopsEventHookCustom :: ([WindowSpace] -> [WindowSpace]) -> Event -> X All +ewmhDesktopsEventHookCustom f e = handle f e >> return (All True) -handle :: Event -> X () -handle ClientMessageEvent { +handle :: ([WindowSpace] -> [WindowSpace]) -> Event -> X () +handle f (ClientMessageEvent { ev_window = w, ev_message_type = mt, ev_data = d - } = withWindowSet $ \s -> do + }) = withWindowSet $ \s -> do sort' <- getSortByIndex - let ws = sort' $ W.workspaces s + let ws = f $ sort' $ W.workspaces s a_cd <- getAtom "_NET_CURRENT_DESKTOP" a_d <- getAtom "_NET_WM_DESKTOP" @@ -155,7 +160,7 @@ handle ClientMessageEvent { -- The Message is unknown to us, but that is ok, not all are meant -- to be handled by the window manager return () -handle _ = return () +handle _ _ = return () -- | -- An event hook to handle applications that wish to fullscreen using the -- cgit v1.2.3