summaryrefslogtreecommitdiff
path: root/kde-misc/yakuake/files/yakuake-3.0.4-qt-5.9-wayland.patch
blob: b24781dcc9ff07b6c486f6f0544d0cc6bdc4c145 (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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
From 7534df21025b10fd236dd5a8f92d0dff7889e0ef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= <mgraesslin@kde.org>
Date: Wed, 6 Sep 2017 18:42:01 +0200
Subject: Make Yakuake work on Wayland with Qt 5.9

Summary:
Yakuake is also affected by the common problem that the integration
breaks once a window gets hidden, which is a very common feature of
Yakuake.

This change tracks the PlasmaShellSurface, destroys it on hide and
recreates on show. Thus it's alwyas positioned as expected.

Test Plan:
This commit was created using a yakuake which is positioned
correctly, although I pressed F12 a few times.

Differential Revision: https://phabricator.kde.org/D7709
---
 app/mainwindow.cpp | 33 ++++++++++++++++++++++++++-------
 app/mainwindow.h   |  3 +++
 2 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp
index a7b0d89..6fa9160 100644
--- a/app/mainwindow.cpp
+++ b/app/mainwindow.cpp
@@ -95,6 +95,7 @@ MainWindow::MainWindow(QWidget* parent)
     m_isWayland = QGuiApplication::platformName().startsWith(QLatin1String("wayland"));
 #if HAVE_KWAYLAND
     m_plasmaShell = Q_NULLPTR;
+    m_plasmaShellSurface = Q_NULLPTR;
     initWayland();
 #endif
 
@@ -176,6 +177,21 @@ void MainWindow::initWayland()
     registry->setup();
     connection->roundtrip();
 }
+
+void MainWindow::initWaylandSurface()
+{
+    if (m_plasmaShellSurface) {
+        return;
+    }
+    if (!m_plasmaShell) {
+        return;
+    }
+    if (auto surface = KWayland::Client::Surface::fromWindow(windowHandle())) {
+        m_plasmaShellSurface = m_plasmaShell->createSurface(surface, this);
+        m_plasmaShellSurface->setPosition(pos());
+    }
+}
+
 #endif
 
 bool MainWindow::queryClose()
@@ -861,13 +877,7 @@ void MainWindow::setWindowGeometry(int newWidth, int newHeight, int newPosition)
     setGeometry(workArea.x() + workArea.width() * newPosition * (100 - newWidth) / 10000,
                 workArea.y(), targetWidth, maxHeight);
 #if HAVE_KWAYLAND
-    if (m_plasmaShell) {
-        if (auto surface = KWayland::Client::Surface::fromWindow(windowHandle())) {
-            if (auto plasmaSurface = m_plasmaShell->createSurface(surface, this)) {
-                plasmaSurface->setPosition(pos());
-            }
-        }
-    }
+    initWaylandSurface();
 #endif
 
     maxHeight -= m_titleBar->height();
@@ -1303,6 +1313,10 @@ void MainWindow::sharedAfterOpenWindow()
 
     applyWindowProperties();
 
+#if HAVE_KWAYLAND
+    initWaylandSurface();
+#endif
+
     emit windowOpened();
 }
 
@@ -1316,6 +1330,11 @@ void MainWindow::sharedAfterHideWindow()
 {
     if (Settings::pollMouse()) toggleMousePoll(true);
 
+#if HAVE_KWAYLAND
+    delete m_plasmaShellSurface;
+    m_plasmaShellSurface = Q_NULLPTR;
+#endif
+
     emit windowClosed();
 }
 
diff --git a/app/mainwindow.h b/app/mainwindow.h
index 8a46c89..bb6404e 100644
--- a/app/mainwindow.h
+++ b/app/mainwindow.h
@@ -44,6 +44,7 @@ class KActionCollection;
 namespace KWayland {
     namespace Client {
         class PlasmaShell;
+        class PlasmaShellSurface;
     }
 }
 #endif
@@ -203,7 +204,9 @@ class MainWindow : public QMainWindow
 
 #if HAVE_KWAYLAND
         void initWayland();
+        void initWaylandSurface();
         KWayland::Client::PlasmaShell *m_plasmaShell;
+        KWayland::Client::PlasmaShellSurface *m_plasmaShellSurface;
 #endif
 };
 
-- 
cgit v0.11.2