Skip to content

Commit 68b9b4f

Browse files
committed
wayland/lock: support Qt 6.10
1 parent 9662234 commit 68b9b4f

File tree

3 files changed

+54
-32
lines changed

3 files changed

+54
-32
lines changed

src/wayland/session_lock/shell_integration.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
QtWaylandClient::QWaylandShellSurface*
1111
QSWaylandSessionLockIntegration::createShellSurface(QtWaylandClient::QWaylandWindow* window) {
1212
auto* lock = LockWindowExtension::get(window->window());
13-
if (lock == nullptr || lock->surface == nullptr || !lock->surface->isExposed()) {
13+
if (lock == nullptr || lock->surface == nullptr) {
1414
qFatal() << "Visibility canary failed. A window with a LockWindowExtension MUST be set to "
1515
"visible via LockWindowExtension::setVisible";
1616
}
1717

18-
return lock->surface;
18+
QSWaylandSessionLockSurface* surface = lock->surface; // shut up the unused include linter
19+
return surface;
1920
}

src/wayland/session_lock/surface.cpp

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,6 @@ void QSWaylandSessionLockSurface::applyConfigure() {
4848
this->window()->resizeFromApplyConfigure(this->size);
4949
}
5050

51-
bool QSWaylandSessionLockSurface::handleExpose(const QRegion& region) {
52-
if (this->initBuf != nullptr) {
53-
// at this point qt's next commit to the surface will have a new buffer, and we can safely delete this one.
54-
delete this->initBuf;
55-
this->initBuf = nullptr;
56-
}
57-
58-
return this->QtWaylandClient::QWaylandShellSurface::handleExpose(region);
59-
}
60-
6151
void QSWaylandSessionLockSurface::setExtension(LockWindowExtension* ext) {
6252
if (ext == nullptr) {
6353
if (this->window() != nullptr) this->window()->window()->close();
@@ -71,11 +61,6 @@ void QSWaylandSessionLockSurface::setExtension(LockWindowExtension* ext) {
7161
}
7262
}
7363

74-
void QSWaylandSessionLockSurface::setVisible() {
75-
if (this->configured && !this->visible) this->initVisible();
76-
this->visible = true;
77-
}
78-
7964
void QSWaylandSessionLockSurface::ext_session_lock_surface_v1_configure(
8065
quint32 serial,
8166
quint32 width,
@@ -97,33 +82,42 @@ void QSWaylandSessionLockSurface::ext_session_lock_surface_v1_configure(
9782
#else
9883
this->window()->updateExposure();
9984
#endif
85+
86+
#if QT_VERSION < QT_VERSION_CHECK(6, 10, 0)
10087
if (this->visible) this->initVisible();
88+
#endif
10189
} else {
10290
// applyConfigureWhenPossible runs too late and causes a protocol error on reconfigure.
10391
this->window()->resizeFromApplyConfigure(this->size);
10492
}
10593
}
10694

107-
#if QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
95+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
10896

109-
#include <private/qwaylandshmbackingstore_p.h>
97+
bool QSWaylandSessionLockSurface::commitSurfaceRole() const { return false; }
11098

111-
void QSWaylandSessionLockSurface::initVisible() {
112-
this->visible = true;
99+
void QSWaylandSessionLockSurface::setVisible() { this->window()->window()->setVisible(true); }
113100

114-
// qt always commits a null buffer in QWaylandWindow::initWindow.
115-
// We attach a dummy buffer to satisfy ext_session_lock_v1.
116-
this->initBuf = new QtWaylandClient::QWaylandShmBuffer(
117-
this->window()->display(),
118-
this->size,
119-
QImage::Format_ARGB32
120-
);
101+
#else
121102

122-
this->window()->waylandSurface()->attach(this->initBuf->buffer(), 0, 0);
123-
this->window()->window()->setVisible(true);
103+
bool QSWaylandSessionLockSurface::handleExpose(const QRegion& region) {
104+
if (this->initBuf != nullptr) {
105+
// at this point qt's next commit to the surface will have a new buffer, and we can safely delete this one.
106+
delete this->initBuf;
107+
this->initBuf = nullptr;
108+
}
109+
110+
return this->QtWaylandClient::QWaylandShellSurface::handleExpose(region);
124111
}
125112

126-
#else
113+
void QSWaylandSessionLockSurface::setVisible() {
114+
if (this->configured && !this->visible) this->initVisible();
115+
this->visible = true;
116+
}
117+
118+
#endif
119+
120+
#if QT_VERSION < QT_VERSION_CHECK(6, 10, 0)
127121

128122
#include <cmath>
129123

@@ -190,4 +184,23 @@ void QSWaylandSessionLockSurface::initVisible() {
190184
}
191185
}
192186

187+
#elif QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
188+
189+
#include <private/qwaylandshmbackingstore_p.h>
190+
191+
void QSWaylandSessionLockSurface::initVisible() {
192+
this->visible = true;
193+
194+
// qt always commits a null buffer in QWaylandWindow::initWindow.
195+
// We attach a dummy buffer to satisfy ext_session_lock_v1.
196+
this->initBuf = new QtWaylandClient::QWaylandShmBuffer(
197+
this->window()->display(),
198+
this->size,
199+
QImage::Format_ARGB32
200+
);
201+
202+
this->window()->waylandSurface()->attach(this->initBuf->buffer(), 0, 0);
203+
this->window()->window()->setVisible(true);
204+
}
205+
193206
#endif

src/wayland/session_lock/surface.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <private/qwaylandwindow_p.h>
66
#include <qregion.h>
77
#include <qtclasshelpermacros.h>
8+
#include <qtversionchecks.h>
89
#include <qtypes.h>
910
#include <qwayland-ext-session-lock-v1.h>
1011

@@ -20,7 +21,12 @@ class QSWaylandSessionLockSurface
2021

2122
[[nodiscard]] bool isExposed() const override;
2223
void applyConfigure() override;
24+
25+
#if QT_VERSION >= QT_VERSION_CHECK(6, 10, 0)
26+
[[nodiscard]] bool commitSurfaceRole() const override;
27+
#else
2328
bool handleExpose(const QRegion& region) override;
29+
#endif
2430

2531
void setExtension(LockWindowExtension* ext);
2632
void setVisible();
@@ -29,11 +35,13 @@ class QSWaylandSessionLockSurface
2935
void
3036
ext_session_lock_surface_v1_configure(quint32 serial, quint32 width, quint32 height) override;
3137

38+
#if QT_VERSION < QT_VERSION_CHECK(6, 10, 0)
3239
void initVisible();
40+
bool visible = false;
41+
#endif
3342

3443
LockWindowExtension* ext = nullptr;
3544
QSize size;
3645
bool configured = false;
37-
bool visible = false;
3846
QtWaylandClient::QWaylandShmBuffer* initBuf = nullptr;
3947
};

0 commit comments

Comments
 (0)