blob: a3ff4276152bc93452d8d9809d9d3e8e3509501f (
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
|
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "platform/linux/linux_wayland_integration.h"
#include "base/platform/base_platform_info.h"
#include <connection_thread.h>
#include <registry.h>
using namespace KWayland::Client;
namespace Platform {
namespace internal {
class WaylandIntegration::Private : public QObject {
public:
Private();
[[nodiscard]] Registry ®istry() {
return _registry;
}
[[nodiscard]] QEventLoop &interfacesLoop() {
return _interfacesLoop;
}
[[nodiscard]] bool interfacesAnnounced() const {
return _interfacesAnnounced;
}
private:
ConnectionThread _connection;
Registry _registry;
QEventLoop _interfacesLoop;
bool _interfacesAnnounced = false;
};
WaylandIntegration::Private::Private() {
connect(&_connection, &ConnectionThread::connected, [=] {
LOG(("Successfully connected to Wayland server at socket: %1")
.arg(_connection.socketName()));
_registry.create(&_connection);
_registry.setup();
});
connect(
&_connection,
&ConnectionThread::connectionDied,
&_registry,
&Registry::destroy);
connect(&_registry, &Registry::interfacesAnnounced, [=] {
_interfacesAnnounced = true;
if (_interfacesLoop.isRunning()) {
_interfacesLoop.quit();
}
});
_connection.initConnection();
}
WaylandIntegration::WaylandIntegration()
: _private(std::make_unique<Private>()) {
}
WaylandIntegration::~WaylandIntegration() = default;
WaylandIntegration *WaylandIntegration::Instance() {
if (!IsWayland()) return nullptr;
static WaylandIntegration instance;
return &instance;
}
void WaylandIntegration::waitForInterfaceAnnounce() {
Expects(!_private->interfacesLoop().isRunning());
if (!_private->interfacesAnnounced()) {
_private->interfacesLoop().exec();
}
}
bool WaylandIntegration::supportsXdgDecoration() {
return _private->registry().hasInterface(
Registry::Interface::XdgDecorationUnstableV1);
}
} // namespace internal
} // namespace Platform
|