diff --git a/src/client/client.h b/src/client/client.h index cefddd5..f93e497 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -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) && diff --git a/src/maomao.c b/src/maomao.c index 7e322c1..b5d0e06 100644 --- a/src/maomao.c +++ b/src/maomao.c @@ -3707,6 +3707,10 @@ void focusclient(Client *c, int lift) { if (c && c->animation.tagouting && !c->animation.tagouting) return; + if(c && client_is_x11(c) && !client_surface_wants_focus(c)) { + return; + } + /* Raise client in stacking order if requested */ if (c && lift) wlr_scene_node_raise_to_top(&c->scene->node); // 将视图提升到顶层