xwayland: Create a dummy no_focus_window to use for non-X window focus

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
This commit is contained in:
Rémi Bernon 2025-05-23 17:53:19 +02:00
parent 4ab8d6d2c4
commit 87ae07b63f
No known key found for this signature in database
GPG key ID: 38D0E5827B54E5C9
2 changed files with 31 additions and 0 deletions

View file

@ -2685,6 +2685,32 @@ weston_wm_create_wm_window(struct weston_wm *wm)
XCB_TIME_CURRENT_TIME); XCB_TIME_CURRENT_TIME);
} }
static void
weston_wm_create_no_focus_window(struct weston_wm *wm)
{
uint32_t values[2];
values[0] = 1;
values[1] =
XCB_EVENT_MASK_KEY_PRESS |
XCB_EVENT_MASK_KEY_RELEASE |
XCB_EVENT_MASK_FOCUS_CHANGE;
wm->no_focus_window = xcb_generate_id(wm->conn);
xcb_create_window(wm->conn,
XCB_COPY_FROM_PARENT,
wm->no_focus_window,
wm->screen->root,
-100, -100, 1, 1,
0,
XCB_WINDOW_CLASS_COPY_FROM_PARENT,
XCB_COPY_FROM_PARENT,
XCB_CW_OVERRIDE_REDIRECT |
XCB_CW_EVENT_MASK,
values);
xcb_map_window(wm->conn, wm->no_focus_window);
}
static void static void
free_xwl_surface(struct wl_resource *resource) free_xwl_surface(struct wl_resource *resource)
{ {
@ -2935,6 +2961,10 @@ weston_wm_create(struct weston_xserver *wxs, int fd)
* signals to Xwayland that we're done with setup. */ * signals to Xwayland that we're done with setup. */
weston_wm_create_wm_window(wm); weston_wm_create_wm_window(wm);
/* Create a dummy no_focus_window to use when focus changes
* to a non-X window. */
weston_wm_create_no_focus_window(wm);
weston_log("created wm, root %d\n", wm->screen->root); weston_log("created wm, root %d\n", wm->screen->root);
return wm; return wm;

View file

@ -63,6 +63,7 @@ struct weston_wm {
struct weston_xserver *server; struct weston_xserver *server;
struct wl_global *xwayland_shell_global; struct wl_global *xwayland_shell_global;
xcb_window_t wm_window; xcb_window_t wm_window;
xcb_window_t no_focus_window;
struct weston_wm_window *focus_window; struct weston_wm_window *focus_window;
struct theme *theme; struct theme *theme;
xcb_cursor_t *cursors; xcb_cursor_t *cursors;