addClientResource(client, &surface->base()->resource, id, &wl_surface_interface,
&surface_interface, destroy_surface);
- quint32 processId = m_windowManagerWaylandProtocol->pidForClient(client);
- // if there is no PID, the client does not support the protocol.
- surface->setProcessId(processId);
+ WaylandManagedClient *managedClient = m_windowManagerWaylandProtocol->managedClient(client);
+ if (managedClient) {
+ // if there is no PID, the client does not support the protocol.
+ surface->setProcessId(managedClient->processId());
+ surface->setAuthenticationToken(managedClient->authenticationToken());
+ }
+
m_qt_compositor->surfaceCreated(surface->handle());
QList<struct wl_client *> prevClientList = clients();
bool textureCreatedForBuffer;
wl_buffer *directRenderBuffer;
qint64 processId;
+ QByteArray authenticationToken;
private:
struct wl_buffer *surfaceBuffer;
d->processId = processId;
}
+QByteArray Surface::authenticationToken() const
+{
+ Q_D(const Surface);
+ return d->authenticationToken;
+}
+
+void Surface::setAuthenticationToken(const QByteArray &authenticationToken)
+{
+ Q_D(Surface);
+ d->authenticationToken = authenticationToken;
+}
+
uint32_t toWaylandButton(Qt::MouseButton button)
{
switch (button) {
wl_client *clientHandle() const;
qint64 processId() const;
void setProcessId(qint64 processId);
+ QByteArray authenticationToken() const;
+ void setAuthenticationToken(const QByteArray &authenticationToken);
+
void setSurfaceCreationFinished(bool isCreated);
protected:
#include "wayland-util.h"
static const struct wl_message wl_windowmanager_requests[] = {
- { "map_client_to_process", "u", NULL },
+ { "map_client_to_process", "u" },
+ { "authenticate_with_token", "s" },
};
WL_EXPORT const struct wl_interface wl_windowmanager_interface = {
ARRAY_LENGTH(wl_windowmanager_requests), wl_windowmanager_requests,
0, NULL,
};
+
struct wl_windowmanager_interface {
void (*map_client_to_process)(struct wl_client *client,
- struct wl_windowmanager *wl_windowmanager,
+ struct wl_windowmanager *windowmanager,
uint32_t processid);
+ void (*authenticate_with_token)(struct wl_client *client,
+ struct wl_windowmanager *windowmanager,
+ const char *wl_authentication_token);
};
#ifdef __cplusplus
WindowManagerServerIntegration::instance()->mapClientToProcess(client, processId);
}
+ void authenticateWithToken(wl_client *client, const char *authenticationToken)
+ {
+ WindowManagerServerIntegration::instance()->authenticateWithToken(client, authenticationToken);
+ }
+
};
void map_client_to_process(wl_client *client, struct wl_windowmanager *windowMgr, uint32_t processId)
reinterpret_cast<WindowManagerObject *>(windowMgr)->mapClientToProcess(client, processId);
}
+void authenticate_with_token(wl_client *client, struct wl_windowmanager *windowMgr, const char *wl_authentication_token)
+{
+ reinterpret_cast<WindowManagerObject *>(windowMgr)->authenticateWithToken(client, wl_authentication_token);
+}
+
const static struct wl_windowmanager_interface windowmanager_interface = {
- map_client_to_process
+ map_client_to_process,
+ authenticate_with_token
};
WindowManagerServerIntegration *WindowManagerServerIntegration::m_instance = 0;
void WindowManagerServerIntegration::removeClient(wl_client *client)
{
- m_clientToProcessId.remove(client);
+ WaylandManagedClient *managedClient = m_managedClients.take(client);
+ delete managedClient;
}
void WindowManagerServerIntegration::mapClientToProcess(wl_client *client, uint32_t processId)
{
- m_clientToProcessId.insert(client, processId);
- emit clientMappedToProcess(client, processId);
+ WaylandManagedClient *managedClient = m_managedClients.value(client, new WaylandManagedClient);
+ managedClient->m_processId = processId;
+ m_managedClients.insert(client, managedClient);
}
+void WindowManagerServerIntegration::authenticateWithToken(wl_client *client, const char *token)
+{
+ WaylandManagedClient *managedClient = m_managedClients.value(client, new WaylandManagedClient);
+ managedClient->m_authenticationToken = QByteArray(token);
+ m_managedClients.insert(client, managedClient);
+}
-qint64 WindowManagerServerIntegration::pidForClient(wl_client *client) const
+WaylandManagedClient *WindowManagerServerIntegration::managedClient(wl_client *client) const
{
- return m_clientToProcessId.value(client, 0);
+ return m_managedClients.value(client, 0);
}
WindowManagerServerIntegration *WindowManagerServerIntegration::instance()
{
return m_instance;
}
+
+/// ///
+/// / WaylandManagedClient
+/// ///
+
+WaylandManagedClient::WaylandManagedClient()
+ : m_processId(0)
+{
+
+}
+
+qint64 WaylandManagedClient::processId() const
+{
+ return m_processId;
+}
+
+QByteArray WaylandManagedClient::authenticationToken() const
+{
+ return m_authenticationToken;
+}
struct wl_client;
class WindowManagerObject;
+class WaylandManagedClient;
class WindowManagerServerIntegration : public QObject
{
void initialize(Wayland::Display *waylandDisplay);
void removeClient(wl_client *client);
- qint64 pidForClient(wl_client *client) const;
-
-signals:
- void clientMappedToProcess(wl_client *client, quint32 processId);
+ WaylandManagedClient *managedClient(wl_client *client) const;
private:
void mapClientToProcess(wl_client *client, uint32_t processId);
+ void authenticateWithToken(wl_client *client, const char *token);
private:
- QMap<wl_client*, qint64> m_clientToProcessId;
+ QMap<wl_client*, WaylandManagedClient*> m_managedClients;
static WindowManagerServerIntegration *m_instance;
WindowManagerObject *m_windowManagerObject;
friend class WindowManagerObject;
};
+class WaylandManagedClient
+{
+public:
+ WaylandManagedClient();
+ qint64 processId() const;
+ QByteArray authenticationToken() const;
+
+private:
+ qint64 m_processId;
+ QByteArray m_authenticationToken;
+
+ friend class WindowManagerServerIntegration;
+};
+
#endif // WAYLANDWINDOWMANAGERINTEGRATION_H