Switch Wayland integration to the new type safe Qt API

This also makes object lifetime tracking better thanks to the new API
This commit is contained in:
Ilya Fedin
2023-05-13 23:31:20 +04:00
committed by John Preston
parent 0ffaff2d8b
commit d1455f5117
3 changed files with 13 additions and 14 deletions
@@ -14,9 +14,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtGui/QGuiApplication>
#include <QtGui/QWindow>
#include <qpa/qplatformnativeinterface.h>
#include <qpa/qplatformwindow_p.h>
#include <wayland-client.h>
using namespace QNativeInterface;
using namespace QNativeInterface::Private;
namespace Platform {
namespace internal {
namespace {
@@ -101,14 +104,12 @@ org_kde_plasma_surface *WaylandIntegration::Private::plasmaSurface(
return nullptr;
}
const auto native = QGuiApplication::platformNativeInterface();
const auto native = window->nativeInterface<QWaylandWindow>();
if (!native) {
return nullptr;
}
const auto surface = reinterpret_cast<wl_surface*>(
native->nativeResourceForWindow(QByteArray("surface"), window));
const auto surface = native->surface();
if (!surface) {
return nullptr;
}
@@ -126,8 +127,8 @@ org_kde_plasma_surface *WaylandIntegration::Private::plasmaSurface(
plasmaSurfaces.emplace(surface, result);
base::qt_signal_producer(
window,
&QObject::destroyed
native,
&QWaylandWindow::surfaceDestroyed
) | rpl::start_with_next([=] {
auto it = plasmaSurfaces.find(surface);
if (it != plasmaSurfaces.cend()) {
@@ -140,14 +141,12 @@ org_kde_plasma_surface *WaylandIntegration::Private::plasmaSurface(
WaylandIntegration::WaylandIntegration()
: _private(std::make_unique<Private>()) {
const auto native = QGuiApplication::platformNativeInterface();
const auto native = qApp->nativeInterface<QWaylandApplication>();
if (!native) {
return;
}
const auto display = reinterpret_cast<wl_display*>(
native->nativeResourceForIntegration(QByteArray("wl_display")));
const auto display = native->display();
if (!display) {
return;
}
@@ -159,7 +158,7 @@ WaylandIntegration::WaylandIntegration()
_private.get());
base::qt_signal_producer(
native,
qApp,
&QObject::destroyed
) | rpl::start_with_next([=] {
// too late for standard destructors, just free
+1 -1
Submodule cmake updated: a7d000be71...42f8428489