diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c index d40367522..c33ec4038 100644 --- a/xwayland/window-manager.c +++ b/xwayland/window-manager.c @@ -2685,6 +2685,32 @@ weston_wm_create_wm_window(struct weston_wm *wm) 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 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. */ 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); return wm; diff --git a/xwayland/xwayland.h b/xwayland/xwayland.h index ee878b871..7f18b33ff 100644 --- a/xwayland/xwayland.h +++ b/xwayland/xwayland.h @@ -63,6 +63,7 @@ struct weston_wm { struct weston_xserver *server; struct wl_global *xwayland_shell_global; xcb_window_t wm_window; + xcb_window_t no_focus_window; struct weston_wm_window *focus_window; struct theme *theme; xcb_cursor_t *cursors;