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 <paul.tvete@qt.io>
This commit is contained in:
Johan Klokkhammer Helsing 2018-05-09 22:57:53 +02:00 committed by Johan Helsing
parent ae58414530
commit d8e37e4b03
15 changed files with 142 additions and 54 deletions

View File

@ -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 \

View File

@ -2,4 +2,6 @@ TEMPLATE = subdirs
SUBDIRS += \
ivi-shell \
xdg-shell-v5
xdg-shell-v5 \
wl-shell \

View File

@ -0,0 +1,69 @@
/****************************************************************************
**
** Copyright (C) 2018 The Qt Company Ltd.
** Copyright (C) 2017 ITAGE Corporation, author: <yusuke.binsaki@itage.co.jp>
** 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 <QtWaylandClient/private/qwaylandshellintegrationplugin_p.h>
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 &paramList) override;
};
QWaylandShellIntegration *QWaylandWlShellIntegrationPlugin::create(const QString &key, const QStringList &paramList)
{
Q_UNUSED(key);
Q_UNUSED(paramList);
return new QWaylandWlShellIntegration();
}
}
QT_END_NAMESPACE
#include "main.moc"

View File

@ -38,29 +38,16 @@
****************************************************************************/
#include "qwaylandwlshellintegration_p.h"
#include "qwaylandwlshellsurface_p.h"
#include <QtWaylandClient/private/qwaylandwindow_p.h>
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
#include <QtWaylandClient/private/qwaylandwlshellsurface_p.h>
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
QWaylandWlShellIntegration *QWaylandWlShellIntegration::create(QWaylandDisplay *display)
{
if (!display->hasRegistryGlobal(QLatin1String("wl_shell")))
return nullptr;
QScopedPointer<QWaylandWlShellIntegration> 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<QWaylandWindow *>(window->handle())) {
if (auto shellSurface = qobject_cast<QWaylandWlShellSurface *>(waylandWindow->shellSurface())) {
return shellSurface->object();
}
}
}
return nullptr;
}
} // namespace QtWaylandClient
QT_END_NAMESPACE

View File

@ -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;
};

View File

@ -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 <QtWaylandClient/private/qwaylanddisplay_p.h>
#include <QtWaylandClient/private/qwaylandwindow_p.h>
#include <QtWaylandClient/private/qwaylandinputdevice_p.h>
#include <QtWaylandClient/private/qwaylandabstractdecoration_p.h>
#include <QtWaylandClient/private/qwaylandscreen_p.h>
#include <QtWaylandClient/private/qwaylandextendedsurface_p.h>
#include <QtCore/QDebug>
@ -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;
}

View File

@ -0,0 +1,3 @@
{
"Keys":[ "wl-shell" ]
}

View File

@ -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)

View File

@ -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"

View File

@ -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;

View File

@ -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());

View File

@ -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 <QtGui/private/qguiapplication_p.h>
#include <QtGui/QScreen>
#include <QtWaylandClient/private/qwaylandclientbufferintegration_p.h>
@ -91,18 +91,13 @@ void *QWaylandNativeInterface::nativeResourceForWindow(const QByteArray &resourc
QWaylandWindow *w = static_cast<QWaylandWindow*>(window->handle());
return w ? w->object() : nullptr;
}
if (lowerCaseResource == "wl_shell_surface") {
QWaylandWindow *w = static_cast<QWaylandWindow*>(window->handle());
if (!w)
return nullptr;
QWaylandWlShellSurface *s = qobject_cast<QWaylandWlShellSurface *>(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;
}

View File

@ -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"

View File

@ -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;