Add authentication token support for wayland windows
For compositors that support it, the wayland clients can associate themselves with an auth token, specified by WL_AUTHENTICATION_TOKEN env var, or by directly specifying it in the wayland client plugin. Change-Id: I74a50a27c7c61c2b2cf1e09868618f36edc94cb1 Reviewed-by: Samuel Rødal Reviewed-on: http://codereview.qt.nokia.com/116 Reviewed-by: Paul Olav Tvete <paul.tvete@nokia.com>
This commit is contained in:
parent
6fe12b0e80
commit
1909e03882
@ -140,6 +140,11 @@ QWaylandDisplay::QWaylandDisplay(void)
|
||||
#ifdef QT_WAYLAND_GL_SUPPORT
|
||||
mEglIntegration = QWaylandGLIntegration::createGLIntegration(this);
|
||||
#endif
|
||||
|
||||
#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
|
||||
mWindowManagerIntegration = QWaylandWindowManagerIntegration::createIntegration(this);
|
||||
#endif
|
||||
|
||||
blockingReadEvents();
|
||||
|
||||
qRegisterMetaType<uint32_t>("uint32_t");
|
||||
@ -148,10 +153,6 @@ QWaylandDisplay::QWaylandDisplay(void)
|
||||
mEglIntegration->initialize();
|
||||
#endif
|
||||
|
||||
#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
|
||||
mWindowManagerIntegration = QWaylandWindowManagerIntegration::createIntegration(this);
|
||||
#endif
|
||||
|
||||
connect(QAbstractEventDispatcher::instance(), SIGNAL(aboutToBlock()), this, SLOT(flushRequests()));
|
||||
|
||||
mFd = wl_display_get_fd(mDisplay, sourceUpdate, this);
|
||||
|
@ -67,6 +67,7 @@ QWaylandWindow::QWaylandWindow(QWidget *window)
|
||||
|
||||
#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
|
||||
mDisplay->windowManagerIntegration()->mapClientToProcess(qApp->applicationPid());
|
||||
mDisplay->windowManagerIntegration()->authenticateWithToken();
|
||||
#endif
|
||||
|
||||
mSurface = mDisplay->createSurface(this);
|
||||
|
@ -36,16 +36,37 @@ struct wl_client;
|
||||
|
||||
struct wl_windowmanager;
|
||||
|
||||
struct wl_proxy;
|
||||
|
||||
extern void
|
||||
wl_proxy_marshal(struct wl_proxy *p, uint32_t opcode, ...);
|
||||
extern struct wl_proxy *
|
||||
wl_proxy_create(struct wl_proxy *factory,
|
||||
const struct wl_interface *interface);
|
||||
extern struct wl_proxy *
|
||||
wl_proxy_create_for_id(struct wl_display *display,
|
||||
const struct wl_interface *interface, uint32_t id);
|
||||
extern void
|
||||
wl_proxy_destroy(struct wl_proxy *proxy);
|
||||
|
||||
extern int
|
||||
wl_proxy_add_listener(struct wl_proxy *proxy,
|
||||
void (**implementation)(void), void *data);
|
||||
|
||||
extern void
|
||||
wl_proxy_set_user_data(struct wl_proxy *proxy, void *user_data);
|
||||
|
||||
extern void *
|
||||
wl_proxy_get_user_data(struct wl_proxy *proxy);
|
||||
|
||||
extern const struct wl_interface wl_windowmanager_interface;
|
||||
|
||||
#define WL_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS 0
|
||||
#define wl_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS 0
|
||||
#define wl_WINDOWMANAGER_AUTHENTICATE_WITH_TOKEN 1
|
||||
|
||||
static inline struct wl_windowmanager *
|
||||
wl_windowmanager_create(struct wl_display *display, uint32_t id, uint32_t /*version*/)
|
||||
wl_windowmanager_create(struct wl_display *display, uint32_t id)
|
||||
{
|
||||
// ### does not run without latest wayland. must be enabled later
|
||||
//wl_display_bind(display, id, "wl_windowmanager", version);
|
||||
|
||||
return (struct wl_windowmanager *)
|
||||
wl_proxy_create_for_id(display, &wl_windowmanager_interface, id);
|
||||
}
|
||||
@ -72,7 +93,14 @@ static inline void
|
||||
wl_windowmanager_map_client_to_process(struct wl_windowmanager *wl_windowmanager, uint32_t processid)
|
||||
{
|
||||
wl_proxy_marshal((struct wl_proxy *) wl_windowmanager,
|
||||
WL_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS, processid);
|
||||
wl_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS, processid);
|
||||
}
|
||||
|
||||
static inline void
|
||||
wl_windowmanager_authenticate_with_token(struct wl_windowmanager *wl_windowmanager, const char *wl_authentication_token)
|
||||
{
|
||||
wl_proxy_marshal((struct wl_proxy *) wl_windowmanager,
|
||||
wl_WINDOWMANAGER_AUTHENTICATE_WITH_TOKEN, wl_authentication_token);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -68,12 +68,11 @@ struct wl_windowmanager *QWaylandWindowManagerIntegration::windowManager() const
|
||||
return mWaylandWindowManager;
|
||||
}
|
||||
|
||||
void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(wl_display *display, uint32_t id, const char *interface,
|
||||
uint32_t version, void *data)
|
||||
void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(wl_display *display, uint32_t id, const char *interface, uint32_t version, void *data)
|
||||
{
|
||||
if (strcmp(interface, "wl_windowmanager") == 0) {
|
||||
QWaylandWindowManagerIntegration *integration = static_cast<QWaylandWindowManagerIntegration *>(data);
|
||||
integration->mWaylandWindowManager = wl_windowmanager_create(display,id, version);
|
||||
integration->mWaylandWindowManager = wl_windowmanager_create(display, id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,3 +82,11 @@ void QWaylandWindowManagerIntegration::mapClientToProcess(long long processId)
|
||||
wl_windowmanager_map_client_to_process(mWaylandWindowManager, (uint32_t) processId);
|
||||
}
|
||||
|
||||
void QWaylandWindowManagerIntegration::authenticateWithToken(const QByteArray &token)
|
||||
{
|
||||
QByteArray authToken = token;
|
||||
if (authToken.isEmpty())
|
||||
authToken = qgetenv("WL_AUTHENTICATION_TOKEN");
|
||||
if (mWaylandWindowManager)
|
||||
wl_windowmanager_authenticate_with_token(mWaylandWindowManager, authToken.constData());
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ public:
|
||||
|
||||
void mapSurfaceToProcess(struct wl_surface *surface, long long processId);
|
||||
void mapClientToProcess(long long processId);
|
||||
void authenticateWithToken(const QByteArray &token = QByteArray());
|
||||
|
||||
private:
|
||||
static void wlHandleListenerGlobal(wl_display *display, uint32_t id,
|
||||
|
@ -26,7 +26,8 @@
|
||||
#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 = {
|
||||
|
Loading…
Reference in New Issue
Block a user