fix: The x11 window that should not be focused on miss judge

This commit is contained in:
DreamMaoMao 2025-05-13 08:26:44 +08:00
parent 20dddcec2b
commit aec027f7fa
2 changed files with 33 additions and 0 deletions

View file

@ -363,6 +363,35 @@ static inline void client_set_suspended(Client *c, int suspended) {
wlr_xdg_toplevel_set_suspended(c->surface.xdg->toplevel, suspended);
}
static inline int client_surface_wants_focus(Client *c) {
#ifdef XWAYLAND
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 (size_t i = 0; i < sizeof(no_focus_types)/sizeof(no_focus_types[0]); ++i) {
if (wlr_xwayland_surface_has_window_type(surface, no_focus_types[i])) {
return 0;
}
}
}
#endif
return 1;
}
static inline int client_wants_focus(Client *c) {
#ifdef XWAYLAND
return client_is_unmanaged(c) &&