Support platform specific implementation
QtWaylandClient can be inherited to support platform specific implementaton. Change-Id: Ie0f4aa28dbb2dcd6b1245cb14e23f3b45e687400 Reviewed-by: Elvis Lee <kwangwoong.lee@lge.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
parent
487d305d2b
commit
1a1c264b0b
@ -79,7 +79,7 @@ public:
|
|||||||
~QWaylandCursorTheme();
|
~QWaylandCursorTheme();
|
||||||
::wl_cursor *cursor(Qt::CursorShape shape);
|
::wl_cursor *cursor(Qt::CursorShape shape);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
enum WaylandCursor {
|
enum WaylandCursor {
|
||||||
ArrowCursor = Qt::ArrowCursor,
|
ArrowCursor = Qt::ArrowCursor,
|
||||||
UpArrowCursor,
|
UpArrowCursor,
|
||||||
@ -134,7 +134,7 @@ public:
|
|||||||
|
|
||||||
static QSharedPointer<QWaylandBuffer> cursorBitmapBuffer(QWaylandDisplay *display, const QCursor *cursor);
|
static QSharedPointer<QWaylandBuffer> cursorBitmapBuffer(QWaylandDisplay *display, const QCursor *cursor);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
QWaylandDisplay *mDisplay = nullptr;
|
QWaylandDisplay *mDisplay = nullptr;
|
||||||
QPoint mLastPos;
|
QPoint mLastPos;
|
||||||
};
|
};
|
||||||
|
@ -327,7 +327,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
|
|||||||
struct ::wl_registry *registry = object();
|
struct ::wl_registry *registry = object();
|
||||||
|
|
||||||
if (interface == QStringLiteral("wl_output")) {
|
if (interface == QStringLiteral("wl_output")) {
|
||||||
mWaitingScreens << new QWaylandScreen(this, version, id);
|
mWaitingScreens << mWaylandIntegration->createPlatformScreen(this, version, id);
|
||||||
} else if (interface == QStringLiteral("wl_compositor")) {
|
} else if (interface == QStringLiteral("wl_compositor")) {
|
||||||
mCompositorVersion = qMin((int)version, 4);
|
mCompositorVersion = qMin((int)version, 4);
|
||||||
mCompositor.init(registry, id, mCompositorVersion);
|
mCompositor.init(registry, id, mCompositorVersion);
|
||||||
@ -627,7 +627,7 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
|
|||||||
QWaylandCursor *QWaylandDisplay::waylandCursor()
|
QWaylandCursor *QWaylandDisplay::waylandCursor()
|
||||||
{
|
{
|
||||||
if (!mCursor)
|
if (!mCursor)
|
||||||
mCursor.reset(new QWaylandCursor(this));
|
mCursor.reset(mWaylandIntegration->createPlatformCursor(this));
|
||||||
return mCursor.data();
|
return mCursor.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ public:
|
|||||||
Pointer *pointer() const;
|
Pointer *pointer() const;
|
||||||
Touch *touch() const;
|
Touch *touch() const;
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
QWaylandDisplay *mQDisplay = nullptr;
|
QWaylandDisplay *mQDisplay = nullptr;
|
||||||
struct wl_display *mDisplay = nullptr;
|
struct wl_display *mDisplay = nullptr;
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
#include "qwaylanddnd_p.h"
|
#include "qwaylanddnd_p.h"
|
||||||
#include "qwaylandwindowmanagerintegration_p.h"
|
#include "qwaylandwindowmanagerintegration_p.h"
|
||||||
#include "qwaylandscreen_p.h"
|
#include "qwaylandscreen_p.h"
|
||||||
|
#include "qwaylandcursor_p.h"
|
||||||
|
|
||||||
#if defined(Q_OS_MACOS)
|
#if defined(Q_OS_MACOS)
|
||||||
# include <QtGui/private/qcoretextfontdatabase_p.h>
|
# include <QtGui/private/qcoretextfontdatabase_p.h>
|
||||||
@ -112,22 +113,12 @@ QWaylandIntegration::QWaylandIntegration()
|
|||||||
#else
|
#else
|
||||||
: mFontDb(new QGenericUnixFontDatabase())
|
: mFontDb(new QGenericUnixFontDatabase())
|
||||||
#endif
|
#endif
|
||||||
, mNativeInterface(new QWaylandNativeInterface(this))
|
|
||||||
{
|
{
|
||||||
initializeInputDeviceIntegration();
|
|
||||||
mDisplay.reset(new QWaylandDisplay(this));
|
mDisplay.reset(new QWaylandDisplay(this));
|
||||||
if (!mDisplay->isInitialized()) {
|
if (!mDisplay->isInitialized()) {
|
||||||
mFailed = true;
|
mFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#if QT_CONFIG(clipboard)
|
|
||||||
mClipboard.reset(new QWaylandClipboard(mDisplay.data()));
|
|
||||||
#endif
|
|
||||||
#if QT_CONFIG(draganddrop)
|
|
||||||
mDrag.reset(new QWaylandDrag(mDisplay.data()));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
reconfigureInputContext();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWaylandIntegration::~QWaylandIntegration()
|
QWaylandIntegration::~QWaylandIntegration()
|
||||||
@ -193,8 +184,30 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
|
|||||||
return createUnixEventDispatcher();
|
return createUnixEventDispatcher();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPlatformNativeInterface *QWaylandIntegration::createPlatformNativeInterface()
|
||||||
|
{
|
||||||
|
return new QWaylandNativeInterface(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QWaylandIntegration::initializePlatform()
|
||||||
|
{
|
||||||
|
mNativeInterface.reset(createPlatformNativeInterface());
|
||||||
|
initializeInputDeviceIntegration();
|
||||||
|
#if QT_CONFIG(clipboard)
|
||||||
|
mClipboard.reset(new QWaylandClipboard(mDisplay.data()));
|
||||||
|
#endif
|
||||||
|
#if QT_CONFIG(draganddrop)
|
||||||
|
mDrag.reset(new QWaylandDrag(mDisplay.data()));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
reconfigureInputContext();
|
||||||
|
}
|
||||||
|
|
||||||
void QWaylandIntegration::initialize()
|
void QWaylandIntegration::initialize()
|
||||||
{
|
{
|
||||||
|
// Support platform specicif initialization
|
||||||
|
initializePlatform();
|
||||||
|
|
||||||
QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
|
QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
|
||||||
QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
|
QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
|
||||||
QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
|
QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
|
||||||
@ -282,6 +295,16 @@ QPlatformTheme *QWaylandIntegration::createPlatformTheme(const QString &name) co
|
|||||||
return QGenericUnixTheme::createUnixTheme(name);
|
return QGenericUnixTheme::createUnixTheme(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QWaylandScreen *QWaylandIntegration::createPlatformScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id) const
|
||||||
|
{
|
||||||
|
return new QWaylandScreen(waylandDisplay, version, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
QWaylandCursor *QWaylandIntegration::createPlatformCursor(QWaylandDisplay *display) const
|
||||||
|
{
|
||||||
|
return new QWaylandCursor(display);
|
||||||
|
}
|
||||||
|
|
||||||
#if QT_CONFIG(vulkan)
|
#if QT_CONFIG(vulkan)
|
||||||
QPlatformVulkanInstance *QWaylandIntegration::createPlatformVulkanInstance(QVulkanInstance *instance) const
|
QPlatformVulkanInstance *QWaylandIntegration::createPlatformVulkanInstance(QVulkanInstance *instance) const
|
||||||
{
|
{
|
||||||
@ -418,7 +441,7 @@ void QWaylandIntegration::initializeShellIntegration()
|
|||||||
QWindowSystemInterfacePrivate::TabletEvent::setPlatformSynthesizesMouse(false);
|
QWindowSystemInterfacePrivate::TabletEvent::setPlatformSynthesizesMouse(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWaylandInputDevice *QWaylandIntegration::createInputDevice(QWaylandDisplay *display, int version, uint32_t id)
|
QWaylandInputDevice *QWaylandIntegration::createInputDevice(QWaylandDisplay *display, int version, uint32_t id) const
|
||||||
{
|
{
|
||||||
if (mInputDeviceIntegration) {
|
if (mInputDeviceIntegration) {
|
||||||
return mInputDeviceIntegration->createInputDevice(display, version, id);
|
return mInputDeviceIntegration->createInputDevice(display, version, id);
|
||||||
|
@ -67,6 +67,8 @@ class QWaylandServerBufferIntegration;
|
|||||||
class QWaylandShellIntegration;
|
class QWaylandShellIntegration;
|
||||||
class QWaylandInputDeviceIntegration;
|
class QWaylandInputDeviceIntegration;
|
||||||
class QWaylandInputDevice;
|
class QWaylandInputDevice;
|
||||||
|
class QWaylandScreen;
|
||||||
|
class QWaylandCursor;
|
||||||
|
|
||||||
class Q_WAYLAND_CLIENT_EXPORT QWaylandIntegration : public QPlatformIntegration
|
class Q_WAYLAND_CLIENT_EXPORT QWaylandIntegration : public QPlatformIntegration
|
||||||
{
|
{
|
||||||
@ -117,7 +119,9 @@ public:
|
|||||||
QPlatformVulkanInstance *createPlatformVulkanInstance(QVulkanInstance *instance) const override;
|
QPlatformVulkanInstance *createPlatformVulkanInstance(QVulkanInstance *instance) const override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QWaylandInputDevice *createInputDevice(QWaylandDisplay *display, int version, uint32_t id);
|
virtual QWaylandInputDevice *createInputDevice(QWaylandDisplay *display, int version, uint32_t id) const;
|
||||||
|
virtual QWaylandScreen *createPlatformScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id) const;
|
||||||
|
virtual QWaylandCursor *createPlatformCursor(QWaylandDisplay *display) const;
|
||||||
|
|
||||||
virtual QWaylandClientBufferIntegration *clientBufferIntegration() const;
|
virtual QWaylandClientBufferIntegration *clientBufferIntegration() const;
|
||||||
virtual QWaylandServerBufferIntegration *serverBufferIntegration() const;
|
virtual QWaylandServerBufferIntegration *serverBufferIntegration() const;
|
||||||
@ -125,19 +129,24 @@ public:
|
|||||||
|
|
||||||
void reconfigureInputContext();
|
void reconfigureInputContext();
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
// NOTE: mDisplay *must* be destructed after mDrag and mClientBufferIntegration
|
// NOTE: mDisplay *must* be destructed after mDrag and mClientBufferIntegration
|
||||||
// and mShellIntegration.
|
// and mShellIntegration.
|
||||||
// Do not move this definition into the private section at the bottom.
|
// Do not move this definition into the private section at the bottom.
|
||||||
QScopedPointer<QWaylandDisplay> mDisplay;
|
QScopedPointer<QWaylandDisplay> mDisplay;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual QPlatformNativeInterface *createPlatformNativeInterface();
|
||||||
|
|
||||||
QScopedPointer<QWaylandClientBufferIntegration> mClientBufferIntegration;
|
QScopedPointer<QWaylandClientBufferIntegration> mClientBufferIntegration;
|
||||||
QScopedPointer<QWaylandServerBufferIntegration> mServerBufferIntegration;
|
QScopedPointer<QWaylandServerBufferIntegration> mServerBufferIntegration;
|
||||||
QScopedPointer<QWaylandShellIntegration> mShellIntegration;
|
QScopedPointer<QWaylandShellIntegration> mShellIntegration;
|
||||||
QScopedPointer<QWaylandInputDeviceIntegration> mInputDeviceIntegration;
|
QScopedPointer<QWaylandInputDeviceIntegration> mInputDeviceIntegration;
|
||||||
|
|
||||||
|
QScopedPointer<QPlatformInputContext> mInputContext;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void initializePlatform();
|
||||||
void initializeClientBufferIntegration();
|
void initializeClientBufferIntegration();
|
||||||
void initializeServerBufferIntegration();
|
void initializeServerBufferIntegration();
|
||||||
void initializeShellIntegration();
|
void initializeShellIntegration();
|
||||||
@ -152,7 +161,6 @@ private:
|
|||||||
QScopedPointer<QPlatformDrag> mDrag;
|
QScopedPointer<QPlatformDrag> mDrag;
|
||||||
#endif
|
#endif
|
||||||
QScopedPointer<QPlatformNativeInterface> mNativeInterface;
|
QScopedPointer<QPlatformNativeInterface> mNativeInterface;
|
||||||
QScopedPointer<QPlatformInputContext> mInputContext;
|
|
||||||
#if QT_CONFIG(accessibility)
|
#if QT_CONFIG(accessibility)
|
||||||
mutable QScopedPointer<QPlatformAccessibility> mAccessibility;
|
mutable QScopedPointer<QPlatformAccessibility> mAccessibility;
|
||||||
#endif
|
#endif
|
||||||
|
@ -113,7 +113,7 @@ public:
|
|||||||
static QWaylandScreen *waylandScreenFromWindow(QWindow *window);
|
static QWaylandScreen *waylandScreenFromWindow(QWindow *window);
|
||||||
static QWaylandScreen *fromWlOutput(::wl_output *output);
|
static QWaylandScreen *fromWlOutput(::wl_output *output);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
void output_mode(uint32_t flags, int width, int height, int refresh) override;
|
void output_mode(uint32_t flags, int width, int height, int refresh) override;
|
||||||
void output_geometry(int32_t x, int32_t y,
|
void output_geometry(int32_t x, int32_t y,
|
||||||
int32_t width, int32_t height,
|
int32_t width, int32_t height,
|
||||||
@ -149,10 +149,6 @@ private:
|
|||||||
bool mOutputDone = false;
|
bool mOutputDone = false;
|
||||||
bool mXdgOutputDone = false;
|
bool mXdgOutputDone = false;
|
||||||
bool mInitialized = false;
|
bool mInitialized = false;
|
||||||
|
|
||||||
#if QT_CONFIG(cursor)
|
|
||||||
QScopedPointer<QWaylandCursor> mWaylandCursor;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -214,6 +214,8 @@ signals:
|
|||||||
void wlSurfaceDestroyed();
|
void wlSurfaceDestroyed();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void sendExposeEvent(const QRect &rect);
|
||||||
|
|
||||||
QWaylandDisplay *mDisplay = nullptr;
|
QWaylandDisplay *mDisplay = nullptr;
|
||||||
QScopedPointer<QWaylandSurface> mSurface;
|
QScopedPointer<QWaylandSurface> mSurface;
|
||||||
QWaylandShellSurface *mShellSurface = nullptr;
|
QWaylandShellSurface *mShellSurface = nullptr;
|
||||||
@ -268,7 +270,6 @@ private:
|
|||||||
bool shouldCreateShellSurface() const;
|
bool shouldCreateShellSurface() const;
|
||||||
bool shouldCreateSubSurface() const;
|
bool shouldCreateSubSurface() const;
|
||||||
void reset();
|
void reset();
|
||||||
void sendExposeEvent(const QRect &rect);
|
|
||||||
static void closePopups(QWaylandWindow *parent);
|
static void closePopups(QWaylandWindow *parent);
|
||||||
QPlatformScreen *calculateScreenFromSurfaceEvents() const;
|
QPlatformScreen *calculateScreenFromSurfaceEvents() const;
|
||||||
void setOpaqueArea(const QRegion &opaqueArea);
|
void setOpaqueArea(const QRegion &opaqueArea);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user