From d8e37e4b03f9c786e1cb3dda80b050f05f974752 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Wed, 9 May 2018 22:57:53 +0200 Subject: [PATCH] Move wl-shell to a plugin [ChangeLog][QPA plugin] The wl-shell shell integration has been moved to a plugin. This also adds API so shell integrations can return native resources for windows, as it was needed in order to continue to supporting wl_shell_surface. Change-Id: Ibc68ffcc5b0c6993d8f4e078f663e4d67340e1a5 Reviewed-by: Paul Olav Tvete --- src/plugins/platforms/wayland/client.pro | 4 -- .../shellintegration/shellintegration.pro | 4 +- .../shellintegration/wl-shell/main.cpp | 69 +++++++++++++++++++ .../wl-shell}/qwaylandwlshellintegration.cpp | 43 ++++++------ .../wl-shell}/qwaylandwlshellintegration_p.h | 5 +- .../wl-shell}/qwaylandwlshellsurface.cpp | 16 ++--- .../wl-shell}/qwaylandwlshellsurface_p.h | 0 .../shellintegration/wl-shell/wl-shell.json | 3 + .../shellintegration/wl-shell/wl-shell.pro | 23 +++++++ .../platforms/wayland/qwaylanddisplay.cpp | 1 - .../platforms/wayland/qwaylanddisplay_p.h | 2 +- .../platforms/wayland/qwaylandintegration.cpp | 5 +- .../wayland/qwaylandnativeinterface.cpp | 15 ++-- .../platforms/wayland/qwaylandwindow.cpp | 1 - .../qwaylandshellintegration_p.h | 5 ++ 15 files changed, 142 insertions(+), 54 deletions(-) create mode 100644 src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/main.cpp rename src/plugins/platforms/wayland/{ => plugins/shellintegration/wl-shell}/qwaylandwlshellintegration.cpp (78%) rename src/plugins/platforms/wayland/{ => plugins/shellintegration/wl-shell}/qwaylandwlshellintegration_p.h (95%) rename src/plugins/platforms/wayland/{ => plugins/shellintegration/wl-shell}/qwaylandwlshellsurface.cpp (94%) rename src/plugins/platforms/wayland/{ => plugins/shellintegration/wl-shell}/qwaylandwlshellsurface_p.h (100%) create mode 100644 src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/wl-shell.json create mode 100644 src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/wl-shell.pro diff --git a/src/plugins/platforms/wayland/client.pro b/src/plugins/platforms/wayland/client.pro index 1bcd6780c5b..b1457004667 100644 --- a/src/plugins/platforms/wayland/client.pro +++ b/src/plugins/platforms/wayland/client.pro @@ -42,8 +42,6 @@ SOURCES += qwaylandintegration.cpp \ qwaylandscreen.cpp \ qwaylandshmwindow.cpp \ qwaylandshellsurface.cpp \ - qwaylandwlshellsurface.cpp \ - qwaylandwlshellintegration.cpp \ qwaylandxdgshellv6.cpp \ qwaylandxdgshellv6integration.cpp \ qwaylandextendedsurface.cpp \ @@ -71,8 +69,6 @@ HEADERS += qwaylandintegration_p.h \ qwaylandbuffer_p.h \ qwaylandshmwindow_p.h \ qwaylandshellsurface_p.h \ - qwaylandwlshellsurface_p.h \ - qwaylandwlshellintegration_p.h \ qwaylandxdgshellv6_p.h \ qwaylandxdgshellv6integration_p.h \ qwaylandextendedsurface_p.h \ diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/shellintegration.pro b/src/plugins/platforms/wayland/plugins/shellintegration/shellintegration.pro index 7f465d61b4c..12a900db253 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/shellintegration.pro +++ b/src/plugins/platforms/wayland/plugins/shellintegration/shellintegration.pro @@ -2,4 +2,6 @@ TEMPLATE = subdirs SUBDIRS += \ ivi-shell \ - xdg-shell-v5 + xdg-shell-v5 \ + wl-shell \ + diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/main.cpp b/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/main.cpp new file mode 100644 index 00000000000..9b033b5f33a --- /dev/null +++ b/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/main.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Copyright (C) 2017 ITAGE Corporation, author: +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandwlshellintegration_p.h" + +#include + +QT_BEGIN_NAMESPACE + +namespace QtWaylandClient { + +class QWaylandWlShellIntegrationPlugin : public QWaylandShellIntegrationPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID QWaylandShellIntegrationFactoryInterface_iid FILE "wl-shell.json") + +public: + QWaylandShellIntegration *create(const QString &key, const QStringList ¶mList) override; +}; + +QWaylandShellIntegration *QWaylandWlShellIntegrationPlugin::create(const QString &key, const QStringList ¶mList) +{ + Q_UNUSED(key); + Q_UNUSED(paramList); + return new QWaylandWlShellIntegration(); +} + +} + +QT_END_NAMESPACE + +#include "main.moc" diff --git a/src/plugins/platforms/wayland/qwaylandwlshellintegration.cpp b/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp similarity index 78% rename from src/plugins/platforms/wayland/qwaylandwlshellintegration.cpp rename to src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp index c76628420c0..be156dad21b 100644 --- a/src/plugins/platforms/wayland/qwaylandwlshellintegration.cpp +++ b/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp @@ -38,29 +38,16 @@ ****************************************************************************/ #include "qwaylandwlshellintegration_p.h" +#include "qwaylandwlshellsurface_p.h" #include #include -#include QT_BEGIN_NAMESPACE namespace QtWaylandClient { -QWaylandWlShellIntegration *QWaylandWlShellIntegration::create(QWaylandDisplay *display) -{ - if (!display->hasRegistryGlobal(QLatin1String("wl_shell"))) - return nullptr; - - QScopedPointer integration; - integration.reset(new QWaylandWlShellIntegration(display)); - if (integration && !integration->initialize(display)) - return nullptr; - - return integration.take(); -} - -QWaylandWlShellIntegration::QWaylandWlShellIntegration(QWaylandDisplay *display) +bool QWaylandWlShellIntegration::initialize(QWaylandDisplay *display) { Q_FOREACH (QWaylandDisplay::RegistryGlobal global, display->globals()) { if (global.interface == QLatin1String("wl_shell")) { @@ -68,19 +55,33 @@ QWaylandWlShellIntegration::QWaylandWlShellIntegration(QWaylandDisplay *display) break; } } -} -bool QWaylandWlShellIntegration::initialize(QWaylandDisplay *display) -{ - QWaylandShellIntegration::initialize(display); - return m_wlShell != nullptr; -}; + if (!m_wlShell) { + qCDebug(lcQpaWayland) << "Couldn't find global wl_shell"; + return false; + } + + return QWaylandShellIntegration::initialize(display); +} QWaylandShellSurface *QWaylandWlShellIntegration::createShellSurface(QWaylandWindow *window) { return new QWaylandWlShellSurface(m_wlShell->get_shell_surface(window->object()), window); } +void *QWaylandWlShellIntegration::nativeResourceForWindow(const QByteArray &resource, QWindow *window) +{ + QByteArray lowerCaseResource = resource.toLower(); + if (lowerCaseResource == "wl_shell_surface") { + if (auto waylandWindow = static_cast(window->handle())) { + if (auto shellSurface = qobject_cast(waylandWindow->shellSurface())) { + return shellSurface->object(); + } + } + } + return nullptr; } +} // namespace QtWaylandClient + QT_END_NAMESPACE diff --git a/src/plugins/platforms/wayland/qwaylandwlshellintegration_p.h b/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellintegration_p.h similarity index 95% rename from src/plugins/platforms/wayland/qwaylandwlshellintegration_p.h rename to src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellintegration_p.h index 7a6b53524a9..80a7507d4b5 100644 --- a/src/plugins/platforms/wayland/qwaylandwlshellintegration_p.h +++ b/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellintegration_p.h @@ -63,13 +63,12 @@ namespace QtWaylandClient { class Q_WAYLAND_CLIENT_EXPORT QWaylandWlShellIntegration : public QWaylandShellIntegration { public: - static QWaylandWlShellIntegration *create(QWaylandDisplay* display); + QWaylandWlShellIntegration() {} bool initialize(QWaylandDisplay *) override; QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override; + void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) override; private: - QWaylandWlShellIntegration(QWaylandDisplay* display); - QtWayland::wl_shell *m_wlShell = nullptr; }; diff --git a/src/plugins/platforms/wayland/qwaylandwlshellsurface.cpp b/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellsurface.cpp similarity index 94% rename from src/plugins/platforms/wayland/qwaylandwlshellsurface.cpp rename to src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellsurface.cpp index 3601fd43765..9f2bcc00c10 100644 --- a/src/plugins/platforms/wayland/qwaylandwlshellsurface.cpp +++ b/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellsurface.cpp @@ -39,12 +39,12 @@ #include "qwaylandwlshellsurface_p.h" -#include "qwaylanddisplay_p.h" -#include "qwaylandwindow_p.h" -#include "qwaylandinputdevice_p.h" -#include "qwaylandabstractdecoration_p.h" -#include "qwaylandscreen_p.h" -#include "qwaylandextendedsurface_p.h" +#include +#include +#include +#include +#include +#include #include @@ -229,11 +229,11 @@ void QWaylandWlShellSurface::setPopup(QWaylandWindow *parent, QWaylandInputDevic { QWaylandWindow *parent_wayland_window = parent; if (!parent_wayland_window) { - qWarning("setPopup called without parent window"); + qCWarning(lcQpaWayland) << "setPopup called without a parent window"; return; } if (!device) { - qWarning("setPopup called without input device"); + qCWarning(lcQpaWayland) << "setPopup called without an input device"; return; } diff --git a/src/plugins/platforms/wayland/qwaylandwlshellsurface_p.h b/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h similarity index 100% rename from src/plugins/platforms/wayland/qwaylandwlshellsurface_p.h rename to src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/wl-shell.json b/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/wl-shell.json new file mode 100644 index 00000000000..1859bb58ad0 --- /dev/null +++ b/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/wl-shell.json @@ -0,0 +1,3 @@ +{ + "Keys":[ "wl-shell" ] +} diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/wl-shell.pro b/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/wl-shell.pro new file mode 100644 index 00000000000..211dc876f8e --- /dev/null +++ b/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/wl-shell.pro @@ -0,0 +1,23 @@ +QT += gui-private waylandclient-private +CONFIG += wayland-scanner + +QMAKE_USE += wayland-client + +WAYLANDCLIENTSOURCES += \ + ../../../3rdparty/protocol/wayland.xml + +HEADERS += \ + qwaylandwlshellintegration_p.h \ + qwaylandwlshellsurface_p.h \ + +SOURCES += \ + main.cpp \ + qwaylandwlshellintegration.cpp \ + qwaylandwlshellsurface.cpp \ + +OTHER_FILES += \ + wl-shell.json + +PLUGIN_TYPE = wayland-shell-integration +PLUGIN_CLASS_NAME = QWaylandWlShellIntegrationPlugin +load(qt_plugin) diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index 0199e169d73..946e99bc89b 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -51,7 +51,6 @@ #include "qwaylanddatadevicemanager_p.h" #endif #include "qwaylandhardwareintegration_p.h" -#include "qwaylandwlshellsurface_p.h" #include "qwaylandinputcontext_p.h" #include "qwaylandwindowmanagerintegration_p.h" diff --git a/src/plugins/platforms/wayland/qwaylanddisplay_p.h b/src/plugins/platforms/wayland/qwaylanddisplay_p.h index 72f8444e0d3..d39e561f641 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay_p.h +++ b/src/plugins/platforms/wayland/qwaylanddisplay_p.h @@ -80,7 +80,7 @@ namespace QtWayland { namespace QtWaylandClient { -Q_DECLARE_LOGGING_CATEGORY(lcQpaWayland); +Q_WAYLAND_CLIENT_EXPORT Q_DECLARE_LOGGING_CATEGORY(lcQpaWayland); class QWaylandInputDevice; class QWaylandBuffer; diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index 2a169aca652..fbfdd57f48b 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -77,7 +77,6 @@ #include "qwaylandshellintegration_p.h" #include "qwaylandshellintegrationfactory_p.h" -#include "qwaylandwlshellintegration_p.h" #include "qwaylandxdgshellv6integration_p.h" #include "qwaylandinputdeviceintegration_p.h" @@ -442,9 +441,7 @@ void QWaylandIntegration::initializeInputDeviceIntegration() QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName) { - if (integrationName == QLatin1Literal("wl-shell")) { - return QWaylandWlShellIntegration::create(mDisplay.data()); - } else if (integrationName == QLatin1Literal("xdg-shell-v6")) { + if (integrationName == QLatin1Literal("xdg-shell-v6")) { return QWaylandXdgShellV6Integration::create(mDisplay.data()); } else if (QWaylandShellIntegrationFactory::keys().contains(integrationName)) { return QWaylandShellIntegrationFactory::create(integrationName, mDisplay.data()); diff --git a/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp b/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp index 9946c323567..76acb526bf3 100644 --- a/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp +++ b/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp @@ -40,13 +40,13 @@ #include "qwaylandnativeinterface_p.h" #include "qwaylanddisplay_p.h" #include "qwaylandwindow_p.h" +#include "qwaylandshellintegration_p.h" #include "qwaylandsubsurface_p.h" #include "qwaylandextendedsurface_p.h" #include "qwaylandintegration_p.h" #include "qwaylanddisplay_p.h" #include "qwaylandwindowmanagerintegration_p.h" #include "qwaylandscreen_p.h" -#include "qwaylandwlshellsurface_p.h" #include #include #include @@ -91,18 +91,13 @@ void *QWaylandNativeInterface::nativeResourceForWindow(const QByteArray &resourc QWaylandWindow *w = static_cast(window->handle()); return w ? w->object() : nullptr; } - if (lowerCaseResource == "wl_shell_surface") { - QWaylandWindow *w = static_cast(window->handle()); - if (!w) - return nullptr; - QWaylandWlShellSurface *s = qobject_cast(w->shellSurface()); - if (!s) - return nullptr; - return s->object(); - } + if (lowerCaseResource == "egldisplay" && m_integration->clientBufferIntegration()) return m_integration->clientBufferIntegration()->nativeResource(QWaylandClientBufferIntegration::EglDisplay); + if (auto shellIntegration = m_integration->shellIntegration()) + return shellIntegration->nativeResourceForWindow(resourceString, window); + return nullptr; } diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 45f9a19b2fd..ef49e8ea8c8 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -44,7 +44,6 @@ #include "qwaylandinputdevice_p.h" #include "qwaylandscreen_p.h" #include "qwaylandshellsurface_p.h" -#include "qwaylandwlshellsurface_p.h" #include "qwaylandsubsurface_p.h" #include "qwaylandabstractdecoration_p.h" #include "qwaylandwindowmanagerintegration_p.h" diff --git a/src/plugins/platforms/wayland/shellintegration/qwaylandshellintegration_p.h b/src/plugins/platforms/wayland/shellintegration/qwaylandshellintegration_p.h index 7f3a2cefcfd..ccad0048192 100644 --- a/src/plugins/platforms/wayland/shellintegration/qwaylandshellintegration_p.h +++ b/src/plugins/platforms/wayland/shellintegration/qwaylandshellintegration_p.h @@ -79,6 +79,11 @@ public: if (oldFocus) m_display->handleWindowDeactivated(oldFocus); } + virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) { + Q_UNUSED(resource); + Q_UNUSED(window); + return nullptr; + } protected: QWaylandDisplay *m_display = nullptr;