opt: check kde atom _kde_net_wm_window_type_override)

This commit is contained in:
DreamMaoMao 2026-03-04 11:41:12 +08:00
parent 1e1d41e626
commit 0eed59406c
2 changed files with 28 additions and 1 deletions

View file

@ -448,8 +448,23 @@ static inline int32_t client_should_overtop(Client *c) {
return 0; return 0;
} }
static inline bool
extra_xwayland_surface_has_window_type(struct wlr_xwayland_surface *surface,
xcb_atom_t atom) {
for (size_t i = 0; i < surface->window_type_len; i++) {
if (surface->window_type[i] == atom)
return true;
}
return false;
}
static inline int32_t client_wants_focus(Client *c) { static inline int32_t client_wants_focus(Client *c) {
#ifdef XWAYLAND #ifdef XWAYLAND
if (extra_xwayland_surface_has_window_type(
c->surface.xwayland, atom_kde_net_wm_window_type_override))
return false;
return client_is_unmanaged(c) && return client_is_unmanaged(c) &&
wlr_xwayland_surface_override_redirect_wants_focus( wlr_xwayland_surface_override_redirect_wants_focus(
c->surface.xwayland) && c->surface.xwayland) &&

View file

@ -919,7 +919,6 @@ static struct {
int32_t hotspot_y; int32_t hotspot_y;
} last_cursor; } last_cursor;
#include "client/client.h"
#include "config/preset.h" #include "config/preset.h"
struct Pertag { struct Pertag {
@ -988,12 +987,14 @@ static struct wl_listener new_xwayland_surface = {.notify = createnotifyx11};
static struct wl_listener xwayland_ready = {.notify = xwaylandready}; static struct wl_listener xwayland_ready = {.notify = xwaylandready};
static struct wlr_xwayland *xwayland; static struct wlr_xwayland *xwayland;
static struct wl_event_source *sync_keymap; static struct wl_event_source *sync_keymap;
static xcb_atom_t atom_kde_net_wm_window_type_override;
#endif #endif
#include "animation/client.h" #include "animation/client.h"
#include "animation/common.h" #include "animation/common.h"
#include "animation/layer.h" #include "animation/layer.h"
#include "animation/tag.h" #include "animation/tag.h"
#include "client/client.h"
#include "config/parse_config.h" #include "config/parse_config.h"
#include "dispatch/bind_define.h" #include "dispatch/bind_define.h"
#include "ext-protocol/all.h" #include "ext-protocol/all.h"
@ -6552,6 +6553,17 @@ void xwaylandready(struct wl_listener *listener, void *data) {
/* xwayland can't auto sync the keymap, so we do it manually /* xwayland can't auto sync the keymap, so we do it manually
and we need to wait the xwayland completely inited and we need to wait the xwayland completely inited
*/ */
xcb_connection_t *xcb_conn =
xcb_connect(NULL, NULL); // 或从 wlr_xwayland 获取
xcb_intern_atom_cookie_t cookie =
xcb_intern_atom(xcb_conn, 0, strlen("_KDE_NET_WM_WINDOW_TYPE_OVERRIDE"),
"_KDE_NET_WM_WINDOW_TYPE_OVERRIDE");
xcb_intern_atom_reply_t *reply =
xcb_intern_atom_reply(xcb_conn, cookie, NULL);
atom_kde_net_wm_window_type_override = reply->atom;
free(reply);
wl_event_source_timer_update(sync_keymap, 500); wl_event_source_timer_update(sync_keymap, 500);
} }