summaryrefslogtreecommitdiff
path: root/dev-qt/qtwayland/files/qtwayland-5.12.4-client-no-fake-surfacecreated-destroyed-events.patch
blob: c358e0f72de0672abd110b3cbbfb0976ea7a1a4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
From e6edc73942a76e57e7ac745217092333480f2c64 Mon Sep 17 00:00:00 2001
From: David Edmundson <davidedmundson@kde.org>
Date: Sun, 23 Jun 2019 15:09:51 +0200
Subject: [PATCH] Client: Don't send fake SurfaceCreated/Destroyed events

QPlatformSurface relates to the backing store. Not the wl_surface.
They are emitted by QPlatformWindow.

Due to a previously incorrect usage by KDE developers it was faked to
emit the events when the wl_surface is created/hidden to keep behavior.

With QtBase a9246c7132a2c8864d3ae6cebd260bb9ee711fcb this now causes an
issue as now QWidgets react to this event in a breaking way.

Change-Id: I2f003bc9da85f032a0053677fd281152099fc9eb
---
 .../wayland/custom-extension/client-common/customextension.cpp |  9 +++++++--
 src/client/qwaylandwindow.cpp                                  | 10 ++--------
 src/client/qwaylandwindow_p.h                                  |  2 +-
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/examples/wayland/custom-extension/client-common/customextension.cpp b/examples/wayland/custom-extension/client-common/customextension.cpp
index aa0cb58a4..16f18fd7a 100644
--- a/examples/wayland/custom-extension/client-common/customextension.cpp
+++ b/examples/wayland/custom-extension/client-common/customextension.cpp
@@ -81,8 +81,13 @@ QWindow *CustomExtension::windowForSurface(struct ::wl_surface *surface)
 
 bool CustomExtension::eventFilter(QObject *object, QEvent *event)
 {
-    if (event->type() == QEvent::PlatformSurface
-            && static_cast<QPlatformSurfaceEvent*>(event)->surfaceEventType() == QPlatformSurfaceEvent::SurfaceCreated) {
+    if (event->type() == QEvent::Expose) {
+        auto ee = static_cast<QExposeEvent*>(event);
+
+        if ((ee->region().isNull())) {
+            return false;
+        }
+
         QWindow *window = qobject_cast<QWindow*>(object);
         Q_ASSERT(window);
         window->removeEventFilter(this);
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index ca7c8495c..a6331621d 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -93,7 +93,7 @@ QWaylandWindow::~QWaylandWindow()
     delete mWindowDecoration;
 
     if (isInitialized())
-        reset(false);
+        reset();
 
     const QWindow *parent = window();
     foreach (QWindow *w, QGuiApplication::topLevelWindows()) {
@@ -119,8 +119,6 @@ void QWaylandWindow::initWindow()
 
     if (!isInitialized()) {
         initializeWlSurface();
-        QPlatformSurfaceEvent e(QPlatformSurfaceEvent::SurfaceCreated);
-        QGuiApplication::sendEvent(window(), &e);
     }
 
     if (shouldCreateSubSurface()) {
@@ -227,12 +225,8 @@ bool QWaylandWindow::shouldCreateSubSurface() const
     return QPlatformWindow::parent() != nullptr;
 }
 
-void QWaylandWindow::reset(bool sendDestroyEvent)
+void QWaylandWindow::reset()
 {
-    if (isInitialized() && sendDestroyEvent) {
-        QPlatformSurfaceEvent e(QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed);
-        QGuiApplication::sendEvent(window(), &e);
-    }
     delete mShellSurface;
     mShellSurface = nullptr;
     delete mSubSurfaceWindow;
diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h
index 121ad8219..ba69fd9dc 100644
--- a/src/client/qwaylandwindow_p.h
+++ b/src/client/qwaylandwindow_p.h
@@ -263,7 +263,7 @@ private:
     void initializeWlSurface();
     bool shouldCreateShellSurface() const;
     bool shouldCreateSubSurface() const;
-    void reset(bool sendDestroyEvent = true);
+    void reset();
     void sendExposeEvent(const QRect &rect);
     static void closePopups(QWaylandWindow *parent);
     QWaylandScreen *calculateScreenFromSurfaceEvents() const;
-- 
2.16.3