@@ -27,9 +27,6 @@ module XMonad.Hooks.EwmhDesktops (
27
27
ewmhDesktopsLogHook' ,
28
28
ewmhDesktopsLogHook ,
29
29
ewmhDesktopsLogHookCustom ,
30
- NetActivated (.. ),
31
- activated ,
32
- activateLogHook ,
33
30
ewmhDesktopsEventHook' ,
34
31
ewmhDesktopsEventHook ,
35
32
ewmhDesktopsEventHookCustom ,
@@ -49,12 +46,12 @@ import XMonad
49
46
import Control.Monad
50
47
import qualified XMonad.StackSet as W
51
48
49
+ import XMonad.Hooks.ManageHelpers
52
50
import XMonad.Hooks.SetWMName
53
51
import qualified XMonad.Util.ExtensibleState as E
54
52
import XMonad.Util.XUtils (fi )
55
53
import XMonad.Util.WorkspaceCompare
56
54
import XMonad.Util.WindowProperties (getProp32 )
57
- import qualified XMonad.Util.ExtensibleState as XS
58
55
59
56
-- $usage
60
57
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
@@ -70,42 +67,19 @@ import qualified XMonad.Util.ExtensibleState as XS
70
67
--
71
68
-- You may also be interested in 'docks' from "XMonad.Hooks.ManageDocks".
72
69
--
73
- -- __/NOTE:/__ 'ewmh' function will call 'logHook' for handling activated
74
- -- window.
75
- --
76
- -- And now by default window activation will do nothing: neither switch
77
- -- workspace, nor focus. You can use regular 'ManageHook' combinators for
78
- -- changing window activation behavior and then add resulting 'ManageHook'
79
- -- using 'activateLogHook' to your 'logHook'. Also, you may be interested in
80
- -- "XMonad.Hooks.Focus", which provides additional predicates for using in
81
- -- 'ManageHook'.
82
- --
83
- -- To get back old 'ewmh' window activation behavior (switch workspace and
84
- -- focus to activated window) you may use:
85
- --
86
- -- > import XMonad
87
- -- >
88
- -- > import XMonad.Hooks.EwmhDesktops
89
- -- > import qualified XMonad.StackSet as W
90
- -- >
91
- -- > main :: IO ()
92
- -- > main = do
93
- -- > let acMh :: ManageHook
94
- -- > acMh = reader W.focusWindow >>= doF
95
- -- > xcf = ewmh $ def
96
- -- > { modMask = mod4Mask
97
- -- > , logHook = activateLogHook acMh <+> logHook def
98
- -- > }
99
- -- > xmonad xcf
70
+ -- TODO: mention "XMonad.Hooks.UrgencyHook"
71
+ -- TODO: mention "XMonad.Hooks.Focus"
100
72
101
73
-- | TODO
102
74
data EwmhConfig = EwmhConfig
103
75
{ workspaceListTransform :: [WindowSpace ] -> [WindowSpace ]
76
+ , activateHook :: ManageHook
104
77
}
105
78
106
79
instance Default EwmhConfig where
107
80
def = EwmhConfig
108
81
{ workspaceListTransform = id
82
+ , activateHook = doFocus
109
83
}
110
84
111
85
-- | 'ewmh'' with default 'EwmhConfig'.
@@ -238,40 +212,6 @@ ewmhDesktopsEventHook = ewmhDesktopsEventHook' def
238
212
ewmhDesktopsEventHookCustom :: ([WindowSpace ] -> [WindowSpace ]) -> Event -> X All
239
213
ewmhDesktopsEventHookCustom f = ewmhDesktopsEventHook' def{ workspaceListTransform = f }
240
214
241
- -- | Whether new window _NET_ACTIVE_WINDOW activated or not. I should keep
242
- -- this value in global state, because i use 'logHook' for handling activated
243
- -- windows and i need a way to tell 'logHook' what window is activated.
244
- newtype NetActivated = NetActivated { netActivated :: Maybe Window }
245
- deriving (Show , Typeable )
246
- instance ExtensionClass NetActivated where
247
- initialValue = NetActivated Nothing
248
-
249
- -- | Was new window @_NET_ACTIVE_WINDOW@ activated?
250
- activated :: Query Bool
251
- activated = fmap (isJust . netActivated) (liftX XS. get)
252
-
253
- -- | Run supplied 'ManageHook' for activated windows /only/. If you want to
254
- -- run this 'ManageHook' for new windows too, add it to 'manageHook'.
255
- --
256
- -- __/NOTE:/__ 'activateLogHook' will work only _once_. I.e. if several
257
- -- 'activateLogHook'-s was used, only first one will actually run (because it
258
- -- resets 'NetActivated' at the end and others won't know, that window is
259
- -- activated).
260
- activateLogHook :: ManageHook -> X ()
261
- activateLogHook mh = XS. get >>= maybe (return () ) go . netActivated
262
- where
263
- go :: Window -> X ()
264
- go w = do
265
- f <- runQuery mh w
266
- -- I should reset 'NetActivated' here, because:
267
- -- * 'windows' calls 'logHook' and i shouldn't go here the second
268
- -- time for one window.
269
- -- * if i reset 'NetActivated' before running 'logHook' once,
270
- -- then 'activated' predicate won't match.
271
- -- Thus, here is the /only/ correct place.
272
- XS. put NetActivated {netActivated = Nothing }
273
- windows (appEndo f)
274
-
275
215
-- |
276
216
-- Intercepts messages from pagers and similar applications and reacts on them.
277
217
-- Currently supports:
@@ -284,7 +224,7 @@ activateLogHook mh = XS.get >>= maybe (return ()) go . netActivated
284
224
--
285
225
-- * _NET_CLOSE_WINDOW (close window)
286
226
ewmhDesktopsEventHook' :: EwmhConfig -> Event -> X All
287
- ewmhDesktopsEventHook' EwmhConfig { workspaceListTransform }
227
+ ewmhDesktopsEventHook' EwmhConfig { workspaceListTransform, activateHook }
288
228
ClientMessageEvent {ev_window = w, ev_message_type = mt, ev_data = d}
289
229
= withWindowSet $ \ s -> do
290
230
sort' <- getSortByIndex
@@ -310,10 +250,7 @@ ewmhDesktopsEventHook' EwmhConfig{ workspaceListTransform }
310
250
-- when the request comes from a pager, honor it unconditionally
311
251
-- https://specifications.freedesktop.org/wm-spec/wm-spec-1.3.html#sourceindication
312
252
(2 : _) -> windows $ W. focusWindow w
313
- _ -> do
314
- lh <- asks (logHook . config)
315
- XS. put (NetActivated (Just w))
316
- lh
253
+ _ -> windows . appEndo =<< runQuery activateHook w
317
254
| mt == a_cw ->
318
255
killWindow w
319
256
| otherwise ->
0 commit comments