From ddd7481a6aba6c6ee6bf47739941c58c925d05f8 Mon Sep 17 00:00:00 2001 From: Martin Zielinski Date: Mon, 4 Jul 2011 09:54:42 +0200 Subject: [PATCH] Correct authentication behavior The authentication of clients via windowmanager-token is now more robust. This is needed to get the app-booster usecase working correctly. --- src/qt-compositor/wayland_wrapper/wlcompositor.cpp | 21 ++++++++++++++------- src/qt-compositor/wayland_wrapper/wlcompositor.h | 2 ++ src/qt-compositor/wayland_wrapper/wlsurface.cpp | 8 +------- src/qt-compositor/wayland_wrapper/wlsurface.h | 1 - .../waylandwindowmanagerintegration.cpp | 6 ++++++ .../waylandwindowmanagerintegration.h | 9 ++++++++- 6 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/qt-compositor/wayland_wrapper/wlcompositor.cpp b/src/qt-compositor/wayland_wrapper/wlcompositor.cpp index 9522001..65c074f 100644 --- a/src/qt-compositor/wayland_wrapper/wlcompositor.cpp +++ b/src/qt-compositor/wayland_wrapper/wlcompositor.cpp @@ -268,14 +268,7 @@ void Compositor::createSurface(struct wl_client *client, int id) addClientResource(client, &surface->base()->resource, id, &wl_surface_interface, &surface_interface, destroy_surface); - 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_windowManagerWaylandProtocol->updateOrientation(client); - } - m_qt_compositor->surfaceCreated(surface->handle()); QList prevClientList = clients(); @@ -332,6 +325,7 @@ void Compositor::processWaylandEvents() fprintf(stderr, "wl_event_loop_dispatch error: %d\n", ret); } + void Compositor::surfaceDestroyed(Surface *surface) { m_surfaces.removeOne(surface); @@ -456,3 +450,16 @@ wl_input_device * Wayland::Compositor::defaultInputDevice() { return &m_input; } + +QList Wayland::Compositor::surfacesForClient(wl_client *client) +{ + QList ret; + + for (int i=0; i < m_surfaces.count(); ++i) { + if (m_surfaces.at(i)->clientHandle() == client) { + ret.append(m_surfaces.at(i)); + } + } + return ret; +} + diff --git a/src/qt-compositor/wayland_wrapper/wlcompositor.h b/src/qt-compositor/wayland_wrapper/wlcompositor.h index 21a4109..be63a94 100644 --- a/src/qt-compositor/wayland_wrapper/wlcompositor.h +++ b/src/qt-compositor/wayland_wrapper/wlcompositor.h @@ -96,6 +96,8 @@ public: bool setDirectRenderSurface(Surface *surface); Surface *directRenderSurface() const {return m_directRenderSurface;} + QList surfacesForClient(wl_client* client); + wl_input_device *defaultInputDevice(); WaylandCompositor *qtCompositor() const { return m_qt_compositor; } diff --git a/src/qt-compositor/wayland_wrapper/wlsurface.cpp b/src/qt-compositor/wayland_wrapper/wlsurface.cpp index 52d793e..d653a82 100644 --- a/src/qt-compositor/wayland_wrapper/wlsurface.cpp +++ b/src/qt-compositor/wayland_wrapper/wlsurface.cpp @@ -270,13 +270,7 @@ void Surface::setProcessId(qint64 processId) QByteArray Surface::authenticationToken() const { Q_D(const Surface); - return d->authenticationToken; -} - -void Surface::setAuthenticationToken(const QByteArray &authenticationToken) -{ - Q_D(Surface); - d->authenticationToken = authenticationToken; + return WindowManagerServerIntegration::instance()->managedClient(d->client)->authenticationToken(); } uint32_t toWaylandButton(Qt::MouseButton button) diff --git a/src/qt-compositor/wayland_wrapper/wlsurface.h b/src/qt-compositor/wayland_wrapper/wlsurface.h index 2a699a9..ed6e0aa 100644 --- a/src/qt-compositor/wayland_wrapper/wlsurface.h +++ b/src/qt-compositor/wayland_wrapper/wlsurface.h @@ -105,7 +105,6 @@ public: qint64 processId() const; void setProcessId(qint64 processId); QByteArray authenticationToken() const; - void setAuthenticationToken(const QByteArray &authenticationToken); void setSurfaceCreationFinished(bool isCreated); diff --git a/src/qt-compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp b/src/qt-compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp index de3ca8c..5fb9ea0 100644 --- a/src/qt-compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp +++ b/src/qt-compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp @@ -61,11 +61,13 @@ public: void mapClientToProcess(wl_client *client, uint32_t processId) { + //qDebug() << "COMPOSITOR:" << Q_FUNC_INFO << client << processId; WindowManagerServerIntegration::instance()->mapClientToProcess(client, processId); } void authenticateWithToken(wl_client *client, const char *authenticationToken) { + //qDebug() << "COMPOSITOR:" << Q_FUNC_INFO << client << authenticationToken; WindowManagerServerIntegration::instance()->authenticateWithToken(client, authenticationToken); } @@ -122,9 +124,13 @@ void WindowManagerServerIntegration::mapClientToProcess(wl_client *client, uint3 void WindowManagerServerIntegration::authenticateWithToken(wl_client *client, const char *token) { + Q_ASSERT(token != 0 && *token != 0); + WaylandManagedClient *managedClient = m_managedClients.value(client, new WaylandManagedClient); managedClient->m_authenticationToken = QByteArray(token); m_managedClients.insert(client, managedClient); + + emit clientAuthenticated(client); } void WindowManagerServerIntegration::changeScreenVisibility(wl_client *client, int visible) diff --git a/src/qt-compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h b/src/qt-compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h index 199c96b..be7c609 100644 --- a/src/qt-compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h +++ b/src/qt-compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h @@ -44,7 +44,6 @@ #include #include -#include "wayland_wrapper/wldisplay.h" #include #include @@ -52,6 +51,10 @@ struct wl_client; +namespace Wayland { + class Display; +} + class WindowManagerObject; class WaylandManagedClient; @@ -70,6 +73,10 @@ public: void setScreenOrientation(wl_client *client, qint32 orientationInDegrees); void updateOrientation(wl_client *client); + +signals: + void clientAuthenticated(wl_client *client); + private: void mapClientToProcess(wl_client *client, uint32_t processId); void authenticateWithToken(wl_client *client, const char *token); -- 2.7.4