From a6e8db7220f4bc575e4661f202d2ea032be65b26 Mon Sep 17 00:00:00 2001 From: Sergey Trofimov Date: Tue, 15 Oct 2024 18:29:15 +0200 Subject: [PATCH] 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 --- exwm-manage.el | 2 ++ exwm.el | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/exwm-manage.el b/exwm-manage.el index ab66e29..c5c7932 100644 --- a/exwm-manage.el +++ b/exwm-manage.el @@ -65,6 +65,7 @@ possible choices: * prefix-keys: `exwm-input-prefix-keys' local to this X window. * simulation-keys: `exwm-input-simulation-keys' local to this X window. * 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. 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") :value-type (key-sequence :tag "To"))) ((const :tag "Workspace" workspace) integer) + ((const :tag "Don't steal focus" dont-steal-focus) boolean) ((const :tag "Managed" managed) boolean) ;; For forward compatibility. ((other) sexp)))) diff --git a/exwm.el b/exwm.el index 537d616..83fe959 100644 --- a/exwm.el +++ b/exwm.el @@ -494,7 +494,8 @@ DATA contains unmarshalled PropertyNotify event data." (if (buffer-live-p buffer) ;; Either an `exwm-mode' buffer (an X window) or a floating frame. (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 (select-frame exwm--floating-frame) (setq window (get-buffer-window nil t))