Add dont-steal-focus configuration property.

Some applications send _NET_ACTIVE_WINDOW to activate their window. EXWM
respects this message always and brings such up into focus. This might
be unintended and there should be a way to turn this off. In my case the
app is Spotify desktop client installed from Flatpak.

Fixes https://github.com/ch11ng/exwm/issues/732
This commit is contained in:
Sergey Trofimov 2024-10-15 18:29:15 +02:00
parent 14e78817f9
commit a6e8db7220
2 changed files with 4 additions and 1 deletions

View file

@ -65,6 +65,7 @@ possible choices:
* prefix-keys: `exwm-input-prefix-keys' local to this X window. * prefix-keys: `exwm-input-prefix-keys' local to this X window.
* simulation-keys: `exwm-input-simulation-keys' local to this X window. * simulation-keys: `exwm-input-simulation-keys' local to this X window.
* workspace: The initial workspace. * workspace: The initial workspace.
* dont-steal-focus: Ignore activation message for this X window.
* managed: Force to manage (non-nil) or not manage (nil) the X window. * managed: Force to manage (non-nil) or not manage (nil) the X window.
For each X window managed for the first time, matching criteria (sexps) are For each X window managed for the first time, matching criteria (sexps) are
@ -98,6 +99,7 @@ want to match against EXWM internal variables such as `exwm-title',
(alist :key-type (key-sequence :tag "From") (alist :key-type (key-sequence :tag "From")
:value-type (key-sequence :tag "To"))) :value-type (key-sequence :tag "To")))
((const :tag "Workspace" workspace) integer) ((const :tag "Workspace" workspace) integer)
((const :tag "Don't steal focus" dont-steal-focus) boolean)
((const :tag "Managed" managed) boolean) ((const :tag "Managed" managed) boolean)
;; For forward compatibility. ;; For forward compatibility.
((other) sexp)))) ((other) sexp))))

View file

@ -494,7 +494,8 @@ DATA contains unmarshalled PropertyNotify event data."
(if (buffer-live-p buffer) (if (buffer-live-p buffer)
;; Either an `exwm-mode' buffer (an X window) or a floating frame. ;; Either an `exwm-mode' buffer (an X window) or a floating frame.
(with-current-buffer buffer (with-current-buffer buffer
(when (eq exwm--frame exwm-workspace--current) (when (and (eq exwm--frame exwm-workspace--current)
(not (plist-get exwm--configurations 'dont-steal-focus)))
(if exwm--floating-frame (if exwm--floating-frame
(select-frame exwm--floating-frame) (select-frame exwm--floating-frame)
(setq window (get-buffer-window nil t)) (setq window (get-buffer-window nil t))