mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
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:
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 @@
|
|||
Subproject commit 17a19f39d2a1204a90d74516c28fd27c522ded17
|
||||
Subproject commit b032f944298bfa464c9378a5c56826cf13956eae
|
2
cmake
2
cmake
|
@ -1 +1 @@
|
|||
Subproject commit a7d000be71db475f034c42687e7905fc8116050f
|
||||
Subproject commit 42f8428489692f0a4a05bf833478bad7ee8d5989
|
Loading…
Add table
Reference in a new issue