From 1d7807235f56c68289b143d8a6c6b5ae5a0d4ad2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= <emilio@crisal.io>
Date: Wed, 23 Jun 2021 12:46:30 +0200
Subject: [PATCH] kwayland: Send wl_surface_enter / wl_surface_leave on top of
 wl_pointer_enter / wl_pointer_leave.

---
 src/server/pointer_interface.cpp | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/server/pointer_interface.cpp b/src/server/pointer_interface.cpp
index ab0d28f..f0a72b1 100644
--- a/src/server/pointer_interface.cpp
+++ b/src/server/pointer_interface.cpp
@@ -57,12 +57,19 @@ void PointerInterface::Private::setCursor(quint32 serial, SurfaceInterface *surf
 
 void PointerInterface::Private::sendLeave(SurfaceInterface *surface, quint32 serial)
 {
-    if (!surface) {
+    if (!surface || !surface->resource()) {
         return;
     }
-    if (resource && surface->resource()) {
+    if (resource) {
         wl_pointer_send_leave(resource, serial, surface->resource());
     }
+
+    if (cursor) {
+        auto cursorSurface = cursor->surface();
+        if (cursorSurface && cursorSurface->resource()) {
+            wl_surface_send_leave(cursorSurface->resource(), surface->resource());
+        }
+    }
 }
 
 void PointerInterface::Private::registerRelativePointer(RelativePointerInterface *relativePointer)
@@ -107,6 +114,12 @@ void PointerInterface::Private::sendEnter(SurfaceInterface *surface, const QPoin
     }
     const QPointF adjustedPos = parentSurfacePosition - surfacePosition(surface);
     wl_pointer_send_enter(resource, serial, surface->resource(), wl_fixed_from_double(adjustedPos.x()), wl_fixed_from_double(adjustedPos.y()));
+    if (cursor) {
+        auto cursorSurface = cursor->surface();
+        if (cursorSurface && cursorSurface->resource()) {
+            wl_surface_send_enter(cursorSurface->resource(), surface->resource());
+        }
+    }
 }
 
 void PointerInterface::Private::startSwipeGesture(quint32 serial, quint32 fingerCount)
-- 
2.31.1

