xwayland: set tag on our surfaces

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>
(cherry picked from commit 8a5f3ddb2e)
This commit is contained in:
Olivier Fourdan 2022-05-04 14:25:29 +02:00
parent aff0a4fb58
commit f883f6bc6e
3 changed files with 37 additions and 0 deletions

View file

@ -467,6 +467,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;
@ -834,6 +837,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);
@ -893,6 +899,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,
@ -1026,6 +1035,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;
@ -1041,6 +1053,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)
@ -1241,6 +1256,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__);
@ -1917,6 +1935,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);

View file

@ -50,6 +50,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,
@ -114,6 +115,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)
@ -482,6 +495,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);

View file

@ -66,6 +66,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);