Move xdg-shell-v5 to a plugin

This is the first step in deprecating xdg-shell unstable v5 and making the good
names available for the good names for xdg-shell stable.

Shell initialization has been refactored slightly, so the
QWaylandShellIntegrationFactory actually tries to initialize the shell
integration before returning it. Similarly for the factory method of non-plugin
shells.

Change-Id: I85e60594c4fc03c6f302c04316110aed428d28dc
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
Johan Klokkhammer Helsing 2018-05-08 16:31:16 +02:00 committed by Johan Helsing
parent 4f292a1226
commit 7ef6c33a69
21 changed files with 183 additions and 79 deletions

View File

@ -28,7 +28,6 @@ WAYLANDCLIENTSOURCES += \
../extensions/qtkey-extension.xml \
../extensions/qt-windowmanager.xml \
../3rdparty/protocol/text-input-unstable-v2.xml \
../3rdparty/protocol/xdg-shell.xml \
../3rdparty/protocol/xdg-shell-unstable-v6.xml \
WAYLANDCLIENTSOURCES_SYSTEM += \
@ -45,10 +44,6 @@ SOURCES += qwaylandintegration.cpp \
qwaylandshellsurface.cpp \
qwaylandwlshellsurface.cpp \
qwaylandwlshellintegration.cpp \
qwaylandxdgshell.cpp \
qwaylandxdgsurface.cpp \
qwaylandxdgpopup.cpp \
qwaylandxdgshellintegration.cpp \
qwaylandxdgshellv6.cpp \
qwaylandxdgshellv6integration.cpp \
qwaylandextendedsurface.cpp \
@ -78,10 +73,6 @@ HEADERS += qwaylandintegration_p.h \
qwaylandshellsurface_p.h \
qwaylandwlshellsurface_p.h \
qwaylandwlshellintegration_p.h \
qwaylandxdgshell_p.h \
qwaylandxdgsurface_p.h \
qwaylandxdgpopup_p.h \
qwaylandxdgshellintegration_p.h \
qwaylandxdgshellv6_p.h \
qwaylandxdgshellv6integration_p.h \
qwaylandextendedsurface_p.h \

View File

@ -1,3 +1,5 @@
TEMPLATE = subdirs
SUBDIRS += ivi-shell
SUBDIRS += \
ivi-shell \
xdg-shell-v5

View File

@ -0,0 +1,70 @@
/****************************************************************************
**
** 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 "qwaylandxdgshellintegration_p.h"
#include <QtWaylandClient/private/qwaylandshellintegrationplugin_p.h>
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
class QWaylandXdgShellV5IntegrationPlugin : public QWaylandShellIntegrationPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID QWaylandShellIntegrationFactoryInterface_iid FILE "xdg-shell-v5.json")
public:
QWaylandShellIntegration *create(const QString &key, const QStringList &paramList) override;
};
QWaylandShellIntegration *QWaylandXdgShellV5IntegrationPlugin::create(const QString &key, const QStringList &paramList)
{
qDebug() << Q_FUNC_INFO;
Q_UNUSED(key);
Q_UNUSED(paramList);
return new QWaylandXdgShellIntegration();
}
}
QT_END_NAMESPACE
#include "main.moc"

View File

@ -39,9 +39,9 @@
#include "qwaylandxdgpopup_p.h"
#include "qwaylandwindow_p.h"
#include "qwaylanddisplay_p.h"
#include "qwaylandextendedsurface_p.h"
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
#include <QtWaylandClient/private/qwaylandwindow_p.h>
#include <QtWaylandClient/private/qwaylandextendedsurface_p.h>
QT_BEGIN_NAMESPACE

View File

@ -51,10 +51,11 @@
// We mean it.
//
#include "qwayland-xdg-shell.h"
#include <wayland-client.h>
#include <QtWaylandClient/qtwaylandclientglobal.h>
#include <QtWaylandClient/private/qwayland-xdg-shell.h>
#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
QT_BEGIN_NAMESPACE

View File

@ -38,16 +38,16 @@
****************************************************************************/
#include "qwaylandxdgshell_p.h"
#include "qwaylanddisplay_p.h"
#include "qwaylandwindow_p.h"
#include "qwaylandinputdevice_p.h"
#include "qwaylandscreen_p.h"
#include "qwaylandxdgpopup_p.h"
#include "qwaylandxdgsurface_p.h"
#include <QtCore/QDebug>
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
#include <QtWaylandClient/private/qwaylandwindow_p.h>
#include <QtWaylandClient/private/qwaylandinputdevice_p.h>
#include <QtWaylandClient/private/qwaylandscreen_p.h>
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {

View File

@ -51,12 +51,13 @@
// We mean it.
//
#include "qwayland-xdg-shell.h"
#include <QtCore/QSize>
#include <QtCore/QVector>
#include <wayland-client.h>
#include <QtWaylandClient/private/qwayland-xdg-shell.h>
#include <QtWaylandClient/qtwaylandclientglobal.h>
#include <QtWaylandClient/private/qwaylandshellsurface_p.h>

View File

@ -38,38 +38,32 @@
****************************************************************************/
#include "qwaylandxdgshellintegration_p.h"
#include "qwaylandxdgsurface_p.h"
#include "qwaylandxdgpopup_p.h"
#include "qwaylandxdgshell_p.h"
#include <QtWaylandClient/private/qwaylandwindow_p.h>
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
#include <QtWaylandClient/private/qwaylandxdgsurface_p.h>
#include <QtWaylandClient/private/qwaylandxdgpopup_p.h>
#include <QtWaylandClient/private/qwaylandxdgshell_p.h>
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
QWaylandXdgShellIntegration *QWaylandXdgShellIntegration::create(QWaylandDisplay *display)
{
if (display->hasRegistryGlobal(QLatin1String("xdg_shell")))
return new QWaylandXdgShellIntegration(display);
return nullptr;
}
QWaylandXdgShellIntegration::QWaylandXdgShellIntegration(QWaylandDisplay *display)
bool QWaylandXdgShellIntegration::initialize(QWaylandDisplay *display)
{
Q_FOREACH (QWaylandDisplay::RegistryGlobal global, display->globals()) {
if (global.interface == QLatin1String("xdg_shell")) {
m_xdgShell = new QWaylandXdgShell(display->wl_registry(), global.id);
m_xdgShell.reset(new QWaylandXdgShell(display->wl_registry(), global.id));
break;
}
}
}
bool QWaylandXdgShellIntegration::initialize(QWaylandDisplay *display)
{
QWaylandShellIntegration::initialize(display);
return m_xdgShell != nullptr;
if (!m_xdgShell) {
qWarning() << "Couldn't find global xdg_shell for xdg-shell unstable v5";
return false;
}
return QWaylandShellIntegration::initialize(display);
}
QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWindow *window)

View File

@ -51,7 +51,7 @@
// We mean it.
//
#include <wayland-client.h>
#include "qwaylandxdgshell_p.h"
#include <QtWaylandClient/private/qwaylandshellintegration_p.h>
@ -64,15 +64,13 @@ class QWaylandXdgShell;
class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgShellIntegration : public QWaylandShellIntegration
{
public:
static QWaylandXdgShellIntegration *create(QWaylandDisplay* display);
QWaylandXdgShellIntegration() {qDebug() << Q_FUNC_INFO;}
bool initialize(QWaylandDisplay *display) override;
QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
private:
QWaylandXdgShellIntegration(QWaylandDisplay *display);
QWaylandXdgShell *m_xdgShell = nullptr;
QScopedPointer<QWaylandXdgShell> m_xdgShell;
};
}

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the config.tests of the Qt Toolkit.
@ -38,15 +38,15 @@
****************************************************************************/
#include "qwaylandxdgsurface_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 "qwaylandxdgshell_p.h"
#include <QtWaylandClient/private/qwaylanddisplay_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>
QT_BEGIN_NAMESPACE

View File

@ -51,15 +51,16 @@
// We mean it.
//
#include "qwayland-xdg-shell.h"
#include <QtWaylandClient/qtwaylandclientglobal.h>
#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
#include <QtCore/QSize>
#include <QtCore/QMargins>
#include <wayland-client.h>
#include <QtWaylandClient/qtwaylandclientglobal.h>
#include <QtWaylandClient/private/qwayland-xdg-shell.h>
#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
QT_BEGIN_NAMESPACE
class QWindow;

View File

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

View File

@ -0,0 +1,30 @@
QT += gui-private waylandclient-private
CONFIG += wayland-scanner
QMAKE_USE += wayland-client
qtConfig(xkbcommon-evdev): \
QMAKE_USE += xkbcommon_evdev
WAYLANDCLIENTSOURCES += \
../../../3rdparty/protocol/xdg-shell.xml
HEADERS += \
qwaylandxdgpopup_p.h \
qwaylandxdgshell_p.h \
qwaylandxdgshellintegration_p.h \
qwaylandxdgsurface_p.h \
SOURCES += \
main.cpp \
qwaylandxdgpopup.cpp \
qwaylandxdgshell.cpp \
qwaylandxdgshellintegration.cpp \
qwaylandxdgsurface.cpp \
OTHER_FILES += \
xdg-shell-v5.json
PLUGIN_TYPE = wayland-shell-integration
PLUGIN_CLASS_NAME = QWaylandXdgShellV5IntegrationPlugin
load(qt_plugin)

View File

@ -51,8 +51,6 @@
#include "qwaylanddatadevicemanager_p.h"
#endif
#include "qwaylandhardwareintegration_p.h"
#include "qwaylandxdgshell_p.h"
#include "qwaylandxdgsurface_p.h"
#include "qwaylandwlshellsurface_p.h"
#include "qwaylandinputcontext_p.h"
@ -66,7 +64,6 @@
#include "qwaylandqtkey_p.h"
#include <QtWaylandClient/private/qwayland-text-input-unstable-v2.h>
#include <QtWaylandClient/private/qwayland-xdg-shell.h>
#include <QtCore/QAbstractEventDispatcher>
#include <QtGui/private/qguiapplication_p.h>

View File

@ -63,7 +63,6 @@
#include <QtWaylandClient/private/qwayland-wayland.h>
#include <QtWaylandClient/private/qtwaylandclientglobal_p.h>
#include <QtWaylandClient/private/qwayland-xdg-shell.h>
#include <QtWaylandClient/private/qwaylandshm_p.h>
struct wl_cursor_image;

View File

@ -77,7 +77,6 @@
#include "qwaylandshellintegration_p.h"
#include "qwaylandshellintegrationfactory_p.h"
#include "qwaylandxdgshellintegration_p.h"
#include "qwaylandwlshellintegration_p.h"
#include "qwaylandxdgshellv6integration_p.h"
@ -409,9 +408,9 @@ void QWaylandIntegration::initializeShellIntegration()
}
}
if (!mShellIntegration || !mShellIntegration->initialize(mDisplay.data())) {
mShellIntegration.reset();
qWarning("Failed to load shell integration %s", qPrintable(targetKey));
if (!mShellIntegration) {
qCWarning(lcQpaWayland) << "Loading shell integration failed.";
qCWarning(lcQpaWayland) << "Attempted to load the following shells" << preferredShells;
}
}
@ -445,13 +444,12 @@ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QStr
{
if (integrationName == QLatin1Literal("wl-shell")) {
return QWaylandWlShellIntegration::create(mDisplay.data());
} else if (integrationName == QLatin1Literal("xdg-shell-v5")) {
return QWaylandXdgShellIntegration::create(mDisplay.data());
} else if (integrationName == QLatin1Literal("xdg-shell-v6")) {
return QWaylandXdgShellV6Integration::create(mDisplay.data());
} else if (QWaylandShellIntegrationFactory::keys().contains(integrationName)) {
return QWaylandShellIntegrationFactory::create(integrationName, QStringList());
return QWaylandShellIntegrationFactory::create(integrationName, mDisplay.data());
} else {
qCWarning(lcQpaWayland) << "No shell integration named" << integrationName << "found";
return nullptr;
}
}

View File

@ -45,7 +45,6 @@
#include "qwaylandscreen_p.h"
#include "qwaylandshellsurface_p.h"
#include "qwaylandwlshellsurface_p.h"
#include "qwaylandxdgsurface_p.h"
#include "qwaylandsubsurface_p.h"
#include "qwaylandabstractdecoration_p.h"
#include "qwaylandwindowmanagerintegration_p.h"

View File

@ -49,9 +49,15 @@ namespace QtWaylandClient {
QWaylandWlShellIntegration *QWaylandWlShellIntegration::create(QWaylandDisplay *display)
{
if (display->hasRegistryGlobal(QLatin1String("wl_shell")))
return new QWaylandWlShellIntegration(display);
return nullptr;
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)

View File

@ -59,9 +59,15 @@ QWaylandXdgShellV6Integration::QWaylandXdgShellV6Integration(QWaylandDisplay *di
QWaylandXdgShellV6Integration *QWaylandXdgShellV6Integration::create(QWaylandDisplay *display)
{
if (display->hasRegistryGlobal(QLatin1String("zxdg_shell_v6")))
return new QWaylandXdgShellV6Integration(display);
return nullptr;
if (!display->hasRegistryGlobal(QLatin1String("zxdg_shell_v6")))
return nullptr;
QScopedPointer<QWaylandXdgShellV6Integration> integration;
integration.reset(new QWaylandXdgShellV6Integration(display));
if (integration && !integration->initialize(display))
return nullptr;
return integration.take();
}
bool QWaylandXdgShellV6Integration::initialize(QWaylandDisplay *display)

View File

@ -78,19 +78,24 @@ QStringList QWaylandShellIntegrationFactory::keys(const QString &pluginPath)
#endif
}
QWaylandShellIntegration *QWaylandShellIntegrationFactory::create(const QString &name, const QStringList &args, const QString &pluginPath)
QWaylandShellIntegration *QWaylandShellIntegrationFactory::create(const QString &name, QWaylandDisplay *display, const QStringList &args, const QString &pluginPath)
{
#if QT_CONFIG(library)
QScopedPointer<QWaylandShellIntegration> integration;
// Try loading the plugin from platformPluginPath first:
if (!pluginPath.isEmpty()) {
QCoreApplication::addLibraryPath(pluginPath);
if (QWaylandShellIntegration *ret = qLoadPlugin<QWaylandShellIntegration, QWaylandShellIntegrationPlugin>(directLoader(), name, args))
return ret;
integration.reset(qLoadPlugin<QWaylandShellIntegration, QWaylandShellIntegrationPlugin>(directLoader(), name, args));
}
if (QWaylandShellIntegration *ret = qLoadPlugin<QWaylandShellIntegration, QWaylandShellIntegrationPlugin>(loader(), name, args))
return ret;
if (!integration)
integration.reset(qLoadPlugin<QWaylandShellIntegration, QWaylandShellIntegrationPlugin>(loader(), name, args));
#endif
return nullptr;
if (integration && !integration->initialize(display))
return nullptr;
return integration.take();
}
}

View File

@ -51,7 +51,10 @@
// We mean it.
//
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
#include <QtWaylandClient/qtwaylandclientglobal.h>
#include <QtCore/QStringList>
QT_BEGIN_NAMESPACE
@ -64,7 +67,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandShellIntegrationFactory
{
public:
static QStringList keys(const QString &pluginPath = QString());
static QWaylandShellIntegration *create(const QString &name, const QStringList &args, const QString &pluginPath = QString());
static QWaylandShellIntegration *create(const QString &name, QWaylandDisplay *display, const QStringList &args = QStringList(), const QString &pluginPath = QString());
};
}