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

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