client: Disentangle platform services and windowmanagerintegration
The current state was a bit messy with the platform services being the potentially no initialised qt window manager extension wayland object. Change-Id: Id1f911b75d34fcf70594ca7257b79bf431f0643f Reviewed-by: David Edmundson <davidedmundson@kde.org>
This commit is contained in:
parent
4313de83d6
commit
24cd08a667
@ -42,6 +42,7 @@ qt_internal_add_module(WaylandClient
|
||||
qwaylandinputmethodcontext.cpp qwaylandinputmethodcontext_p.h
|
||||
qwaylandintegration.cpp qwaylandintegration_p.h
|
||||
qwaylandnativeinterface.cpp qwaylandnativeinterface_p.h
|
||||
qwaylandplatformservices.cpp qwaylandplatformservices_p.h
|
||||
qwaylandpointergestures.cpp qwaylandpointergestures_p.h
|
||||
qwaylandqtkey.cpp qwaylandqtkey_p.h
|
||||
qwaylandscreen.cpp qwaylandscreen_p.h
|
||||
|
@ -312,7 +312,7 @@ QWaylandClientBufferIntegration * QWaylandDisplay::clientBufferIntegration() con
|
||||
|
||||
QWaylandWindowManagerIntegration *QWaylandDisplay::windowManagerIntegration() const
|
||||
{
|
||||
return mWindowManagerIntegration.data();
|
||||
return mGlobals.windowManagerIntegration.get();
|
||||
}
|
||||
|
||||
QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
|
||||
@ -335,8 +335,6 @@ void QWaylandDisplay::setupConnection()
|
||||
struct ::wl_registry *registry = wl_display_get_registry(mDisplay);
|
||||
init(registry);
|
||||
|
||||
mWindowManagerIntegration.reset(new QWaylandWindowManagerIntegration(this));
|
||||
|
||||
#if QT_CONFIG(xkbcommon)
|
||||
mXkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_FLAGS));
|
||||
if (!mXkbContext)
|
||||
@ -373,7 +371,6 @@ QWaylandDisplay::~QWaylandDisplay(void)
|
||||
|
||||
// Reset the globals manually since they need to be destroyed before the wl_display
|
||||
mGlobals = {};
|
||||
mWindowManagerIntegration.reset();
|
||||
|
||||
if (object())
|
||||
wl_registry_destroy(object());
|
||||
@ -781,6 +778,9 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
|
||||
mGlobals.xdgToplevelDragManager.reset(
|
||||
new WithDestructor<QtWayland::xdg_toplevel_drag_manager_v1,
|
||||
xdg_toplevel_drag_manager_v1_destroy>(registry, id, 1));
|
||||
} else if (interface == QLatin1String(QtWayland::qt_windowmanager::interface()->name)) {
|
||||
mGlobals.windowManagerIntegration.reset(
|
||||
new QWaylandWindowManagerIntegration(this, id, version));
|
||||
}
|
||||
|
||||
mRegistryGlobals.append(RegistryGlobal(id, interface, version, registry));
|
||||
|
@ -316,8 +316,6 @@ private:
|
||||
QScopedPointer<QWaylandCursor> mCursor;
|
||||
#endif
|
||||
|
||||
QScopedPointer<QWaylandWindowManagerIntegration> mWindowManagerIntegration;
|
||||
|
||||
struct GlobalHolder
|
||||
{
|
||||
std::unique_ptr<QtWayland::wl_compositor> compositor;
|
||||
@ -346,6 +344,7 @@ private:
|
||||
std::unique_ptr<QtWayland::wp_fractional_scale_manager_v1> fractionalScaleManager;
|
||||
std::unique_ptr<QtWayland::wp_cursor_shape_manager_v1> cursorShapeManager;
|
||||
std::unique_ptr<QtWayland::xdg_toplevel_drag_manager_v1> xdgToplevelDragManager;
|
||||
std::unique_ptr<QWaylandWindowManagerIntegration> windowManagerIntegration;
|
||||
} mGlobals;
|
||||
int mFd = -1;
|
||||
int mWritableNotificationFd = -1;
|
||||
|
@ -15,6 +15,7 @@
|
||||
#endif
|
||||
#include "qwaylanddnd_p.h"
|
||||
#include "qwaylandwindowmanagerintegration_p.h"
|
||||
#include "qwaylandplatformservices_p.h"
|
||||
#include "qwaylandscreen_p.h"
|
||||
#include "qwaylandcursor_p.h"
|
||||
|
||||
@ -83,6 +84,7 @@ QWaylandIntegration::QWaylandIntegration()
|
||||
#endif
|
||||
{
|
||||
mDisplay.reset(new QWaylandDisplay(this));
|
||||
mPlatformServices.reset(new QWaylandPlatformServices(mDisplay.data()));
|
||||
|
||||
QWaylandWindow::fixedToplevelPositions =
|
||||
!qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
|
||||
@ -246,7 +248,7 @@ QPlatformAccessibility *QWaylandIntegration::accessibility() const
|
||||
|
||||
QPlatformServices *QWaylandIntegration::services() const
|
||||
{
|
||||
return mDisplay->windowManagerIntegration();
|
||||
return mPlatformServices.data();
|
||||
}
|
||||
|
||||
QWaylandDisplay *QWaylandIntegration::display() const
|
||||
@ -525,8 +527,7 @@ void QWaylandIntegration::reset()
|
||||
|
||||
void QWaylandIntegration::setApplicationBadge(qint64 number)
|
||||
{
|
||||
auto unixServices = mDisplay->windowManagerIntegration();
|
||||
unixServices->setApplicationBadge(number);
|
||||
mPlatformServices->setApplicationBadge(number);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@ class QWaylandInputDeviceIntegration;
|
||||
class QWaylandInputDevice;
|
||||
class QWaylandScreen;
|
||||
class QWaylandCursor;
|
||||
class QWaylandPlatformServices;
|
||||
|
||||
class Q_WAYLANDCLIENT_EXPORT QWaylandIntegration : public QPlatformIntegration
|
||||
{
|
||||
@ -136,6 +137,7 @@ private:
|
||||
#if QT_CONFIG(accessibility)
|
||||
mutable QScopedPointer<QPlatformAccessibility> mAccessibility;
|
||||
#endif
|
||||
QScopedPointer<QWaylandPlatformServices> mPlatformServices;
|
||||
QMutex mClientBufferInitLock;
|
||||
bool mClientBufferIntegrationInitialized = false;
|
||||
bool mServerBufferIntegrationInitialized = false;
|
||||
|
50
src/plugins/platforms/wayland/qwaylandplatformservices.cpp
Normal file
50
src/plugins/platforms/wayland/qwaylandplatformservices.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#include "qwaylandplatformservices_p.h"
|
||||
#include "qwaylandwindow_p.h"
|
||||
#include "qwaylanddisplay_p.h"
|
||||
#include "qwaylandshellsurface_p.h"
|
||||
#include "qwaylandwindowmanagerintegration_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QtWaylandClient {
|
||||
|
||||
QWaylandPlatformServices::QWaylandPlatformServices(QWaylandDisplay *display)
|
||||
: m_display(display) { }
|
||||
|
||||
bool QWaylandPlatformServices::openUrl(const QUrl &url)
|
||||
{
|
||||
if (auto windowManagerIntegration = m_display->windowManagerIntegration()) {
|
||||
windowManagerIntegration->openUrl(url);
|
||||
return true;
|
||||
}
|
||||
return QGenericUnixServices::openUrl(url);
|
||||
}
|
||||
|
||||
bool QWaylandPlatformServices::openDocument(const QUrl &url)
|
||||
{
|
||||
if (auto windowManagerIntegration = m_display->windowManagerIntegration()) {
|
||||
windowManagerIntegration->openUrl(url);
|
||||
return true;
|
||||
}
|
||||
return QGenericUnixServices::openDocument(url);
|
||||
}
|
||||
|
||||
QString QWaylandPlatformServices::portalWindowIdentifier(QWindow *window)
|
||||
{
|
||||
if (window && window->handle()) {
|
||||
auto shellSurface = static_cast<QWaylandWindow *>(window->handle())->shellSurface();
|
||||
if (shellSurface) {
|
||||
const QString handle = shellSurface->externWindowHandle();
|
||||
return QLatin1String("wayland:") + handle;
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
} // namespace QtWaylandClient
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "moc_qwaylandplatformservices_p.cpp"
|
48
src/plugins/platforms/wayland/qwaylandplatformservices_p.h
Normal file
48
src/plugins/platforms/wayland/qwaylandplatformservices_p.h
Normal file
@ -0,0 +1,48 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#ifndef QWAYLANDPLATFORMSERVICES_H
|
||||
#define QWAYLANDPLATFORMSERVICES_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
#include <QtGui/private/qgenericunixservices_p.h>
|
||||
|
||||
#include <QtWaylandClient/private/qwayland-qt-windowmanager.h>
|
||||
#include <QtWaylandClient/qtwaylandclientglobal.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QtWaylandClient {
|
||||
|
||||
class QWaylandDisplay;
|
||||
|
||||
class Q_WAYLANDCLIENT_EXPORT QWaylandPlatformServices : public QGenericUnixServices
|
||||
{
|
||||
public:
|
||||
explicit QWaylandPlatformServices(QWaylandDisplay *waylandDisplay);
|
||||
|
||||
bool openUrl(const QUrl &url) override;
|
||||
bool openDocument(const QUrl &url) override;
|
||||
QString portalWindowIdentifier(QWindow *window) override;
|
||||
|
||||
private:
|
||||
QWaylandDisplay *m_display;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
} // namespace QtWaylandClient
|
||||
|
||||
#endif // QWAYLANDPLATFORMSERVICES_H
|
@ -12,7 +12,7 @@
|
||||
#include "qwaylandshellsurface_p.h"
|
||||
#include "qwaylandsubsurface_p.h"
|
||||
#include "qwaylandabstractdecoration_p.h"
|
||||
#include "qwaylandwindowmanagerintegration_p.h"
|
||||
#include "qwaylandplatformservices_p.h"
|
||||
#include "qwaylandnativeinterface_p.h"
|
||||
#include "qwaylanddecorationfactory_p.h"
|
||||
#include "qwaylandshmbackingstore_p.h"
|
||||
|
@ -22,49 +22,26 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QtWaylandClient {
|
||||
|
||||
class QWaylandWindowManagerIntegrationPrivate {
|
||||
public:
|
||||
QWaylandWindowManagerIntegrationPrivate(QWaylandDisplay *waylandDisplay);
|
||||
bool m_blockPropertyUpdates = false;
|
||||
QWaylandDisplay *m_waylandDisplay = nullptr;
|
||||
QHash<QWindow*, QVariantMap> m_queuedProperties;
|
||||
bool m_showIsFullScreen = false;
|
||||
};
|
||||
|
||||
QWaylandWindowManagerIntegrationPrivate::QWaylandWindowManagerIntegrationPrivate(QWaylandDisplay *waylandDisplay)
|
||||
: m_waylandDisplay(waylandDisplay)
|
||||
QWaylandWindowManagerIntegration::QWaylandWindowManagerIntegration(QWaylandDisplay *waylandDisplay,
|
||||
uint id, uint version)
|
||||
: QtWayland::qt_windowmanager(waylandDisplay->object(), id, version),
|
||||
m_waylandDisplay(waylandDisplay)
|
||||
{
|
||||
}
|
||||
|
||||
QWaylandWindowManagerIntegration::QWaylandWindowManagerIntegration(QWaylandDisplay *waylandDisplay)
|
||||
: d_ptr(new QWaylandWindowManagerIntegrationPrivate(waylandDisplay))
|
||||
{
|
||||
waylandDisplay->addRegistryListener(&wlHandleListenerGlobal, this);
|
||||
}
|
||||
|
||||
QWaylandWindowManagerIntegration::~QWaylandWindowManagerIntegration()
|
||||
{
|
||||
if (object())
|
||||
qt_windowmanager_destroy(object());
|
||||
qt_windowmanager_destroy(object());
|
||||
}
|
||||
|
||||
bool QWaylandWindowManagerIntegration::showIsFullScreen() const
|
||||
{
|
||||
Q_D(const QWaylandWindowManagerIntegration);
|
||||
return d->m_showIsFullScreen;
|
||||
}
|
||||
|
||||
void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(void *data, wl_registry *registry, uint32_t id, const QString &interface, uint32_t version)
|
||||
{
|
||||
Q_UNUSED(version);
|
||||
if (interface == QStringLiteral("qt_windowmanager"))
|
||||
static_cast<QWaylandWindowManagerIntegration *>(data)->init(registry, id, 1);
|
||||
return m_showIsFullScreen;
|
||||
}
|
||||
|
||||
void QWaylandWindowManagerIntegration::windowmanager_hints(int32_t showIsFullScreen)
|
||||
{
|
||||
Q_D(QWaylandWindowManagerIntegration);
|
||||
d->m_showIsFullScreen = showIsFullScreen;
|
||||
m_showIsFullScreen = showIsFullScreen;
|
||||
}
|
||||
|
||||
void QWaylandWindowManagerIntegration::windowmanager_quit()
|
||||
@ -72,11 +49,9 @@ void QWaylandWindowManagerIntegration::windowmanager_quit()
|
||||
QGuiApplication::quit();
|
||||
}
|
||||
|
||||
void QWaylandWindowManagerIntegration::openUrl_helper(const QUrl &url)
|
||||
void QWaylandWindowManagerIntegration::openUrl(const QUrl &url)
|
||||
{
|
||||
Q_ASSERT(isInitialized());
|
||||
QString data = url.toString();
|
||||
|
||||
static const int chunkSize = 128;
|
||||
while (!data.isEmpty()) {
|
||||
QString chunk = data.left(chunkSize);
|
||||
@ -88,36 +63,6 @@ void QWaylandWindowManagerIntegration::openUrl_helper(const QUrl &url)
|
||||
open_url(!data.isEmpty(), chunk);
|
||||
}
|
||||
}
|
||||
|
||||
bool QWaylandWindowManagerIntegration::openUrl(const QUrl &url)
|
||||
{
|
||||
if (isInitialized()) {
|
||||
openUrl_helper(url);
|
||||
return true;
|
||||
}
|
||||
return QGenericUnixServices::openUrl(url);
|
||||
}
|
||||
|
||||
bool QWaylandWindowManagerIntegration::openDocument(const QUrl &url)
|
||||
{
|
||||
if (isInitialized()) {
|
||||
openUrl_helper(url);
|
||||
return true;
|
||||
}
|
||||
return QGenericUnixServices::openDocument(url);
|
||||
}
|
||||
|
||||
QString QWaylandWindowManagerIntegration::portalWindowIdentifier(QWindow *window)
|
||||
{
|
||||
if (window && window->handle()) {
|
||||
auto shellSurface = static_cast<QWaylandWindow *>(window->handle())->shellSurface();
|
||||
if (shellSurface) {
|
||||
const QString handle = shellSurface->externWindowHandle();
|
||||
return QLatin1String("wayland:") + handle;
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -16,9 +16,6 @@
|
||||
//
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QScopedPointer>
|
||||
|
||||
#include <QtGui/private/qgenericunixservices_p.h>
|
||||
|
||||
#include <QtWaylandClient/private/qwayland-qt-windowmanager.h>
|
||||
#include <QtWaylandClient/qtwaylandclientglobal.h>
|
||||
@ -27,35 +24,28 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QtWaylandClient {
|
||||
|
||||
class QWaylandWindow;
|
||||
class QWaylandDisplay;
|
||||
|
||||
class QWaylandWindowManagerIntegrationPrivate;
|
||||
|
||||
class Q_WAYLANDCLIENT_EXPORT QWaylandWindowManagerIntegration : public QObject, public QGenericUnixServices, public QtWayland::qt_windowmanager
|
||||
class Q_WAYLANDCLIENT_EXPORT QWaylandWindowManagerIntegration : public QtWayland::qt_windowmanager
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(QWaylandWindowManagerIntegration)
|
||||
public:
|
||||
explicit QWaylandWindowManagerIntegration(QWaylandDisplay *waylandDisplay);
|
||||
~QWaylandWindowManagerIntegration() override;
|
||||
|
||||
bool openUrl(const QUrl &url) override;
|
||||
bool openDocument(const QUrl &url) override;
|
||||
QString portalWindowIdentifier(QWindow *window) override;
|
||||
public:
|
||||
explicit QWaylandWindowManagerIntegration(QWaylandDisplay *waylandDisplay, uint id,
|
||||
uint version);
|
||||
~QWaylandWindowManagerIntegration();
|
||||
|
||||
void openUrl(const QUrl &url);
|
||||
|
||||
bool showIsFullScreen() const;
|
||||
|
||||
private:
|
||||
static void wlHandleListenerGlobal(void *data, wl_registry *registry, uint32_t id,
|
||||
const QString &interface, uint32_t version);
|
||||
|
||||
QScopedPointer<QWaylandWindowManagerIntegrationPrivate> d_ptr;
|
||||
|
||||
void windowmanager_hints(int32_t showIsFullScreen) override;
|
||||
void windowmanager_quit() override;
|
||||
|
||||
void openUrl_helper(const QUrl &url);
|
||||
QWaylandDisplay *m_waylandDisplay = nullptr;
|
||||
bool m_showIsFullScreen = false;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
Loading…
x
Reference in New Issue
Block a user