Changeset View
Changeset View
Standalone View
Standalone View
waylandserver.cpp
Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Line(s) | 68 | { | |||
---|---|---|---|---|---|
83 | if (!m_allowedClient) { | 83 | if (!m_allowedClient) { | ||
84 | // failed creating the Wayland client | 84 | // failed creating the Wayland client | ||
85 | stop(); | 85 | stop(); | ||
86 | close(socketPair[0]); | 86 | close(socketPair[0]); | ||
87 | close(socketPair[1]); | 87 | close(socketPair[1]); | ||
88 | return -1; | 88 | return -1; | ||
89 | } | 89 | } | ||
90 | connect(m_allowedClient, &KWayland::Server::ClientConnection::disconnected, this, [this] { m_allowedClient = nullptr; }); | 90 | connect(m_allowedClient, &KWayland::Server::ClientConnection::disconnected, this, [this] { m_allowedClient = nullptr; }); | ||
91 | m_interface = wl_global_create(*m_display.data(), &org_kde_ksld_interface, 3, this, bind); | 91 | m_interface = wl_global_create(*m_display.data(), &org_kde_ksld_interface, 4, this, bind); | ||
92 | return socketPair[1]; | 92 | return socketPair[1]; | ||
93 | } | 93 | } | ||
94 | 94 | | |||
95 | void WaylandServer::stop() | 95 | void WaylandServer::stop() | ||
96 | { | 96 | { | ||
97 | if (m_allowedClient) { | 97 | if (m_allowedClient) { | ||
98 | m_allowedClient->destroy(); | 98 | m_allowedClient->destroy(); | ||
99 | } | 99 | } | ||
100 | if (m_interface) { | 100 | if (m_interface) { | ||
101 | wl_global_destroy(m_interface); | 101 | wl_global_destroy(m_interface); | ||
102 | m_interface = nullptr; | 102 | m_interface = nullptr; | ||
103 | } | 103 | } | ||
104 | m_display.reset(); | 104 | m_display.reset(); | ||
105 | m_allowedClient = nullptr; | 105 | m_allowedClient = nullptr; | ||
106 | } | 106 | } | ||
107 | 107 | | |||
108 | void WaylandServer::bind(wl_client *client, void *data, uint32_t version, uint32_t id) | 108 | void WaylandServer::bind(wl_client *client, void *data, uint32_t version, uint32_t id) | ||
109 | { | 109 | { | ||
110 | auto s = reinterpret_cast<WaylandServer*>(data); | 110 | auto s = reinterpret_cast<WaylandServer*>(data); | ||
111 | if (client != s->m_allowedClient->client()) { | 111 | if (client != s->m_allowedClient->client()) { | ||
112 | // a proper error would be better | 112 | // a proper error would be better | ||
113 | wl_client_post_no_memory(client); | 113 | wl_client_post_no_memory(client); | ||
114 | return; | 114 | return; | ||
115 | } | 115 | } | ||
116 | wl_resource *r = s->m_allowedClient->createResource(&org_kde_ksld_interface, qMin(version, 3u), id); | 116 | wl_resource *r = s->m_allowedClient->createResource(&org_kde_ksld_interface, qMin(version, 4u), id); | ||
117 | if (!r) { | 117 | if (!r) { | ||
118 | wl_client_post_no_memory(client); | 118 | wl_client_post_no_memory(client); | ||
119 | return; | 119 | return; | ||
120 | } | 120 | } | ||
121 | 121 | | |||
122 | static const struct org_kde_ksld_interface s_interface = { | 122 | static const struct org_kde_ksld_interface s_interface = { | ||
123 | x11WindowCallback, | 123 | x11WindowCallback, | ||
124 | suspendSystemCallback, | 124 | suspendSystemCallback, | ||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | 191 | Q_FOREACH (auto r, m_resources) { | |||
192 | if (wl_resource_get_version(r) < ORG_KDE_KSLD_OSDTEXT_SINCE_VERSION) { | 192 | if (wl_resource_get_version(r) < ORG_KDE_KSLD_OSDTEXT_SINCE_VERSION) { | ||
193 | continue; | 193 | continue; | ||
194 | } | 194 | } | ||
195 | org_kde_ksld_send_osdText(r, icon.toUtf8().constData(), additionalText.toUtf8().constData()); | 195 | org_kde_ksld_send_osdText(r, icon.toUtf8().constData(), additionalText.toUtf8().constData()); | ||
196 | m_allowedClient->flush(); | 196 | m_allowedClient->flush(); | ||
197 | } | 197 | } | ||
198 | } | 198 | } | ||
199 | 199 | | |||
200 | void WaylandServer::notify(uint id, const QString &appName, uint &replacesId, | ||||
201 | const QString &appIcon, const QString &summary, const QString &body, | ||||
202 | const QStringList &actions, const QVariantMap &hints, int timeout) | ||||
203 | { | ||||
204 | if (!m_allowedClient) { | ||||
205 | return; | ||||
206 | } | ||||
207 | Q_FOREACH (auto r, m_resources) { | ||||
208 | if (wl_resource_get_version(r) < ORG_KDE_KSLD_NOTIFY_SINCE_VERSION) { | ||||
209 | continue; | ||||
210 | } | ||||
211 | org_kde_ksld_send_notify(r, id, appName.toUtf8().constData(), replacesId, appIcon.toUtf8().constData(), | ||||
212 | summary.toUtf8().constData(), body.toUtf8().constData(), timeout); | ||||
213 | } | ||||
214 | } | ||||
215 | | ||||
200 | void WaylandServer::sendCanSuspend() | 216 | void WaylandServer::sendCanSuspend() | ||
201 | { | 217 | { | ||
202 | if (!m_allowedClient) { | 218 | if (!m_allowedClient) { | ||
203 | return; | 219 | return; | ||
204 | } | 220 | } | ||
205 | Q_FOREACH (auto r, m_resources) { | 221 | Q_FOREACH (auto r, m_resources) { | ||
206 | if (wl_resource_get_version(r) < ORG_KDE_KSLD_CANSUSPENDSYSTEM_SINCE_VERSION) { | 222 | if (wl_resource_get_version(r) < ORG_KDE_KSLD_CANSUSPENDSYSTEM_SINCE_VERSION) { | ||
207 | continue; | 223 | continue; | ||
Show All 21 Lines |