diff options
author | Tasuku Suzuki <tasuku.suzuki@qt.io> | 2017-01-13 20:19:17 +0900 |
---|---|---|
committer | Tasuku Suzuki <tasuku.suzuki@qt.io> | 2017-01-13 14:25:20 +0000 |
commit | cab7cb98d5b9530a3c265cc2436dd7d157e43f66 (patch) | |
tree | f17e25ec2bf58922fa83afc4e35c282fa0724a0e | |
parent | 479a487066484809ebdf3c2c16b3c87c72870483 (diff) | |
download | qtwayland-cab7cb98d5b9530a3c265cc2436dd7d157e43f66.tar.gz |
Fix build without feature.cursor
Change-Id: If244e7ac58133ae6fbefacfa243d47fa210140be
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r-- | src/client/client.pro | 13 | ||||
-rw-r--r-- | src/client/qwaylandcursor_p.h | 3 | ||||
-rw-r--r-- | src/client/qwaylandinputdevice.cpp | 10 | ||||
-rw-r--r-- | src/client/qwaylandinputdevice_p.h | 8 | ||||
-rw-r--r-- | src/client/qwaylandscreen.cpp | 8 | ||||
-rw-r--r-- | src/client/qwaylandscreen_p.h | 4 | ||||
-rw-r--r-- | src/client/qwaylandwindow.cpp | 8 | ||||
-rw-r--r-- | src/client/qwaylandwindow_p.h | 2 | ||||
-rw-r--r-- | src/imports/compositor/qwaylandmousetracker.cpp | 4 | ||||
-rw-r--r-- | src/plugins/decorations/bradient/main.cpp | 20 |
10 files changed, 77 insertions, 3 deletions
diff --git a/src/client/client.pro b/src/client/client.pro index f1338cc9..6904e905 100644 --- a/src/client/client.pro +++ b/src/client/client.pro @@ -18,7 +18,7 @@ CONFIG += link_pkgconfig wayland-scanner qtConfig(xkbcommon-evdev): \ QMAKE_USE_PRIVATE += xkbcommon_evdev -QMAKE_USE += wayland-client wayland-cursor +QMAKE_USE += wayland-client INCLUDEPATH += $$PWD/../shared @@ -35,7 +35,6 @@ SOURCES += qwaylandintegration.cpp \ qwaylandnativeinterface.cpp \ qwaylandshmbackingstore.cpp \ qwaylandinputdevice.cpp \ - qwaylandcursor.cpp \ qwaylanddisplay.cpp \ qwaylandwindow.cpp \ qwaylandscreen.cpp \ @@ -69,7 +68,6 @@ SOURCES += qwaylandintegration.cpp \ HEADERS += qwaylandintegration_p.h \ qwaylandnativeinterface_p.h \ - qwaylandcursor_p.h \ qwaylanddisplay_p.h \ qwaylandwindow_p.h \ qwaylandscreen_p.h \ @@ -116,6 +114,15 @@ include(shellintegration/shellintegration.pri) include(inputdeviceintegration/inputdeviceintegration.pri) include(global/global.pri) +qtConfig(cursor) { + QMAKE_USE += wayland-cursor + + HEADERS += \ + qwaylandcursor_p.h + SOURCES += \ + qwaylandcursor.cpp +} + CONFIG += generated_privates MODULE_PLUGIN_TYPES = \ wayland-graphics-integration-client \ diff --git a/src/client/qwaylandcursor_p.h b/src/client/qwaylandcursor_p.h index a7d188f5..97921f9c 100644 --- a/src/client/qwaylandcursor_p.h +++ b/src/client/qwaylandcursor_p.h @@ -55,6 +55,8 @@ #include <QtCore/QMap> #include <QtWaylandClient/qtwaylandclientglobal.h> +#if QT_CONFIG(cursor) + struct wl_cursor; struct wl_cursor_image; struct wl_cursor_theme; @@ -128,4 +130,5 @@ private: QT_END_NAMESPACE +#endif // cursor #endif // QWAYLANDCURSOR_H diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp index 4e8ef7b6..fb22c95e 100644 --- a/src/client/qwaylandinputdevice.cpp +++ b/src/client/qwaylandinputdevice.cpp @@ -62,7 +62,9 @@ #include <fcntl.h> #include <sys/mman.h> +#if QT_CONFIG(cursor) #include <wayland-cursor.h> +#endif #include <QtGui/QGuiApplication> @@ -145,10 +147,14 @@ QWaylandInputDevice::Pointer::Pointer(QWaylandInputDevice *p) : mParent(p) , mFocus(0) , mEnterSerial(0) +#if QT_CONFIG(cursor) , mCursorSerial(0) +#endif , mButtons(0) +#if QT_CONFIG(cursor) , mCursorBuffer(nullptr) , mCursorShape(Qt::BitmapCursor) +#endif { } @@ -344,6 +350,7 @@ Qt::KeyboardModifiers QWaylandInputDevice::Keyboard::modifiers() const return ret; } +#if QT_CONFIG(cursor) uint32_t QWaylandInputDevice::cursorSerial() const { if (mPointer) @@ -415,6 +422,7 @@ void QWaylandInputDevice::setCursor(const QSharedPointer<QWaylandBuffer> &buffer setCursor(buffer->buffer(), hotSpot, buffer->size()); mPixmapCursor = buffer; } +#endif class EnterEvent : public QWaylandPointerEvent { @@ -431,7 +439,9 @@ void QWaylandInputDevice::Pointer::pointer_enter(uint32_t serial, struct wl_surf return; QWaylandWindow *window = QWaylandWindow::fromWlSurface(surface); +#if QT_CONFIG(cursor) window->window()->setCursor(window->window()->cursor()); +#endif mFocus = window; mSurfacePos = QPointF(wl_fixed_to_double(sx), wl_fixed_to_double(sy)); diff --git a/src/client/qwaylandinputdevice_p.h b/src/client/qwaylandinputdevice_p.h index 6d458e35..f2bbd0dc 100644 --- a/src/client/qwaylandinputdevice_p.h +++ b/src/client/qwaylandinputdevice_p.h @@ -72,7 +72,9 @@ #include <QtCore/QDebug> +#if QT_CONFIG(cursor) struct wl_cursor_image; +#endif QT_BEGIN_NAMESPACE @@ -100,10 +102,12 @@ public: struct ::wl_seat *wl_seat() { return QtWayland::wl_seat::object(); } +#if QT_CONFIG(cursor) void setCursor(const QCursor &cursor, QWaylandScreen *screen); void setCursor(struct wl_buffer *buffer, struct ::wl_cursor_image *image); void setCursor(struct wl_buffer *buffer, const QPoint &hotSpot, const QSize &size); void setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot); +#endif void handleWindowDestroyed(QWaylandWindow *window); void handleEndDrag(); @@ -247,12 +251,16 @@ public: QWaylandInputDevice *mParent; QWaylandWindow *mFocus; uint32_t mEnterSerial; +#if QT_CONFIG(cursor) uint32_t mCursorSerial; +#endif QPointF mSurfacePos; QPointF mGlobalPos; Qt::MouseButtons mButtons; +#if QT_CONFIG(cursor) wl_buffer *mCursorBuffer; Qt::CursorShape mCursorShape; +#endif }; class Q_WAYLAND_CLIENT_EXPORT QWaylandInputDevice::Touch : public QtWayland::wl_touch diff --git a/src/client/qwaylandscreen.cpp b/src/client/qwaylandscreen.cpp index 5dbfe5e9..31d21a1c 100644 --- a/src/client/qwaylandscreen.cpp +++ b/src/client/qwaylandscreen.cpp @@ -64,18 +64,24 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin , mFormat(QImage::Format_ARGB32_Premultiplied) , mOutputName(QStringLiteral("Screen%1").arg(id)) , m_orientation(Qt::PrimaryOrientation) +#if QT_CONFIG(cursor) , mWaylandCursor(0) +#endif { } QWaylandScreen::~QWaylandScreen() { +#if QT_CONFIG(cursor) delete mWaylandCursor; +#endif } void QWaylandScreen::init() { +#if QT_CONFIG(cursor) mWaylandCursor = new QWaylandCursor(this); +#endif } QWaylandDisplay * QWaylandScreen::display() const @@ -156,10 +162,12 @@ qreal QWaylandScreen::refreshRate() const return mRefreshRate / 1000.f; } +#if QT_CONFIG(cursor) QPlatformCursor *QWaylandScreen::cursor() const { return mWaylandCursor; } +#endif QWaylandScreen * QWaylandScreen::waylandScreenFromWindow(QWindow *window) { diff --git a/src/client/qwaylandscreen_p.h b/src/client/qwaylandscreen_p.h index 9c1f4673..f9f0776f 100644 --- a/src/client/qwaylandscreen_p.h +++ b/src/client/qwaylandscreen_p.h @@ -90,8 +90,10 @@ public: QString name() const Q_DECL_OVERRIDE { return mOutputName; } +#if QT_CONFIG(cursor) QPlatformCursor *cursor() const Q_DECL_OVERRIDE; QWaylandCursor *waylandCursor() const { return mWaylandCursor; }; +#endif uint32_t outputId() const { return m_outputId; } ::wl_output *output() { return object(); } @@ -121,7 +123,9 @@ private: QString mOutputName; Qt::ScreenOrientation m_orientation; +#if QT_CONFIG(cursor) QWaylandCursor *mWaylandCursor; +#endif }; } diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index ca99f3de..8087921a 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -709,8 +709,10 @@ void QWaylandWindow::handleMouse(QWaylandInputDevice *inputDevice, const QWaylan } } +#if QT_CONFIG(cursor) if (e.type == QWaylandPointerEvent::Enter) restoreMouseCursor(inputDevice); +#endif } void QWaylandWindow::handleMouseLeave(QWaylandInputDevice *inputDevice) @@ -722,7 +724,9 @@ void QWaylandWindow::handleMouseLeave(QWaylandInputDevice *inputDevice) } else { QWindowSystemInterface::handleLeaveEvent(window()); } +#if QT_CONFIG(cursor) restoreMouseCursor(inputDevice); +#endif } bool QWaylandWindow::touchDragDecoration(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, Qt::TouchPointState state, Qt::KeyboardModifiers mods) @@ -754,7 +758,9 @@ void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDe globalTranslated.setX(globalTranslated.x() - marg.left()); globalTranslated.setY(globalTranslated.y() - marg.top()); if (!mMouseEventsInContentArea) { +#if QT_CONFIG(cursor) restoreMouseCursor(inputDevice); +#endif QWindowSystemInterface::handleEnterEvent(window()); } @@ -780,6 +786,7 @@ void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDe } } +#if QT_CONFIG(cursor) void QWaylandWindow::setMouseCursor(QWaylandInputDevice *device, const QCursor &cursor) { device->setCursor(cursor, mScreen); @@ -789,6 +796,7 @@ void QWaylandWindow::restoreMouseCursor(QWaylandInputDevice *device) { setMouseCursor(device, window()->cursor()); } +#endif void QWaylandWindow::requestActivateWindow() { diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h index ce295a0d..7b48e890 100644 --- a/src/client/qwaylandwindow_p.h +++ b/src/client/qwaylandwindow_p.h @@ -176,8 +176,10 @@ public: inline bool isMaximized() const { return mState == Qt::WindowMaximized; } inline bool isFullscreen() const { return mState == Qt::WindowFullScreen; } +#if QT_CONFIG(cursor) void setMouseCursor(QWaylandInputDevice *device, const QCursor &cursor); void restoreMouseCursor(QWaylandInputDevice *device); +#endif QWaylandWindow *transientParent() const; diff --git a/src/imports/compositor/qwaylandmousetracker.cpp b/src/imports/compositor/qwaylandmousetracker.cpp index 489dc7b5..4fcebe1d 100644 --- a/src/imports/compositor/qwaylandmousetracker.cpp +++ b/src/imports/compositor/qwaylandmousetracker.cpp @@ -88,7 +88,9 @@ QWaylandMouseTracker::QWaylandMouseTracker(QQuickItem *parent) setFiltersChildMouseEvents(true); setAcceptHoverEvents(true); setAcceptedMouseButtons(Qt::AllButtons); +#if QT_CONFIG(cursor) setCursor(QCursor(d->cursorPixmap)); +#endif } qreal QWaylandMouseTracker::mouseX() const @@ -102,6 +104,7 @@ qreal QWaylandMouseTracker::mouseY() const return d->mousePos.y(); } +#if QT_CONFIG(cursor) void QWaylandMouseTracker::setWindowSystemCursorEnabled(bool enable) { Q_D(QWaylandMouseTracker); @@ -121,6 +124,7 @@ bool QWaylandMouseTracker::windowSystemCursorEnabled() const Q_D(const QWaylandMouseTracker); return d->windowSystemCursorEnabled; } +#endif bool QWaylandMouseTracker::hovered() const { diff --git a/src/plugins/decorations/bradient/main.cpp b/src/plugins/decorations/bradient/main.cpp index f57b816e..3928a9f1 100644 --- a/src/plugins/decorations/bradient/main.cpp +++ b/src/plugins/decorations/bradient/main.cpp @@ -372,7 +372,9 @@ bool QWaylandBradientDecoration::handleMouse(QWaylandInputDevice *inputDevice, c } else if (local.x() > window()->width() + margins().left()) { processMouseRight(inputDevice,local,b,mods); } else { +#if QT_CONFIG(cursor) waylandWindow()->restoreMouseCursor(inputDevice); +#endif setMouseButtons(b); return false; } @@ -409,19 +411,27 @@ void QWaylandBradientDecoration::processMouseTop(QWaylandInputDevice *inputDevic if (local.y() <= margins().bottom()) { if (local.x() <= margins().left()) { //top left bit +#if QT_CONFIG(cursor) waylandWindow()->setMouseCursor(inputDevice, Qt::SizeFDiagCursor); +#endif startResize(inputDevice,WL_SHELL_SURFACE_RESIZE_TOP_LEFT,b); } else if (local.x() > window()->width() + margins().left()) { //top right bit +#if QT_CONFIG(cursor) waylandWindow()->setMouseCursor(inputDevice, Qt::SizeBDiagCursor); +#endif startResize(inputDevice,WL_SHELL_SURFACE_RESIZE_TOP_RIGHT,b); } else { //top reszie bit +#if QT_CONFIG(cursor) waylandWindow()->setMouseCursor(inputDevice, Qt::SplitVCursor); +#endif startResize(inputDevice,WL_SHELL_SURFACE_RESIZE_TOP,b); } } else { +#if QT_CONFIG(cursor) waylandWindow()->restoreMouseCursor(inputDevice); +#endif startMove(inputDevice,b); } @@ -432,15 +442,21 @@ void QWaylandBradientDecoration::processMouseBottom(QWaylandInputDevice *inputDe Q_UNUSED(mods); if (local.x() <= margins().left()) { //bottom left bit +#if QT_CONFIG(cursor) waylandWindow()->setMouseCursor(inputDevice, Qt::SizeBDiagCursor); +#endif startResize(inputDevice, WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT,b); } else if (local.x() > window()->width() + margins().left()) { //bottom right bit +#if QT_CONFIG(cursor) waylandWindow()->setMouseCursor(inputDevice, Qt::SizeFDiagCursor); +#endif startResize(inputDevice, WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT,b); } else { //bottom bit +#if QT_CONFIG(cursor) waylandWindow()->setMouseCursor(inputDevice, Qt::SplitVCursor); +#endif startResize(inputDevice,WL_SHELL_SURFACE_RESIZE_BOTTOM,b); } } @@ -449,7 +465,9 @@ void QWaylandBradientDecoration::processMouseLeft(QWaylandInputDevice *inputDevi { Q_UNUSED(local); Q_UNUSED(mods); +#if QT_CONFIG(cursor) waylandWindow()->setMouseCursor(inputDevice, Qt::SplitHCursor); +#endif startResize(inputDevice,WL_SHELL_SURFACE_RESIZE_LEFT,b); } @@ -457,7 +475,9 @@ void QWaylandBradientDecoration::processMouseRight(QWaylandInputDevice *inputDev { Q_UNUSED(local); Q_UNUSED(mods); +#if QT_CONFIG(cursor) waylandWindow()->setMouseCursor(inputDevice, Qt::SplitHCursor); +#endif startResize(inputDevice, WL_SHELL_SURFACE_RESIZE_RIGHT,b); } |