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();
|
||||
::wl_cursor *cursor(Qt::CursorShape shape);
|
||||
|
||||
private:
|
||||
protected:
|
||||
enum WaylandCursor {
|
||||
ArrowCursor = Qt::ArrowCursor,
|
||||
UpArrowCursor,
|
||||
@ -134,7 +134,7 @@ public:
|
||||
|
||||
static QSharedPointer<QWaylandBuffer> cursorBitmapBuffer(QWaylandDisplay *display, const QCursor *cursor);
|
||||
|
||||
private:
|
||||
protected:
|
||||
QWaylandDisplay *mDisplay = nullptr;
|
||||
QPoint mLastPos;
|
||||
};
|
||||
|
@ -327,7 +327,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
|
||||
struct ::wl_registry *registry = object();
|
||||
|
||||
if (interface == QStringLiteral("wl_output")) {
|
||||
mWaitingScreens << new QWaylandScreen(this, version, id);
|
||||
mWaitingScreens << mWaylandIntegration->createPlatformScreen(this, version, id);
|
||||
} else if (interface == QStringLiteral("wl_compositor")) {
|
||||
mCompositorVersion = qMin((int)version, 4);
|
||||
mCompositor.init(registry, id, mCompositorVersion);
|
||||
@ -627,7 +627,7 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
|
||||
QWaylandCursor *QWaylandDisplay::waylandCursor()
|
||||
{
|
||||
if (!mCursor)
|
||||
mCursor.reset(new QWaylandCursor(this));
|
||||
mCursor.reset(mWaylandIntegration->createPlatformCursor(this));
|
||||
return mCursor.data();
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ public:
|
||||
Pointer *pointer() const;
|
||||
Touch *touch() const;
|
||||
|
||||
private:
|
||||
protected:
|
||||
QWaylandDisplay *mQDisplay = nullptr;
|
||||
struct wl_display *mDisplay = nullptr;
|
||||
|
||||
|
@ -52,6 +52,7 @@
|
||||
#include "qwaylanddnd_p.h"
|
||||
#include "qwaylandwindowmanagerintegration_p.h"
|
||||
#include "qwaylandscreen_p.h"
|
||||
#include "qwaylandcursor_p.h"
|
||||
|
||||
#if defined(Q_OS_MACOS)
|
||||
# include <QtGui/private/qcoretextfontdatabase_p.h>
|
||||
@ -112,22 +113,12 @@ QWaylandIntegration::QWaylandIntegration()
|
||||
#else
|
||||
: mFontDb(new QGenericUnixFontDatabase())
|
||||
#endif
|
||||
, mNativeInterface(new QWaylandNativeInterface(this))
|
||||
{
|
||||
initializeInputDeviceIntegration();
|
||||
mDisplay.reset(new QWaylandDisplay(this));
|
||||
if (!mDisplay->isInitialized()) {
|
||||
mFailed = true;
|
||||
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()
|
||||
@ -193,8 +184,30 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
|
||||
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()
|
||||
{
|
||||
// Support platform specicif initialization
|
||||
initializePlatform();
|
||||
|
||||
QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
|
||||
QObject::connect(dispatcher, SIGNAL(aboutToBlock()), 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);
|
||||
}
|
||||
|
||||
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)
|
||||
QPlatformVulkanInstance *QWaylandIntegration::createPlatformVulkanInstance(QVulkanInstance *instance) const
|
||||
{
|
||||
@ -418,7 +441,7 @@ void QWaylandIntegration::initializeShellIntegration()
|
||||
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) {
|
||||
return mInputDeviceIntegration->createInputDevice(display, version, id);
|
||||
|
@ -67,6 +67,8 @@ class QWaylandServerBufferIntegration;
|
||||
class QWaylandShellIntegration;
|
||||
class QWaylandInputDeviceIntegration;
|
||||
class QWaylandInputDevice;
|
||||
class QWaylandScreen;
|
||||
class QWaylandCursor;
|
||||
|
||||
class Q_WAYLAND_CLIENT_EXPORT QWaylandIntegration : public QPlatformIntegration
|
||||
{
|
||||
@ -117,7 +119,9 @@ public:
|
||||
QPlatformVulkanInstance *createPlatformVulkanInstance(QVulkanInstance *instance) const override;
|
||||
#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 QWaylandServerBufferIntegration *serverBufferIntegration() const;
|
||||
@ -125,19 +129,24 @@ public:
|
||||
|
||||
void reconfigureInputContext();
|
||||
|
||||
private:
|
||||
protected:
|
||||
// NOTE: mDisplay *must* be destructed after mDrag and mClientBufferIntegration
|
||||
// and mShellIntegration.
|
||||
// Do not move this definition into the private section at the bottom.
|
||||
QScopedPointer<QWaylandDisplay> mDisplay;
|
||||
|
||||
protected:
|
||||
virtual QPlatformNativeInterface *createPlatformNativeInterface();
|
||||
|
||||
QScopedPointer<QWaylandClientBufferIntegration> mClientBufferIntegration;
|
||||
QScopedPointer<QWaylandServerBufferIntegration> mServerBufferIntegration;
|
||||
QScopedPointer<QWaylandShellIntegration> mShellIntegration;
|
||||
QScopedPointer<QWaylandInputDeviceIntegration> mInputDeviceIntegration;
|
||||
|
||||
QScopedPointer<QPlatformInputContext> mInputContext;
|
||||
|
||||
private:
|
||||
void initializePlatform();
|
||||
void initializeClientBufferIntegration();
|
||||
void initializeServerBufferIntegration();
|
||||
void initializeShellIntegration();
|
||||
@ -152,7 +161,6 @@ private:
|
||||
QScopedPointer<QPlatformDrag> mDrag;
|
||||
#endif
|
||||
QScopedPointer<QPlatformNativeInterface> mNativeInterface;
|
||||
QScopedPointer<QPlatformInputContext> mInputContext;
|
||||
#if QT_CONFIG(accessibility)
|
||||
mutable QScopedPointer<QPlatformAccessibility> mAccessibility;
|
||||
#endif
|
||||
|
@ -113,7 +113,7 @@ public:
|
||||
static QWaylandScreen *waylandScreenFromWindow(QWindow *window);
|
||||
static QWaylandScreen *fromWlOutput(::wl_output *output);
|
||||
|
||||
private:
|
||||
protected:
|
||||
void output_mode(uint32_t flags, int width, int height, int refresh) override;
|
||||
void output_geometry(int32_t x, int32_t y,
|
||||
int32_t width, int32_t height,
|
||||
@ -149,10 +149,6 @@ private:
|
||||
bool mOutputDone = false;
|
||||
bool mXdgOutputDone = false;
|
||||
bool mInitialized = false;
|
||||
|
||||
#if QT_CONFIG(cursor)
|
||||
QScopedPointer<QWaylandCursor> mWaylandCursor;
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -214,6 +214,8 @@ signals:
|
||||
void wlSurfaceDestroyed();
|
||||
|
||||
protected:
|
||||
void sendExposeEvent(const QRect &rect);
|
||||
|
||||
QWaylandDisplay *mDisplay = nullptr;
|
||||
QScopedPointer<QWaylandSurface> mSurface;
|
||||
QWaylandShellSurface *mShellSurface = nullptr;
|
||||
@ -268,7 +270,6 @@ private:
|
||||
bool shouldCreateShellSurface() const;
|
||||
bool shouldCreateSubSurface() const;
|
||||
void reset();
|
||||
void sendExposeEvent(const QRect &rect);
|
||||
static void closePopups(QWaylandWindow *parent);
|
||||
QPlatformScreen *calculateScreenFromSurfaceEvents() const;
|
||||
void setOpaqueArea(const QRegion &opaqueArea);
|
||||
|
Loading…
x
Reference in New Issue
Block a user