From df58383e18a05e967a9032cbf24e818d90bfecb2 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Tue, 13 May 2025 19:03:13 +0800 Subject: [PATCH] fix: miss judgment on x11 pop-up windows that shouldn't focus --- client.h | 29 +++++++++++++++++++++++++++++ dwl.c | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/client.h b/client.h index f1e2ab5..ce969c6 100644 --- a/client.h +++ b/client.h @@ -382,6 +382,35 @@ client_set_suspended(Client *c, int suspended) wlr_xdg_toplevel_set_suspended(c->surface.xdg->toplevel, suspended); } +static inline int +client_should_ignore_focus(Client *c) { +#ifdef XWAYLAND + int i; + if (client_is_x11(c)) { + struct wlr_xwayland_surface *surface = c->surface.xwayland; + const uint32_t no_focus_types[] = { + WLR_XWAYLAND_NET_WM_WINDOW_TYPE_COMBO, + WLR_XWAYLAND_NET_WM_WINDOW_TYPE_DND, + WLR_XWAYLAND_NET_WM_WINDOW_TYPE_DROPDOWN_MENU, + WLR_XWAYLAND_NET_WM_WINDOW_TYPE_MENU, + WLR_XWAYLAND_NET_WM_WINDOW_TYPE_NOTIFICATION, + WLR_XWAYLAND_NET_WM_WINDOW_TYPE_POPUP_MENU, + WLR_XWAYLAND_NET_WM_WINDOW_TYPE_SPLASH, + WLR_XWAYLAND_NET_WM_WINDOW_TYPE_DESKTOP, + WLR_XWAYLAND_NET_WM_WINDOW_TYPE_TOOLTIP, + WLR_XWAYLAND_NET_WM_WINDOW_TYPE_UTILITY}; + for (i = 0; + i < LENGTH(no_focus_types); ++i) { + if (wlr_xwayland_surface_has_window_type(surface, + no_focus_types[i])) { + return 1; + } + } + } +#endif + return 0; +} + static inline int client_wants_focus(Client *c) { diff --git a/dwl.c b/dwl.c index 4816159..0a48f7e 100644 --- a/dwl.c +++ b/dwl.c @@ -1404,7 +1404,7 @@ focusclient(Client *c, int lift) Client *old_c = NULL; LayerSurface *old_l = NULL; - if (locked) + if (locked || (c && client_should_ignore_focus(c))) return; /* Raise client in stacking order if requested */