diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index a5181356de8225ea0fe1bc38cc0c4ad13aa4c98d..325bcac0b16148a41b396ddad351a8256fb65a5d 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 f3ca987fdd9a3d5e1bc7dd6df0b5d02501dea4f0..8b7e447afb9879177cee71ac86cf449ca2077097 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 52edb1d5880e654e3d921840737bbaf30b9e94ae..7fb5425930c8a7f5c5c28e2002cdb1b34449e1be 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);