Blame SOURCES/0015-Client-Send-exposeEvent-to-parent-on-subsurface-posi.patch

de89c0
From 2073ff99e62d4f99ed3f1f45559c5b68a61c5f66 Mon Sep 17 00:00:00 2001
c54cd9
From: David Edmundson <davidedmundson@kde.org>
c54cd9
Date: Mon, 14 Sep 2020 17:08:39 +0100
de89c0
Subject: [PATCH 15/36] Client: Send exposeEvent to parent on subsurface
de89c0
 position changes
c54cd9
c54cd9
When a subsurface is moved, we need the parent window to commit to apply
c54cd9
that move. Ideally we want this in sync with any potential rendering on
c54cd9
the parent window.
c54cd9
c54cd9
Currently the code calls requestUpdate() which acts more like a frame
c54cd9
callback; it will only do something if the main QWindow considers itself
c54cd9
dirty.
c54cd9
c54cd9
We want to force a repaint, which is semantically more similar to an
c54cd9
ExposeEvent.
c54cd9
c54cd9
Fixes: QTBUG-86177
c54cd9
Pick-to: 5.15
c54cd9
Change-Id: I30bdfa357beee860ce2b00a256eaea6d040dd55c
c54cd9
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
c54cd9
---
c54cd9
 src/client/qwaylandwindow.cpp             |  7 ++++-
c54cd9
 tests/auto/client/surface/tst_surface.cpp | 33 +++++++++++++++++++----
c54cd9
 2 files changed, 34 insertions(+), 6 deletions(-)
c54cd9
c54cd9
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
de89c0
index 2af39977..e96d8fe9 100644
c54cd9
--- a/src/client/qwaylandwindow.cpp
c54cd9
+++ b/src/client/qwaylandwindow.cpp
de89c0
@@ -342,7 +342,12 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
c54cd9
     if (mSubSurfaceWindow) {
c54cd9
         QMargins m = QPlatformWindow::parent()->frameMargins();
c54cd9
         mSubSurfaceWindow->set_position(rect.x() + m.left(), rect.y() + m.top());
c54cd9
-        mSubSurfaceWindow->parent()->window()->requestUpdate();
c54cd9
+
c54cd9
+        QWaylandWindow *parentWindow = mSubSurfaceWindow->parent();
c54cd9
+        if (parentWindow && parentWindow->isExposed()) {
c54cd9
+            QRect parentExposeGeometry(QPoint(), parentWindow->geometry().size());
c54cd9
+            parentWindow->sendExposeEvent(parentExposeGeometry);
c54cd9
+        }
c54cd9
     }
c54cd9
 }
c54cd9
 
c54cd9
diff --git a/tests/auto/client/surface/tst_surface.cpp b/tests/auto/client/surface/tst_surface.cpp
de89c0
index b8a65f15..95e4e609 100644
c54cd9
--- a/tests/auto/client/surface/tst_surface.cpp
c54cd9
+++ b/tests/auto/client/surface/tst_surface.cpp
c54cd9
@@ -167,17 +167,40 @@ void tst_surface::negotiateShmFormat()
c54cd9
 void tst_surface::createSubsurface()
c54cd9
 {
c54cd9
     QRasterWindow window;
c54cd9
-    window.resize(64, 64);
c54cd9
-    window.show();
c54cd9
-    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
c54cd9
-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
c54cd9
-    QCOMPOSITOR_TRY_VERIFY(xdgSurface()->m_committedConfigureSerial);
c54cd9
+    window.setObjectName("main");
c54cd9
+    window.resize(200, 200);
c54cd9
 
c54cd9
     QRasterWindow subWindow;
c54cd9
+    subWindow.setObjectName("subwindow");
c54cd9
     subWindow.setParent(&window);
c54cd9
     subWindow.resize(64, 64);
c54cd9
+
c54cd9
+    window.show();
c54cd9
     subWindow.show();
c54cd9
+
c54cd9
     QCOMPOSITOR_TRY_VERIFY(subSurface());
c54cd9
+    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
c54cd9
+    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
c54cd9
+    QCOMPOSITOR_TRY_VERIFY(xdgSurface()->m_committedConfigureSerial);
c54cd9
+
c54cd9
+    const Surface *mainSurface = exec([=] {return surface(0);});
c54cd9
+    const Surface *childSurface = exec([=] {return surface(1);});
c54cd9
+    QSignalSpy  mainSurfaceCommitSpy(mainSurface, &Surface::commit);
c54cd9
+    QSignalSpy childSurfaceCommitSpy(childSurface, &Surface::commit);
c54cd9
+
c54cd9
+    // Move subsurface. The parent should redraw and commit
c54cd9
+    subWindow.setGeometry(100, 100, 64, 64);
c54cd9
+    // the toplevel should commit to indicate the subsurface moved
c54cd9
+    QCOMPOSITOR_TRY_COMPARE(mainSurfaceCommitSpy.count(), 1);
c54cd9
+    mainSurfaceCommitSpy.clear();
c54cd9
+    childSurfaceCommitSpy.clear();
c54cd9
+
c54cd9
+    // Move and resize the subSurface. The parent should redraw and commit
c54cd9
+    // The child should also redraw
c54cd9
+    subWindow.setGeometry(50, 50, 80, 80);
c54cd9
+    QCOMPOSITOR_TRY_COMPARE(mainSurfaceCommitSpy.count(), 1);
c54cd9
+    QCOMPOSITOR_TRY_COMPARE(childSurfaceCommitSpy.count(), 1);
c54cd9
+
c54cd9
 }
c54cd9
 
c54cd9
 // Used to cause a crash in libwayland (QTBUG-79674)
de89c0
-- 
de89c0
2.33.1
de89c0