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