diff --git a/src/3rdparty/wayland/protocols/qt_attribution.json b/src/3rdparty/wayland/protocols/qt_attribution.json index 76fd33d37f9..f35dec4f348 100644 --- a/src/3rdparty/wayland/protocols/qt_attribution.json +++ b/src/3rdparty/wayland/protocols/qt_attribution.json @@ -26,9 +26,9 @@ "Files": "ivi-controller.xml ivi-application.xml", "Description": "\"Wayland IVI Extension\" is forked from IVI Layer Management to define a common set of APIs by wayland style protocol and provide reference implementation which can be loaded on Weston.", - "Homepage": "http://projects.genivi.org/wayland-ivi-extension", + "Homepage": "https://at.projects.genivi.org/wiki/display/WIE/Wayland+IVI+Extension+Home", "Version": "1.9.1", - "DownloadLocation": "http://git.projects.genivi.org/?p=wayland-ivi-extension.git;a=commit;h=44598504503eea5ac7f94c88477a5a78bda01f30", + "DownloadLocation": "https://github.com/GENIVI/wayland-ivi-extension/releases/tag/1.9.1", "LicenseId": "MIT", "License": "MIT License", "LicenseFile": "MIT_LICENSE.txt", diff --git a/src/plugins/platforms/wayland/client.pro b/src/plugins/platforms/wayland/client.pro index 824c715b05c..eae7ad52ea2 100644 --- a/src/plugins/platforms/wayland/client.pro +++ b/src/plugins/platforms/wayland/client.pro @@ -23,7 +23,6 @@ QMAKE_USE += wayland-client INCLUDEPATH += $$PWD/../shared WAYLANDCLIENTSOURCES += \ - ../3rdparty/protocol/wayland.xml \ ../extensions/surface-extension.xml \ ../extensions/touch-extension.xml \ ../extensions/qtkey-extension.xml \ @@ -32,6 +31,9 @@ WAYLANDCLIENTSOURCES += \ ../3rdparty/protocol/xdg-shell.xml \ ../3rdparty/protocol/xdg-shell-unstable-v6.xml \ +WAYLANDCLIENTSOURCES_SYSTEM += \ + ../3rdparty/protocol/wayland.xml \ + SOURCES += qwaylandintegration.cpp \ qwaylandnativeinterface.cpp \ qwaylandshmbackingstore.cpp \ @@ -40,9 +42,6 @@ SOURCES += qwaylandintegration.cpp \ qwaylandwindow.cpp \ qwaylandscreen.cpp \ qwaylandshmwindow.cpp \ - qwaylanddataoffer.cpp \ - qwaylanddatadevicemanager.cpp \ - qwaylanddatasource.cpp \ qwaylandshellsurface.cpp \ qwaylandwlshellsurface.cpp \ qwaylandwlshellintegration.cpp \ @@ -76,9 +75,6 @@ HEADERS += qwaylandintegration_p.h \ qwaylandinputdevice_p.h \ qwaylandbuffer_p.h \ qwaylandshmwindow_p.h \ - qwaylanddataoffer_p.h \ - qwaylanddatadevicemanager_p.h \ - qwaylanddatasource_p.h \ qwaylandshellsurface_p.h \ qwaylandwlshellsurface_p.h \ qwaylandwlshellintegration_p.h \ @@ -123,13 +119,25 @@ qtConfig(cursor) { SOURCES += \ qwaylandcursor.cpp } + +qtConfig(wayland-datadevice) { + HEADERS += \ + qwaylanddatadevice_p.h \ + qwaylanddatadevicemanager_p.h \ + qwaylanddataoffer_p.h \ + qwaylanddatasource_p.h + SOURCES += \ + qwaylanddatadevice.cpp \ + qwaylanddatadevicemanager.cpp \ + qwaylanddataoffer.cpp \ + qwaylanddatasource.cpp +} + qtConfig(draganddrop) { HEADERS += \ - qwaylanddnd_p.h \ - qwaylanddatadevice_p.h + qwaylanddnd_p.h SOURCES += \ - qwaylanddnd.cpp \ - qwaylanddatadevice.cpp + qwaylanddnd.cpp } CONFIG += generated_privates diff --git a/src/plugins/platforms/wayland/configure.json b/src/plugins/platforms/wayland/configure.json index b2a8fbc0b3e..c29a8b609d8 100644 --- a/src/plugins/platforms/wayland/configure.json +++ b/src/plugins/platforms/wayland/configure.json @@ -76,13 +76,17 @@ "condition": "!config.win32 && libs.wayland-client && libs.wayland-cursor && tests.wayland-scanner", "output": [ "privateFeature" ] }, + "wayland-datadevice": { + "condition": "features.draganddrop || features.clipboard", + "output": [ "privateFeature" ] + }, "wayland-egl": { "label": "EGL", "condition": "features.wayland-client && features.opengl && features.egl && libs.wayland-egl", "output": [ "privateFeature" ] }, "wayland-brcm": { - "label": "Rasberry Pi", + "label": "Raspberry Pi", "condition": "features.wayland-client && features.eglfs_brcm", "output": [ "privateFeature" ] }, diff --git a/src/plugins/platforms/wayland/plugins/decorations/bradient/main.cpp b/src/plugins/platforms/wayland/plugins/decorations/bradient/main.cpp index 074c74522d2..ceb07c8032d 100644 --- a/src/plugins/platforms/wayland/plugins/decorations/bradient/main.cpp +++ b/src/plugins/platforms/wayland/plugins/decorations/bradient/main.cpp @@ -211,7 +211,6 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device) p.setRenderHint(QPainter::Antialiasing); // Title bar - QPoint gradCenter(top.center()+ QPoint(30, 60)); QLinearGradient grad(top.topLeft(), top.bottomLeft()); QColor base(m_backgroundColor); grad.setColorAt(0, base.lighter(100)); diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/xcomposite-egl/main.cpp b/src/plugins/platforms/wayland/plugins/hardwareintegration/xcomposite-egl/main.cpp index 07222f2374c..585285fae05 100644 --- a/src/plugins/platforms/wayland/plugins/hardwareintegration/xcomposite-egl/main.cpp +++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/xcomposite-egl/main.cpp @@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE namespace QtWaylandClient { -class QWaylandXCompositeEglClientBufferIntegrationPlugin : public QWaylandClientBufferIntegrationPlugin +class QWaylandXCompositeEglClientBufferPlugin : public QWaylandClientBufferIntegrationPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID QWaylandClientBufferIntegrationFactoryInterface_iid FILE "xcomposite-egl.json") @@ -52,7 +52,7 @@ public: QWaylandClientBufferIntegration *create(const QString&, const QStringList&) override; }; -QWaylandClientBufferIntegration *QWaylandXCompositeEglClientBufferIntegrationPlugin::create(const QString& system, const QStringList& paramList) +QWaylandClientBufferIntegration *QWaylandXCompositeEglClientBufferPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); Q_UNUSED(system); diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/xcomposite-egl/xcomposite-egl.pro b/src/plugins/platforms/wayland/plugins/hardwareintegration/xcomposite-egl/xcomposite-egl.pro index c8734084b0c..83bd4fe8d84 100644 --- a/src/plugins/platforms/wayland/plugins/hardwareintegration/xcomposite-egl/xcomposite-egl.pro +++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/xcomposite-egl/xcomposite-egl.pro @@ -11,5 +11,5 @@ SOURCES += \ main.cpp PLUGIN_TYPE = wayland-graphics-integration-client -PLUGIN_CLASS_NAME = QWaylandXCompositeEglClientBufferIntegrationPlugin +PLUGIN_CLASS_NAME = QWaylandXCompositeEglClientBufferPlugin load(qt_plugin) diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/xcomposite-glx/main.cpp b/src/plugins/platforms/wayland/plugins/hardwareintegration/xcomposite-glx/main.cpp index 00fa255b52e..f7b878d96c2 100644 --- a/src/plugins/platforms/wayland/plugins/hardwareintegration/xcomposite-glx/main.cpp +++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/xcomposite-glx/main.cpp @@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE namespace QtWaylandClient { -class QWaylandXCompositeGlxClientBufferIntegrationPlugin : public QWaylandClientBufferIntegrationPlugin +class QWaylandXCompositeGlxClientBufferPlugin : public QWaylandClientBufferIntegrationPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID QWaylandClientBufferIntegrationFactoryInterface_iid FILE "xcomposite-glx.json") @@ -52,7 +52,7 @@ public: QWaylandClientBufferIntegration *create(const QString&, const QStringList&) override; }; -QWaylandClientBufferIntegration *QWaylandXCompositeGlxClientBufferIntegrationPlugin::create(const QString& system, const QStringList& paramList) +QWaylandClientBufferIntegration *QWaylandXCompositeGlxClientBufferPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); Q_UNUSED(system); diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/xcomposite-glx/xcomposite-glx.pro b/src/plugins/platforms/wayland/plugins/hardwareintegration/xcomposite-glx/xcomposite-glx.pro index fb5ad15f84a..804ca386197 100644 --- a/src/plugins/platforms/wayland/plugins/hardwareintegration/xcomposite-glx/xcomposite-glx.pro +++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/xcomposite-glx/xcomposite-glx.pro @@ -8,5 +8,5 @@ SOURCES += \ main.cpp PLUGIN_TYPE = wayland-graphics-integration-client -PLUGIN_CLASS_NAME = QWaylandXCompositeGlxClientBufferIntegrationPlugin +PLUGIN_CLASS_NAME = QWaylandXCompositeGlxClientBufferPlugin load(qt_plugin) diff --git a/src/plugins/platforms/wayland/qwaylandclipboard.cpp b/src/plugins/platforms/wayland/qwaylandclipboard.cpp index 68fb737ccb0..5da1202687e 100644 --- a/src/plugins/platforms/wayland/qwaylandclipboard.cpp +++ b/src/plugins/platforms/wayland/qwaylandclipboard.cpp @@ -44,8 +44,6 @@ #include "qwaylanddatasource_p.h" #include "qwaylanddatadevice_p.h" -#if QT_CONFIG(draganddrop) - QT_BEGIN_NAMESPACE namespace QtWaylandClient { @@ -117,5 +115,3 @@ bool QWaylandClipboard::ownsMode(QClipboard::Mode mode) const } QT_END_NAMESPACE - -#endif // draganddrop diff --git a/src/plugins/platforms/wayland/qwaylandclipboard_p.h b/src/plugins/platforms/wayland/qwaylandclipboard_p.h index 211a969420b..28336202241 100644 --- a/src/plugins/platforms/wayland/qwaylandclipboard_p.h +++ b/src/plugins/platforms/wayland/qwaylandclipboard_p.h @@ -57,7 +57,8 @@ #include -#if QT_CONFIG(draganddrop) +QT_REQUIRE_CONFIG(clipboard); + QT_BEGIN_NAMESPACE namespace QtWaylandClient { @@ -85,6 +86,4 @@ private: QT_END_NAMESPACE -#endif // draganddrop - #endif // QWAYLANDCLIPBOARD_H diff --git a/src/plugins/platforms/wayland/qwaylandcursor.cpp b/src/plugins/platforms/wayland/qwaylandcursor.cpp index e3e3469be3c..7caa247e52f 100644 --- a/src/plugins/platforms/wayland/qwaylandcursor.cpp +++ b/src/plugins/platforms/wayland/qwaylandcursor.cpp @@ -143,31 +143,6 @@ void QWaylandCursor::changeCursor(QCursor *cursor, QWindow *window) mDisplay->setCursor(buffer, image); } -void QWaylandDisplay::setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image) -{ - /* Qt doesn't tell us which input device we should set the cursor - * for, so set it for all devices. */ - for (int i = 0; i < mInputDevices.count(); i++) { - QWaylandInputDevice *inputDevice = mInputDevices.at(i); - inputDevice->setCursor(buffer, image); - } -} - -void QWaylandDisplay::setCursor(const QSharedPointer &buffer, const QPoint &hotSpot) -{ - /* Qt doesn't tell us which input device we should set the cursor - * for, so set it for all devices. */ - for (int i = 0; i < mInputDevices.count(); i++) { - QWaylandInputDevice *inputDevice = mInputDevices.at(i); - inputDevice->setCursor(buffer, hotSpot); - } -} - -QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const -{ - return mInputDevices.isEmpty() ? 0 : mInputDevices.first(); -} - void QWaylandCursor::pointerEvent(const QMouseEvent &event) { mLastPos = event.globalPos(); diff --git a/src/plugins/platforms/wayland/qwaylanddatadevice.cpp b/src/plugins/platforms/wayland/qwaylanddatadevice.cpp index ebd3ce1bff1..33068c5e97a 100644 --- a/src/plugins/platforms/wayland/qwaylanddatadevice.cpp +++ b/src/plugins/platforms/wayland/qwaylanddatadevice.cpp @@ -58,8 +58,6 @@ #include #include -#if QT_CONFIG(draganddrop) - QT_BEGIN_NAMESPACE namespace QtWaylandClient { @@ -103,6 +101,7 @@ void QWaylandDataDevice::setSelectionSource(QWaylandDataSource *source) m_selectionSource.reset(source); } +#if QT_CONFIG(draganddrop) QWaylandDataOffer *QWaylandDataDevice::dragOffer() const { return m_dragOffer.data(); @@ -124,12 +123,14 @@ void QWaylandDataDevice::cancelDrag() { m_dragSource.reset(); } +#endif void QWaylandDataDevice::data_device_data_offer(struct ::wl_data_offer *id) { new QWaylandDataOffer(m_display, id); } +#if QT_CONFIG(draganddrop) void QWaylandDataDevice::data_device_drop() { QDrag *drag = static_cast(QGuiApplicationPrivate::platformIntegration()->drag())->currentDrag(); @@ -229,6 +230,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, 0); } } +#endif // QT_CONFIG(draganddrop) void QWaylandDataDevice::data_device_selection(wl_data_offer *id) { @@ -250,6 +252,7 @@ void QWaylandDataDevice::selectionSourceCancelled() #endif } +#if QT_CONFIG(draganddrop) void QWaylandDataDevice::dragSourceCancelled() { m_dragSource.reset(); @@ -272,9 +275,8 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con } return pnt; } +#endif // QT_CONFIG(draganddrop) } QT_END_NAMESPACE - -#endif // draganddrop diff --git a/src/plugins/platforms/wayland/qwaylanddatadevice_p.h b/src/plugins/platforms/wayland/qwaylanddatadevice_p.h index 1ec8761b913..7fb0003b4dd 100644 --- a/src/plugins/platforms/wayland/qwaylanddatadevice_p.h +++ b/src/plugins/platforms/wayland/qwaylanddatadevice_p.h @@ -52,14 +52,14 @@ // We mean it. // -#include +#include #include #include #include #include -#if QT_CONFIG(draganddrop) +QT_REQUIRE_CONFIG(wayland_datadevice); QT_BEGIN_NAMESPACE @@ -87,25 +87,35 @@ public: QWaylandDataSource *selectionSource() const; void setSelectionSource(QWaylandDataSource *source); +#if QT_CONFIG(draganddrop) QWaylandDataOffer *dragOffer() const; void startDrag(QMimeData *mimeData, QWaylandWindow *icon); void cancelDrag(); +#endif protected: void data_device_data_offer(struct ::wl_data_offer *id) override; + +#if QT_CONFIG(draganddrop) void data_device_drop() override; void data_device_enter(uint32_t serial, struct ::wl_surface *surface, wl_fixed_t x, wl_fixed_t y, struct ::wl_data_offer *id) override; void data_device_leave() override; void data_device_motion(uint32_t time, wl_fixed_t x, wl_fixed_t y) override; +#endif void data_device_selection(struct ::wl_data_offer *id) override; private Q_SLOTS: void selectionSourceCancelled(); + +#if QT_CONFIG(draganddrop) void dragSourceCancelled(); void dragSourceTargetChanged(const QString &mimeType); +#endif private: +#if QT_CONFIG(draganddrop) QPoint calculateDragPosition(int x, int y, QWindow *wnd) const; +#endif QWaylandDisplay *m_display; QWaylandInputDevice *m_inputDevice; @@ -123,6 +133,4 @@ private: QT_END_NAMESPACE -#endif // draganddrop - #endif // QWAYLANDDATADEVICE_H diff --git a/src/plugins/platforms/wayland/qwaylanddatadevicemanager.cpp b/src/plugins/platforms/wayland/qwaylanddatadevicemanager.cpp index c398b86fd5f..35d67307fc3 100644 --- a/src/plugins/platforms/wayland/qwaylanddatadevicemanager.cpp +++ b/src/plugins/platforms/wayland/qwaylanddatadevicemanager.cpp @@ -46,8 +46,6 @@ #include -#if QT_CONFIG(draganddrop) - QT_BEGIN_NAMESPACE namespace QtWaylandClient { @@ -82,5 +80,3 @@ QWaylandDisplay *QWaylandDataDeviceManager::display() const } QT_END_NAMESPACE - -#endif // draganddrop diff --git a/src/plugins/platforms/wayland/qwaylanddatadevicemanager_p.h b/src/plugins/platforms/wayland/qwaylanddatadevicemanager_p.h index e7fc2113a35..3daf780aaa9 100644 --- a/src/plugins/platforms/wayland/qwaylanddatadevicemanager_p.h +++ b/src/plugins/platforms/wayland/qwaylanddatadevicemanager_p.h @@ -51,10 +51,10 @@ // We mean it. // -#include +#include #include -#if QT_CONFIG(draganddrop) +QT_REQUIRE_CONFIG(wayland_datadevice); QT_BEGIN_NAMESPACE @@ -83,6 +83,4 @@ private: QT_END_NAMESPACE -#endif // draganddrop - #endif // QWAYLANDDATADEVICEMANAGER_H diff --git a/src/plugins/platforms/wayland/qwaylanddataoffer.cpp b/src/plugins/platforms/wayland/qwaylanddataoffer.cpp index 56a18f007d3..2491c658b12 100644 --- a/src/plugins/platforms/wayland/qwaylanddataoffer.cpp +++ b/src/plugins/platforms/wayland/qwaylanddataoffer.cpp @@ -47,8 +47,6 @@ #include -#if QT_CONFIG(draganddrop) - QT_BEGIN_NAMESPACE namespace QtWaylandClient { @@ -183,5 +181,3 @@ int QWaylandMimeData::readData(int fd, QByteArray &data) const } QT_END_NAMESPACE - -#endif // draganddrop diff --git a/src/plugins/platforms/wayland/qwaylanddataoffer_p.h b/src/plugins/platforms/wayland/qwaylanddataoffer_p.h index c7520f3e55c..c9b9c21f17d 100644 --- a/src/plugins/platforms/wayland/qwaylanddataoffer_p.h +++ b/src/plugins/platforms/wayland/qwaylanddataoffer_p.h @@ -53,10 +53,11 @@ #include -#include +#include #include -#if QT_CONFIG(draganddrop) +QT_REQUIRE_CONFIG(wayland_datadevice); + QT_BEGIN_NAMESPACE namespace QtWaylandClient { @@ -106,5 +107,4 @@ private: } QT_END_NAMESPACE -#endif // draganddrop #endif diff --git a/src/plugins/platforms/wayland/qwaylanddatasource.cpp b/src/plugins/platforms/wayland/qwaylanddatasource.cpp index c61de181ba6..0c6ad50e4b7 100644 --- a/src/plugins/platforms/wayland/qwaylanddatasource.cpp +++ b/src/plugins/platforms/wayland/qwaylanddatasource.cpp @@ -50,8 +50,6 @@ #include #include -#if QT_CONFIG(draganddrop) - QT_BEGIN_NAMESPACE namespace QtWaylandClient { @@ -108,5 +106,3 @@ void QWaylandDataSource::data_source_target(const QString &mime_type) } QT_END_NAMESPACE - -#endif // draganddrop diff --git a/src/plugins/platforms/wayland/qwaylanddatasource_p.h b/src/plugins/platforms/wayland/qwaylanddatasource_p.h index 0221304c80d..bba003f561b 100644 --- a/src/plugins/platforms/wayland/qwaylanddatasource_p.h +++ b/src/plugins/platforms/wayland/qwaylanddatasource_p.h @@ -54,9 +54,9 @@ #include #include -#include +#include -#if QT_CONFIG(draganddrop) +QT_REQUIRE_CONFIG(wayland_datadevice); QT_BEGIN_NAMESPACE @@ -94,6 +94,4 @@ private: QT_END_NAMESPACE -#endif // draganddrop - #endif // QWAYLANDDATASOURCE_H diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index 851d715b77f..86cfe1a0d6c 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -47,7 +47,9 @@ #if QT_CONFIG(clipboard) #include "qwaylandclipboard_p.h" #endif +#if QT_CONFIG(wayland_datadevice) #include "qwaylanddatadevicemanager_p.h" +#endif #include "qwaylandhardwareintegration_p.h" #include "qwaylandxdgshell_p.h" #include "qwaylandxdgsurface_p.h" @@ -122,7 +124,7 @@ QWaylandWindowManagerIntegration *QWaylandDisplay::windowManagerIntegration() co QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration) : mWaylandIntegration(waylandIntegration) -#if QT_CONFIG(draganddrop) +#if QT_CONFIG(wayland_datadevice) , mDndSelectionHandler(0) #endif , mWindowExtension(0) @@ -162,7 +164,7 @@ QWaylandDisplay::~QWaylandDisplay(void) mWaylandIntegration->destroyScreen(screen); } mScreens.clear(); -#if QT_CONFIG(draganddrop) +#if QT_CONFIG(wayland_datadevice) delete mDndSelectionHandler.take(); #endif wl_display_disconnect(mDisplay); @@ -257,7 +259,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin } else if (interface == QStringLiteral("wl_seat")) { QWaylandInputDevice *inputDevice = mWaylandIntegration->createInputDevice(this, version, id); mInputDevices.append(inputDevice); -#if QT_CONFIG(draganddrop) +#if QT_CONFIG(wayland_datadevice) } else if (interface == QStringLiteral("wl_data_device_manager")) { mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id)); #endif @@ -421,7 +423,14 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic if (mLastKeyboardFocus == keyboardFocus) return; - mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus); + if (mWaylandIntegration->mShellIntegration) { + mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus); + } else { + if (keyboardFocus) + handleWindowActivated(keyboardFocus); + if (mLastKeyboardFocus) + handleWindowDeactivated(mLastKeyboardFocus); + } mLastKeyboardFocus = keyboardFocus; } @@ -461,6 +470,33 @@ void QWaylandDisplay::requestWaylandSync() wl_callback_add_listener(mSyncCallback, &syncCallbackListener, this); } +QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const +{ + return mInputDevices.isEmpty() ? 0 : mInputDevices.first(); +} + +#if QT_CONFIG(cursor) +void QWaylandDisplay::setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image) +{ + /* Qt doesn't tell us which input device we should set the cursor + * for, so set it for all devices. */ + for (int i = 0; i < mInputDevices.count(); i++) { + QWaylandInputDevice *inputDevice = mInputDevices.at(i); + inputDevice->setCursor(buffer, image); + } +} + +void QWaylandDisplay::setCursor(const QSharedPointer &buffer, const QPoint &hotSpot) +{ + /* Qt doesn't tell us which input device we should set the cursor + * for, so set it for all devices. */ + for (int i = 0; i < mInputDevices.count(); i++) { + QWaylandInputDevice *inputDevice = mInputDevices.at(i); + inputDevice->setCursor(buffer, hotSpot); + } +} +#endif // QT_CONFIG(cursor) + } QT_END_NAMESPACE diff --git a/src/plugins/platforms/wayland/qwaylanddisplay_p.h b/src/plugins/platforms/wayland/qwaylanddisplay_p.h index e96a89176ba..35d861760e5 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay_p.h +++ b/src/plugins/platforms/wayland/qwaylanddisplay_p.h @@ -61,7 +61,7 @@ #include #include -#include +#include #include #include @@ -123,10 +123,10 @@ public: QWaylandClientBufferIntegration *clientBufferIntegration() const; QWaylandWindowManagerIntegration *windowManagerIntegration() const; - +#if QT_CONFIG(cursor) void setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image); void setCursor(const QSharedPointer &buffer, const QPoint &hotSpot); - +#endif struct wl_display *wl_display() const { return mDisplay; } struct ::wl_registry *wl_registry() { return object(); } @@ -137,7 +137,7 @@ public: QList inputDevices() const { return mInputDevices; } QWaylandInputDevice *defaultInputDevice() const; QWaylandInputDevice *currentInputDevice() const { return defaultInputDevice(); } -#if QT_CONFIG(draganddrop) +#if QT_CONFIG(wayland_datadevice) QWaylandDataDeviceManager *dndSelectionHandler() const { return mDndSelectionHandler.data(); } #endif QtWayland::qt_surface_extension *windowExtension() const { return mWindowExtension.data(); } @@ -202,7 +202,7 @@ private: QList mInputDevices; QList mRegistryListeners; QWaylandIntegration *mWaylandIntegration; -#if QT_CONFIG(draganddrop) +#if QT_CONFIG(wayland_datadevice) QScopedPointer mDndSelectionHandler; #endif QScopedPointer mWindowExtension; diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index fb22c95e673..b0c6394e2b0 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -42,8 +42,10 @@ #include "qwaylandintegration_p.h" #include "qwaylandwindow_p.h" #include "qwaylandbuffer_p.h" +#if QT_CONFIG(wayland_datadevice) #include "qwaylanddatadevice_p.h" #include "qwaylanddatadevicemanager_p.h" +#endif #include "qwaylandtouch_p.h" #include "qwaylandscreen_p.h" #include "qwaylandcursor_p.h" @@ -187,7 +189,9 @@ QWaylandInputDevice::QWaylandInputDevice(QWaylandDisplay *display, int version, , mDisplay(display->wl_display()) , mVersion(qMin(version, 4)) , mCaps(0) +#if QT_CONFIG(wayland_datadevice) , mDataDevice(0) +#endif , mKeyboard(0) , mPointer(0) , mTouch(0) @@ -196,7 +200,7 @@ QWaylandInputDevice::QWaylandInputDevice(QWaylandDisplay *display, int version, , mSerial(0) , mTouchDevice(0) { -#if QT_CONFIG(draganddrop) +#if QT_CONFIG(wayland_datadevice) if (mQDisplay->dndSelectionHandler()) { mDataDevice = mQDisplay->dndSelectionHandler()->getDataDevice(this); } @@ -286,6 +290,7 @@ void QWaylandInputDevice::handleEndDrag() mPointer->releaseButtons(); } +#if QT_CONFIG(wayland_datadevice) void QWaylandInputDevice::setDataDevice(QWaylandDataDevice *device) { mDataDevice = device; @@ -296,6 +301,7 @@ QWaylandDataDevice *QWaylandInputDevice::dataDevice() const Q_ASSERT(mDataDevice); return mDataDevice; } +#endif void QWaylandInputDevice::setTextInput(QWaylandTextInput *textInput) { diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice_p.h b/src/plugins/platforms/wayland/qwaylandinputdevice_p.h index d8bd0062f29..4d0a4759751 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice_p.h +++ b/src/plugins/platforms/wayland/qwaylandinputdevice_p.h @@ -111,8 +111,10 @@ public: void handleWindowDestroyed(QWaylandWindow *window); void handleEndDrag(); +#if QT_CONFIG(wayland_datadevice) void setDataDevice(QWaylandDataDevice *device); QWaylandDataDevice *dataDevice() const; +#endif void setTextInput(QWaylandTextInput *textInput); QWaylandTextInput *textInput() const; @@ -143,7 +145,9 @@ private: struct wl_surface *pointerSurface; +#if QT_CONFIG(wayland_datadevice) QWaylandDataDevice *mDataDevice; +#endif Keyboard *mKeyboard; Pointer *mPointer; diff --git a/src/plugins/platforms/wayland/qwaylandshmbackingstore_p.h b/src/plugins/platforms/wayland/qwaylandshmbackingstore_p.h index 71f98e30cfe..8564cc9d223 100644 --- a/src/plugins/platforms/wayland/qwaylandshmbackingstore_p.h +++ b/src/plugins/platforms/wayland/qwaylandshmbackingstore_p.h @@ -90,7 +90,7 @@ public: QWaylandShmBackingStore(QWindow *window); ~QWaylandShmBackingStore(); - QPaintDevice *paintDevice(); + QPaintDevice *paintDevice() override; void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) override; void resize(const QSize &size, const QRegion &staticContents) override; void resize(const QSize &size); diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 540403bceba..03cbb4c33d7 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -40,7 +40,6 @@ #include "qwaylandwindow_p.h" #include "qwaylandbuffer_p.h" -#include "qwaylanddatadevice_p.h" #include "qwaylanddisplay_p.h" #include "qwaylandinputdevice_p.h" #include "qwaylandscreen_p.h" @@ -54,6 +53,11 @@ #include "qwaylanddecorationfactory_p.h" #include "qwaylandshmbackingstore_p.h" +#if QT_CONFIG(wayland_datadevice) +#include "qwaylanddatadevice_p.h" +#endif + + #include #include #include @@ -95,6 +99,7 @@ QWaylandWindow::QWaylandWindow(QWindow *window) { static WId id = 1; mWindowId = id++; + initializeWlSurface(); } QWaylandWindow::~QWaylandWindow() @@ -127,7 +132,7 @@ void QWaylandWindow::initWindow() return; if (!isInitialized()) - init(mDisplay->createSurface(static_cast(this))); + initializeWlSurface(); if (shouldCreateSubSurface()) { Q_ASSERT(!mSubSurfaceWindow); @@ -159,7 +164,9 @@ void QWaylandWindow::initWindow() // when available. if (!QGuiApplication::desktopFileName().isEmpty()) { QString name = QGuiApplication::desktopFileName(); - mShellSurface->setAppId(name.replace(QRegularExpression(QLatin1String("\\.desktop$")), QString())); + if (name.endsWith(QLatin1String(".desktop"))) + name.chop(8); + mShellSurface->setAppId(name); } else { QFileInfo fi = QCoreApplication::instance()->applicationFilePath(); QStringList domainName = @@ -200,6 +207,11 @@ void QWaylandWindow::initWindow() mFlags = window()->flags(); } +void QWaylandWindow::initializeWlSurface() +{ + init(mDisplay->createSurface(static_cast(this))); +} + bool QWaylandWindow::shouldCreateShellSurface() const { if (shouldCreateSubSurface()) @@ -225,7 +237,8 @@ void QWaylandWindow::reset() mShellSurface = 0; delete mSubSurfaceWindow; mSubSurfaceWindow = 0; - destroy(); + if (isInitialized()) + destroy(); if (mFrameCallback) wl_callback_destroy(mFrameCallback); @@ -360,8 +373,11 @@ void QWaylandWindow::setMask(const QRegion &mask) mMask = mask; + if (!isInitialized()) + return; + if (mMask.isEmpty()) { - set_input_region(0); + set_input_region(nullptr); } else { struct ::wl_region *region = mDisplay->createRegion(mMask); set_input_region(region); @@ -813,7 +829,7 @@ void QWaylandWindow::requestActivateWindow() void QWaylandWindow::unfocus() { -#if QT_CONFIG(draganddrop) +#if QT_CONFIG(clipboard) QWaylandInputDevice *inputDevice = mDisplay->currentInputDevice(); if (inputDevice && inputDevice->dataDevice()) { inputDevice->dataDevice()->invalidateSelectionOffer(); diff --git a/src/plugins/platforms/wayland/qwaylandwindow_p.h b/src/plugins/platforms/wayland/qwaylandwindow_p.h index 7e8db74bc6e..dd6a368c2df 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow_p.h +++ b/src/plugins/platforms/wayland/qwaylandwindow_p.h @@ -248,6 +248,7 @@ private: bool setWindowStateInternal(Qt::WindowStates flags); void setGeometry_helper(const QRect &rect); void initWindow(); + void initializeWlSurface(); bool shouldCreateShellSurface() const; bool shouldCreateSubSurface() const; void reset(); diff --git a/src/plugins/platforms/wayland/qwaylandxdgshellv6.cpp b/src/plugins/platforms/wayland/qwaylandxdgshellv6.cpp index 687973240eb..b50b6b1cf0b 100644 --- a/src/plugins/platforms/wayland/qwaylandxdgshellv6.cpp +++ b/src/plugins/platforms/wayland/qwaylandxdgshellv6.cpp @@ -199,6 +199,7 @@ void QWaylandXdgSurfaceV6::setPopup(QWaylandWindow *parent, QWaylandInputDevice positioner->set_anchor_rect(transientPos.x(), transientPos.y(), 1, 1); positioner->set_anchor(QtWayland::zxdg_positioner_v6::anchor_top | QtWayland::zxdg_positioner_v6::anchor_left); positioner->set_gravity(QtWayland::zxdg_positioner_v6::gravity_bottom | QtWayland::zxdg_positioner_v6::gravity_right); + positioner->set_size(m_window->geometry().width(), m_window->geometry().height()); m_popup = new Popup(this, parentXdgSurface, positioner); positioner->destroy(); delete positioner; diff --git a/src/plugins/platforms/wayland/shared/qwaylandxkb.cpp b/src/plugins/platforms/wayland/shared/qwaylandxkb.cpp index 3e04467deb3..a0e388a1c9b 100644 --- a/src/plugins/platforms/wayland/shared/qwaylandxkb.cpp +++ b/src/plugins/platforms/wayland/shared/qwaylandxkb.cpp @@ -43,10 +43,13 @@ #include #include +#if QT_CONFIG(xkbcommon_evdev) #include +#endif QT_BEGIN_NAMESPACE +#if QT_CONFIG(xkbcommon_evdev) static const uint32_t KeyTbl[] = { XKB_KEY_Escape, Qt::Key_Escape, XKB_KEY_Tab, Qt::Key_Tab, @@ -290,9 +293,11 @@ static xkb_keysym_t toKeysymFromTable(uint32_t key) return 0; } +#endif std::pair QWaylandXkb::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers &modifiers) { +#if QT_CONFIG(xkbcommon_evdev) QString text; uint utf32 = xkb_keysym_to_utf32(keysym); if (utf32) @@ -326,10 +331,15 @@ std::pair QWaylandXkb::keysymToQtKey(xkb_keysym_t keysym, Qt::Keyb } return { code, text }; +#else + Q_UNUSED(modifiers) + return { keysym, "" }; +#endif } Qt::KeyboardModifiers QWaylandXkb::modifiers(struct xkb_state *state) { +#if QT_CONFIG(xkbcommon_evdev) Qt::KeyboardModifiers modifiers = Qt::NoModifier; xkb_state_component cstate = static_cast(XKB_STATE_DEPRESSED | XKB_STATE_LATCHED | XKB_STATE_LOCKED); @@ -344,6 +354,10 @@ Qt::KeyboardModifiers QWaylandXkb::modifiers(struct xkb_state *state) modifiers |= Qt::MetaModifier; return modifiers; +#else + Q_UNUSED(state) + return Qt::NoModifier; +#endif } QEvent::Type QWaylandXkb::toQtEventType(uint32_t state) @@ -353,6 +367,7 @@ QEvent::Type QWaylandXkb::toQtEventType(uint32_t state) QVector QWaylandXkb::toKeysym(QKeyEvent *event) { +#if QT_CONFIG(xkbcommon_evdev) QVector keysyms; if (event->key() >= Qt::Key_F1 && event->key() <= Qt::Key_F35) { keysyms.append(XKB_KEY_F1 + (event->key() - Qt::Key_F1)); @@ -372,6 +387,9 @@ QVector QWaylandXkb::toKeysym(QKeyEvent *event) keysyms.append(toKeysymFromTable(event->key())); } return keysyms; +#else + return QVector() << event->nativeScanCode(); +#endif } QT_END_NAMESPACE diff --git a/src/plugins/platforms/wayland/shared/qwaylandxkb_p.h b/src/plugins/platforms/wayland/shared/qwaylandxkb_p.h index 230159fbb77..6fa1ea45b8e 100644 --- a/src/plugins/platforms/wayland/shared/qwaylandxkb_p.h +++ b/src/plugins/platforms/wayland/shared/qwaylandxkb_p.h @@ -41,9 +41,16 @@ #ifndef QWAYLANDXKB_H #define QWAYLANDXKB_H +#include #include #include + +#if QT_CONFIG(xkbcommon_evdev) #include +#else +typedef quint32 xkb_keysym_t; +struct xkb_state; +#endif #include