Support Wayland display reconnection
This commit is contained in:
parent
58451aed91
commit
ce8e42bcc2
|
@ -8,7 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "platform/linux/linux_wayland_integration.h"
|
||||
|
||||
#include "base/platform/linux/base_linux_wayland_utilities.h"
|
||||
#include "base/platform/base_platform_info.h"
|
||||
#include "base/qt_signal_producer.h"
|
||||
#include "base/flat_map.h"
|
||||
|
||||
|
@ -20,7 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include <qwayland-wayland.h>
|
||||
#include <qwayland-plasma-shell.h>
|
||||
|
||||
using namespace QNativeInterface;
|
||||
using QWlApp = QNativeInterface::QWaylandApplication;
|
||||
using namespace QNativeInterface::Private;
|
||||
using namespace base::Platform::Wayland;
|
||||
|
||||
|
@ -38,9 +37,17 @@ public:
|
|||
|
||||
} // namespace
|
||||
|
||||
struct WaylandIntegration::Private : public AutoDestroyer<QtWayland::wl_registry> {
|
||||
struct WaylandIntegration::Private
|
||||
: public AutoDestroyer<QtWayland::wl_registry> {
|
||||
Private(not_null<QWlApp*> native)
|
||||
: AutoDestroyer(wl_display_get_registry(native->display()))
|
||||
, display(native->display()) {
|
||||
wl_display_roundtrip(display);
|
||||
}
|
||||
|
||||
QtWayland::org_kde_plasma_surface plasmaSurface(QWindow *window);
|
||||
|
||||
const not_null<wl_display*> display;
|
||||
std::optional<PlasmaShell> plasmaShell;
|
||||
|
||||
protected:
|
||||
|
@ -102,36 +109,27 @@ QtWayland::org_kde_plasma_surface WaylandIntegration::Private::plasmaSurface(
|
|||
}
|
||||
|
||||
WaylandIntegration::WaylandIntegration()
|
||||
: _private(std::make_unique<Private>()) {
|
||||
const auto native = qApp->nativeInterface<QWaylandApplication>();
|
||||
if (!native) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto display = native->display();
|
||||
if (!display) {
|
||||
return;
|
||||
}
|
||||
|
||||
_private->init(wl_display_get_registry(display));
|
||||
wl_display_roundtrip(display);
|
||||
: _private(std::make_unique<Private>(qApp->nativeInterface<QWlApp>())) {
|
||||
}
|
||||
|
||||
WaylandIntegration::~WaylandIntegration() = default;
|
||||
|
||||
WaylandIntegration *WaylandIntegration::Instance() {
|
||||
if (!IsWayland()) return nullptr;
|
||||
static std::optional<WaylandIntegration> instance(std::in_place);
|
||||
[[maybe_unused]] static const auto Inited = [] {
|
||||
const auto native = qApp->nativeInterface<QWlApp>();
|
||||
if (!native) return nullptr;
|
||||
static std::optional<WaylandIntegration> instance;
|
||||
if (instance && native->display() != instance->_private->display) {
|
||||
instance.reset();
|
||||
}
|
||||
if (!instance) {
|
||||
instance.emplace();
|
||||
base::qt_signal_producer(
|
||||
QGuiApplication::platformNativeInterface(),
|
||||
&QObject::destroyed
|
||||
) | rpl::start_with_next([] {
|
||||
instance = std::nullopt;
|
||||
}, instance->_private->lifetime());
|
||||
return true;
|
||||
}();
|
||||
if (!instance) return nullptr;
|
||||
}
|
||||
return &*instance;
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 6de11e6ab705f27158f338e3e17c8b0767750721
|
||||
Subproject commit 5916b1db7ccae3ba0fafa8309d50c2c09a19604b
|
2
cmake
2
cmake
|
@ -1 +1 @@
|
|||
Subproject commit 0ae4e78a12d7fdea687ca52647465b9cf9ef95ee
|
||||
Subproject commit 0bacdcaaa4ac11348cc5562e94eac1e5bdb58789
|
Loading…
Reference in New Issue