From 8a5f3ddb2e4232cbf47bdce25d4b4a929e80e2c9 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan <ofourdan@redhat.com> Date: Wed, 4 May 2022 14:25:29 +0200 Subject: [PATCH] xwayland: set tag on our surfaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit That allows to differentiate Xwayland's own surfaces from others. This is preparation work for optional libdecor support. v2: Check for surface not being NULL (Jonas Ã…dahl <jadahl@gmail.com>) Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Adam Jackson <ajax@redhat.com> --- hw/xwayland/xwayland-input.c | 21 +++++++++++++++++++++ hw/xwayland/xwayland-window.c | 14 ++++++++++++++ hw/xwayland/xwayland-window.h | 2 ++ 3 files changed, 37 insertions(+) diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c index a5181356de..325bcac0b1 100644 --- a/hw/xwayland/xwayland-input.c +++ b/hw/xwayland/xwayland-input.c @@ -525,6 +525,9 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer, if (surface == NULL) return; + if (!is_surface_from_xwl_window(surface)) + return; + xwl_seat->xwl_screen->serial = serial; xwl_seat->pointer_enter_serial = serial; @@ -867,6 +870,9 @@ pointer_gesture_swipe_handle_begin(void *data, { struct xwl_seat *xwl_seat = data; + if (surface != NULL && !is_surface_from_xwl_window(surface)) + return; + xwl_seat->pointer_gesture_swipe_fingers = fingers; QueueGestureSwipeEvents(xwl_seat->pointer_gestures, XI_GestureSwipeBegin, fingers, 0, 0.0, 0.0, 0.0, 0.0); @@ -926,6 +932,9 @@ pointer_gesture_pinch_handle_begin(void *data, { struct xwl_seat *xwl_seat = data; + if (surface != NULL && !is_surface_from_xwl_window(surface)) + return; + xwl_seat->pointer_gesture_pinch_fingers = fingers; xwl_seat->pointer_gesture_pinch_last_scale = 1.0; QueueGesturePinchEvents(xwl_seat->pointer_gestures, @@ -1095,6 +1104,9 @@ keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, struct xwl_seat *xwl_seat = data; uint32_t *k; + if (surface != NULL && !is_surface_from_xwl_window(surface)) + return; + xwl_seat->xwl_screen->serial = serial; xwl_seat->keyboard_focus = surface; @@ -1112,6 +1124,9 @@ keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, struct xwl_seat *xwl_seat = data; uint32_t *k; + if (surface != NULL && !is_surface_from_xwl_window(surface)) + return; + xwl_seat->xwl_screen->serial = serial; wl_array_for_each(k, &xwl_seat->keys) @@ -1314,6 +1329,9 @@ touch_handle_down(void *data, struct wl_touch *wl_touch, if (surface == NULL) return; + if (!is_surface_from_xwl_window(surface)) + return; + xwl_touch = calloc(1, sizeof *xwl_touch); if (xwl_touch == NULL) { ErrorF("%s: ENOMEM\n", __func__); @@ -1997,6 +2015,9 @@ tablet_tool_proximity_in(void *data, struct zwp_tablet_tool_v2 *tool, if (wl_surface == NULL) return; + if (!is_surface_from_xwl_window(wl_surface)) + return; + xwl_tablet_tool->proximity_in_serial = serial; xwl_seat->tablet_focus_window = wl_surface_get_user_data(wl_surface); diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c index f3ca987fdd..8b7e447afb 100644 --- a/hw/xwayland/xwayland-window.c +++ b/hw/xwayland/xwayland-window.c @@ -48,6 +48,7 @@ static DevPrivateKeyRec xwl_window_private_key; static DevPrivateKeyRec xwl_damage_private_key; +static const char *xwl_surface_tag = "xwl-surface"; static void xwl_window_set_allow_commits(struct xwl_window *xwl_window, Bool allow, @@ -112,6 +113,18 @@ xwl_window_from_window(WindowPtr window) return NULL; } +static void +xwl_window_set_xwayland_tag(struct xwl_window *xwl_window) +{ + wl_proxy_set_tag((struct wl_proxy *)xwl_window->surface, &xwl_surface_tag); +} + +Bool +is_surface_from_xwl_window(struct wl_surface *surface) +{ + return wl_proxy_get_tag((struct wl_proxy *) surface) == &xwl_surface_tag; +} + void xwl_window_update_property(struct xwl_window *xwl_window, PropertyStateRec *propstate) @@ -672,6 +685,7 @@ ensure_surface_for_window(WindowPtr window) send_surface_id_event(xwl_window); wl_surface_set_user_data(xwl_window->surface, xwl_window); + xwl_window_set_xwayland_tag(xwl_window); compRedirectWindow(serverClient, window, CompositeRedirectManual); diff --git a/hw/xwayland/xwayland-window.h b/hw/xwayland/xwayland-window.h index 52edb1d588..7fb5425930 100644 --- a/hw/xwayland/xwayland-window.h +++ b/hw/xwayland/xwayland-window.h @@ -63,6 +63,8 @@ struct xwl_window { struct xwl_window *xwl_window_get(WindowPtr window); struct xwl_window *xwl_window_from_window(WindowPtr window); +Bool is_surface_from_xwl_window(struct wl_surface *surface); + void xwl_window_update_property(struct xwl_window *xwl_window, PropertyStateRec *propstate); Bool xwl_window_has_viewport_enabled(struct xwl_window *xwl_window); -- GitLab