From fc9e419cabc67c33907661dfbfa5595a5896afdb Mon Sep 17 00:00:00 2001 From: Martin Zielinski Date: Mon, 4 Jul 2011 09:41:26 +0200 Subject: [PATCH] Fixed wayland windowmanager-protocol authorization The authorization is now handled more robust. The client tries to authenticate as soon as a surface is created, but does so only if the authentication token is valid. A re-authorization than happens when requestActivateWindow() is called. This is needed to get the auth-process properly working even with pre-started clients, that do not have a valid token on surface-creation time. Change-Id: I4371b424686b9d5a6a163a802ec66a33c0aeeea7 Reviewed-on: http://codereview.qt.nokia.com/1207 Reviewed-by: Qt Sanity Bot Reviewed-by: Lasse Holmstedt --- .../xcomposite_egl/qwaylandxcompositeeglwindow.cpp | 11 +++++++++++ .../xcomposite_egl/qwaylandxcompositeeglwindow.h | 1 + .../qwaylandwindowmanagerintegration.cpp | 9 ++++----- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp index 3daf5f6..1047cb8 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp @@ -40,6 +40,8 @@ ****************************************************************************/ #include "qwaylandxcompositeeglwindow.h" +#include "qwaylandxcompositeeglintegration.h" +#include "windowmanager_integration/qwaylandwindowmanagerintegration.h" #include @@ -75,3 +77,12 @@ void QWaylandXCompositeEGLWindow::setGeometry(const QRect &rect) mContext->geometryChanged(); } } + +void QWaylandXCompositeEGLWindow::requestActivateWindow() +{ +#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT + mDisplay->windowManagerIntegration()->authenticateWithToken(); +#endif + + QWaylandWindow::requestActivateWindow(); +} diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h index 7078019..ea4dd2d 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h @@ -55,6 +55,7 @@ public: QPlatformGLContext *glContext() const; void setGeometry(const QRect &rect); + void requestActivateWindow(); private: QWaylandXCompositeEGLIntegration *mGlxIntegration; diff --git a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp index 7390c52..60b0a56 100644 --- a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp +++ b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp @@ -99,19 +99,18 @@ void QWaylandWindowManagerIntegration::authenticateWithToken(const QByteArray &t QByteArray authToken = token; if (authToken.isEmpty()) authToken = qgetenv("WL_AUTHENTICATION_TOKEN"); - if (mWaylandWindowManager) + + if (mWaylandWindowManager && !authToken.isEmpty()) { wl_windowmanager_authenticate_with_token(mWaylandWindowManager, authToken.constData()); + } } void QWaylandWindowManagerIntegration::wlHandleOnScreenVisibilityChange(void *data, struct wl_windowmanager *wl_windowmanager, int visible) { Q_UNUSED(data); Q_UNUSED(wl_windowmanager); - QEvent evt(visible != 0 ? QEvent::ApplicationActivated : QEvent::ApplicationDeactivated); - + QEvent evt(visible != 0 ? QEvent::ApplicationActivate : QEvent::ApplicationDeactivate); QCoreApplication::sendEvent(QCoreApplication::instance(), &evt); - - qDebug() << "OnScreenVisibility" << (visible != 0); } void QWaylandWindowManagerIntegration::wlHandleScreenOrientationChange(void *data, struct wl_windowmanager *wl_windowmanager, int screenOrientation) -- 2.7.4