File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ module XMonad.Hooks.EwmhDesktops (
21
21
ewmhDesktopsLogHookCustom ,
22
22
ewmhDesktopsEventHook ,
23
23
ewmhDesktopsEventHookCustom ,
24
+ ignoreNetActiveWindow ,
25
+ ignoreNetActiveWindowEventHook ,
24
26
ewmhFullscreen ,
25
27
fullscreenEventHook ,
26
28
fullscreenStartup
@@ -216,6 +218,31 @@ handle f (ClientMessageEvent {
216
218
return ()
217
219
handle _ _ = return ()
218
220
221
+ -- | Ignore window activation requests from some windows, e.g. a browser
222
+ -- stealing focus whenever a link is opened from another app.
223
+ --
224
+ -- Usage:
225
+ --
226
+ -- > main = xmonad $ ignoreNetActiveWindow q $ ewmh def
227
+ -- > where
228
+ -- > q = className =? "google-chrome"
229
+ ignoreNetActiveWindow :: Query Bool -> XConfig a -> XConfig a
230
+ ignoreNetActiveWindow q c =
231
+ c { handleEventHook = ignoreNetActiveWindowEventHook q (handleEventHook c) }
232
+
233
+ ignoreNetActiveWindowEventHook :: Query Bool -> (Event -> X All ) -> Event -> X All
234
+ ignoreNetActiveWindowEventHook q hook
235
+ e@ ClientMessageEvent { ev_window = w, ev_message_type = mt } = do
236
+ a_aw <- getAtom " _NET_ACTIVE_WINDOW"
237
+ if mt == a_aw
238
+ then do
239
+ ignore <- runQuery q w
240
+ if ignore
241
+ then return (All True )
242
+ else hook e
243
+ else hook e
244
+ ignoreNetActiveWindowEventHook _ hook e = hook e
245
+
219
246
-- | Add EWMH fullscreen functionality to the given config.
220
247
--
221
248
-- This must be applied after 'ewmh', like so:
You can’t perform that action at this time.
0 commit comments