diff --git a/hw/xwayland/xwayland-screen.c b/hw/xwayland/xwayland-screen.c index 9b1ad0ec5..1e2a345c2 100644 --- a/hw/xwayland/xwayland-screen.c +++ b/hw/xwayland/xwayland-screen.c @@ -643,6 +643,52 @@ xwl_screen_roundtrip(struct xwl_screen *xwl_screen) xwl_give_up("could not connect to wayland server\n"); } +static int +xwl_server_grab(ClientPtr client) +{ + struct xwl_screen *xwl_screen; + + /* Allow GrabServer for the X11 window manager. + * Xwayland only has 1 screen (no Zaphod for Xwayland) so we check + * for the first and only screen here. + */ + xwl_screen = xwl_screen_get(screenInfo.screens[0]); + if (xwl_screen->wm_client_id == client->index) + return xwl_screen->GrabServer(client); + + /* For all other clients, just pretend it works for compatibility, + but do nothing */ + return Success; +} + +static int +xwl_server_ungrab(ClientPtr client) +{ + struct xwl_screen *xwl_screen; + + /* Same as above, allow UngrabServer for the X11 window manager only */ + xwl_screen = xwl_screen_get(screenInfo.screens[0]); + if (xwl_screen->wm_client_id == client->index) + return xwl_screen->UngrabServer(client); + + /* For all other clients, just pretend it works for compatibility, + but do nothing */ + return Success; +} + +static void +xwl_screen_setup_custom_vector(struct xwl_screen *xwl_screen) +{ + /* Rootfull Xwayland does not need a custom ProcVector (yet?) */ + if (xwl_screen->rootless) + return; + + xwl_screen->GrabServer = ProcVector[X_GrabServer]; + xwl_screen->UngrabServer = ProcVector[X_UngrabServer]; + + ProcVector[X_GrabServer] = xwl_server_grab; + ProcVector[X_UngrabServer] = xwl_server_ungrab; +} int xwl_screen_get_next_output_serial(struct xwl_screen *xwl_screen) @@ -932,6 +978,8 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv) AddCallback(&PropertyStateCallback, xwl_property_callback, pScreen); AddCallback(&RootWindowFinalizeCallback, xwl_root_window_finalized_callback, pScreen); + xwl_screen_setup_custom_vector(xwl_screen); + xwl_screen_roundtrip(xwl_screen); return ret; diff --git a/hw/xwayland/xwayland-screen.h b/hw/xwayland/xwayland-screen.h index fd201cdf5..43414f77d 100644 --- a/hw/xwayland/xwayland-screen.h +++ b/hw/xwayland/xwayland-screen.h @@ -78,6 +78,9 @@ struct xwl_screen { ResizeWindowProcPtr ResizeWindow; MoveWindowProcPtr MoveWindow; + int (*GrabServer) (ClientPtr client); + int (*UngrabServer) (ClientPtr client); + struct xorg_list output_list; struct xorg_list seat_list; struct xorg_list damage_window_list;