From 936eaaf0abce769348d1417e0f4318b0f58bd35a Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Tue, 25 Nov 2014 15:20:33 +0100 Subject: [PATCH 1/6] Make QWaylandShellSurface a QObject to allow build without RTTI dynamic_cast can not be used when RTTI is disabled, so make QWaylandShellSurface a QObject. QWaylandWlShellSurface and QWaylandXdgSurface must also inherit from QWaylandShellSurface first, to properly inherit from QObject. Change-Id: I2addb8105a0fe61615d4bc905414f7ee7277029f Reviewed-by: Giulio Camuffo --- src/plugins/platforms/wayland/qwaylandshellsurface_p.h | 4 +++- src/plugins/platforms/wayland/qwaylandwindow.cpp | 4 ++-- src/plugins/platforms/wayland/qwaylandwlshellsurface_p.h | 5 +++-- src/plugins/platforms/wayland/qwaylandxdgsurface_p.h | 5 +++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandshellsurface_p.h b/src/plugins/platforms/wayland/qwaylandshellsurface_p.h index 6f2336162c2..1f2346a9b59 100644 --- a/src/plugins/platforms/wayland/qwaylandshellsurface_p.h +++ b/src/plugins/platforms/wayland/qwaylandshellsurface_p.h @@ -43,6 +43,7 @@ #define QWAYLANDSHELLSURFACE_H #include +#include #include @@ -56,8 +57,9 @@ class QWaylandWindow; class QWaylandInputDevice; class QWindow; -class Q_WAYLAND_CLIENT_EXPORT QWaylandShellSurface +class Q_WAYLAND_CLIENT_EXPORT QWaylandShellSurface : public QObject { + Q_OBJECT public: explicit QWaylandShellSurface(QWaylandWindow *window); virtual ~QWaylandShellSurface() {} diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 976ebba15c3..1b939726f03 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -232,7 +232,7 @@ void QWaylandWindow::setVisible(bool visible) parent = mDisplay->lastInputWindow(); } if (parent) { - QWaylandWlShellSurface *wlshellSurface = dynamic_cast(mShellSurface); + QWaylandWlShellSurface *wlshellSurface = qobject_cast(mShellSurface); if (wlshellSurface) wlshellSurface->setPopup(parent, mDisplay->lastInputDevice(), mDisplay->lastInputSerial()); } @@ -481,7 +481,7 @@ bool QWaylandWindow::createDecoration() { // so far only xdg-shell support this "unminimize" trick, may be moved elsewhere if (mState == Qt::WindowMinimized) { - QWaylandXdgSurface *xdgSurface = dynamic_cast(mShellSurface); + QWaylandXdgSurface *xdgSurface = qobject_cast(mShellSurface); if ( xdgSurface ) { if (xdgSurface->isFullscreen()) { setWindowStateInternal(Qt::WindowFullScreen); diff --git a/src/plugins/platforms/wayland/qwaylandwlshellsurface_p.h b/src/plugins/platforms/wayland/qwaylandwlshellsurface_p.h index 8d6e298b9da..c9b8ac942b3 100644 --- a/src/plugins/platforms/wayland/qwaylandwlshellsurface_p.h +++ b/src/plugins/platforms/wayland/qwaylandwlshellsurface_p.h @@ -57,9 +57,10 @@ class QWaylandInputDevice; class QWindow; class QWaylandExtendedSurface; -class Q_WAYLAND_CLIENT_EXPORT QWaylandWlShellSurface : public QtWayland::wl_shell_surface - , public QWaylandShellSurface +class Q_WAYLAND_CLIENT_EXPORT QWaylandWlShellSurface : public QWaylandShellSurface + , public QtWayland::wl_shell_surface { + Q_OBJECT public: QWaylandWlShellSurface(struct ::wl_shell_surface *shell_surface, QWaylandWindow *window); virtual ~QWaylandWlShellSurface(); diff --git a/src/plugins/platforms/wayland/qwaylandxdgsurface_p.h b/src/plugins/platforms/wayland/qwaylandxdgsurface_p.h index 635c9496a7e..f287157070d 100644 --- a/src/plugins/platforms/wayland/qwaylandxdgsurface_p.h +++ b/src/plugins/platforms/wayland/qwaylandxdgsurface_p.h @@ -57,9 +57,10 @@ class QWaylandInputDevice; class QWindow; class QWaylandExtendedSurface; -class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgSurface : public QtWayland::xdg_surface - , public QWaylandShellSurface +class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgSurface : public QWaylandShellSurface + , public QtWayland::xdg_surface { + Q_OBJECT public: QWaylandXdgSurface(struct ::xdg_surface *shell_surface, QWaylandWindow *window); virtual ~QWaylandXdgSurface(); From babb58933fc1f279c9746749d11d537711526d7b Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Wed, 10 Dec 2014 14:22:48 +0100 Subject: [PATCH 2/6] Remove useless EGL linking in plugins EGL libs are already linked from the hardwareintegration pri file, and the plugins do not make direct use of any EGL symbol. Change-Id: If6ecfee16e8c9d8fee67f03419941ced92d1eff8 Reviewed-by: Giulio Camuffo --- .../wayland/plugins/hardwareintegration/brcm-egl/brcm-egl.pro | 2 -- .../hardwareintegration/drm-egl-server/drm-egl-server.pro | 2 -- .../libhybris-egl-server/libhybris-egl-server.pro | 2 -- 3 files changed, 6 deletions(-) diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/brcm-egl/brcm-egl.pro b/src/plugins/platforms/wayland/plugins/hardwareintegration/brcm-egl/brcm-egl.pro index 39dcf570dec..6dbe53732ed 100644 --- a/src/plugins/platforms/wayland/plugins/hardwareintegration/brcm-egl/brcm-egl.pro +++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/brcm-egl/brcm-egl.pro @@ -5,8 +5,6 @@ QT += waylandclient-private include(../../../../hardwareintegration/client/brcm-egl/brcm-egl.pri) -LIBS += -lEGL - OTHER_FILES += \ brcm-egl.json diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/drm-egl-server/drm-egl-server.pro b/src/plugins/platforms/wayland/plugins/hardwareintegration/drm-egl-server/drm-egl-server.pro index 3a57958683d..0aba49dddf9 100644 --- a/src/plugins/platforms/wayland/plugins/hardwareintegration/drm-egl-server/drm-egl-server.pro +++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/drm-egl-server/drm-egl-server.pro @@ -5,8 +5,6 @@ QT += waylandclient-private include(../../../../hardwareintegration/client/drm-egl-server/drm-egl-server.pri) -LIBS += -lEGL - OTHER_FILES += \ drm-egl-server.json diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/libhybris-egl-server/libhybris-egl-server.pro b/src/plugins/platforms/wayland/plugins/hardwareintegration/libhybris-egl-server/libhybris-egl-server.pro index 6af6d5c10da..55f98415d58 100644 --- a/src/plugins/platforms/wayland/plugins/hardwareintegration/libhybris-egl-server/libhybris-egl-server.pro +++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/libhybris-egl-server/libhybris-egl-server.pro @@ -5,8 +5,6 @@ QT += waylandclient-private include(../../../../hardwareintegration/client/libhybris-egl-server/libhybris-egl-server.pri) -LIBS += -lEGL - OTHER_FILES += \ libhybris-egl-server.json From 43c14e514d8c7275b51e48925b6c3a48e90b38b0 Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Fri, 5 Dec 2014 14:27:06 +0100 Subject: [PATCH 3/6] Fix shm buffers init and destruction on failure Some pointers need to be initialized in QWaylandBuffer and QWaylandShmBuffer, and checked at destruction. This avoids crashes when shm surface creation fails. Change-Id: I6f6afa3cc6c67533b5130700cbc27b271764109e Reviewed-by: Giulio Camuffo --- src/plugins/platforms/wayland/qwaylandbuffer_p.h | 5 ++++- .../platforms/wayland/qwaylandshmbackingstore.cpp | 12 ++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandbuffer_p.h b/src/plugins/platforms/wayland/qwaylandbuffer_p.h index 2bb9990f3dd..6d2bb66b392 100644 --- a/src/plugins/platforms/wayland/qwaylandbuffer_p.h +++ b/src/plugins/platforms/wayland/qwaylandbuffer_p.h @@ -54,7 +54,10 @@ QT_BEGIN_NAMESPACE class Q_WAYLAND_CLIENT_EXPORT QWaylandBuffer { public: - QWaylandBuffer() { } + QWaylandBuffer() + : mBuffer(0) + { + } virtual ~QWaylandBuffer() { } wl_buffer *buffer() {return mBuffer;} virtual QSize size() const = 0; diff --git a/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp b/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp index 6ca65f053aa..598e9f16079 100644 --- a/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp +++ b/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp @@ -58,7 +58,8 @@ QT_BEGIN_NAMESPACE QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display, const QSize &size, QImage::Format format) - : mMarginsImage(0) + : mShmPool(0) + , mMarginsImage(0) { int stride = size.width() * 4; int alloc = stride * size.height(); @@ -97,9 +98,12 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display, QWaylandShmBuffer::~QWaylandShmBuffer(void) { delete mMarginsImage; - munmap((void *) mImage.constBits(), mImage.byteCount()); - wl_buffer_destroy(mBuffer); - wl_shm_pool_destroy(mShmPool); + if (mImage.constBits()) + munmap((void *) mImage.constBits(), mImage.byteCount()); + if (mBuffer) + wl_buffer_destroy(mBuffer); + if (mShmPool) + wl_shm_pool_destroy(mShmPool); } QImage *QWaylandShmBuffer::imageInsideMargins(const QMargins &margins) From 5c897fb1ab364f6623d96c80d05c15c06fcec6ce Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Tue, 9 Dec 2014 13:24:49 +0100 Subject: [PATCH 4/6] Drop unused mScreensInitialized variable in QWaylandDisplay Unused since commit 78a701272e68d4f0ab95df4062374b8d34ef2919: Made wayland plugin single-threaded, yay :) Change-Id: I1fae78d77179feaac79f5dba6dcad8084e3e97fa Reviewed-by: Pier Luigi Fiorini Reviewed-by: Giulio Camuffo --- src/plugins/platforms/wayland/qwaylanddisplay_p.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/platforms/wayland/qwaylanddisplay_p.h b/src/plugins/platforms/wayland/qwaylanddisplay_p.h index d9619e6f1f5..5a32413e4c8 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay_p.h +++ b/src/plugins/platforms/wayland/qwaylanddisplay_p.h @@ -202,7 +202,6 @@ private: QSocketNotifier *mReadNotifier; int mFd; int mWritableNotificationFd; - bool mScreensInitialized; QList mGlobals; int mCompositorVersion; uint32_t mLastInputSerial; From f9ad726e65a7aea6de2863b7907cb52bcc026fca Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Sun, 29 Mar 2015 11:33:34 +0300 Subject: [PATCH 5/6] Don't handle mouse events in decos if buttons were pressed in the content area MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the decorations stealing the mouse events when going outside the content area. Change-Id: I8f3592fbda6b9c1da6498d74820a73be11c6999d Reviewed-by: Jørgen Lind --- src/plugins/platforms/wayland/qwaylandwindow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 1b939726f03..ca0fa513972 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -619,7 +619,8 @@ bool QWaylandWindow::touchDragDecoration(QWaylandInputDevice *inputDevice, const void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDevice, ulong timestamp, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods) { - if (mWindowDecoration->handleMouse(inputDevice,local,global,b,mods)) + if (mMousePressedInContentArea == Qt::NoButton && + mWindowDecoration->handleMouse(inputDevice,local,global,b,mods)) return; QMargins marg = frameMargins(); From be73094e6e6df055e183f71dffb12bd9dd4189bd Mon Sep 17 00:00:00 2001 From: Pier Luigi Fiorini Date: Thu, 22 Jan 2015 08:13:08 +0100 Subject: [PATCH 6/6] Remove .desktop suffix to appId The appId is the desktop entry identifier. According to the desktop entry specifications [1], for applications the part of the name should follow the reverse DNS convention (see [2]). To do this we use the application domain if available, otherwise for lack of information we fall back to the executable base name like other toolkits such as Gtk+ do. [1] http://standards.freedesktop.org/desktop-entry-spec/latest/ [2] http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s02.html Change-Id: I181ad23a9736844e07e8060d78e756a943c27f67 Reviewed-by: Giulio Camuffo --- .../platforms/wayland/qwaylandwindow.cpp | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index ca0fa513972..83c44c25dbb 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -107,10 +107,24 @@ QWaylandWindow::QWaylandWindow(QWindow *window) // Set initial surface title mShellSurface->setTitle(window->title()); - // Set surface class to the .desktop file name (obtained from executable name) - QFileInfo exeFileInfo(qApp->applicationFilePath()); - QString className = exeFileInfo.baseName() + QLatin1String(".desktop"); - mShellSurface->setAppId(className); + // The appId is the desktop entry identifier that should follow the + // reverse DNS convention (see http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s02.html), + // use the application domain if available, otherwise the executable base name. + // According to xdg-shell the appId is only the name, without the .desktop suffix. + QFileInfo fi = QCoreApplication::instance()->applicationFilePath(); + QStringList domainName = + QCoreApplication::instance()->organizationDomain().split(QLatin1Char('.'), + QString::SkipEmptyParts); + + if (domainName.isEmpty()) { + mShellSurface->setAppId(fi.baseName()); + } else { + QString appId; + for (int i = 0; i < domainName.count(); ++i) + appId.prepend(QLatin1Char('.')).prepend(domainName.at(i)); + appId.append(fi.baseName()); + mShellSurface->setAppId(appId); + } } if (QPlatformWindow::parent() && mSubSurfaceWindow) {