Fix build without feature.cursor

Change-Id: If244e7ac58133ae6fbefacfa243d47fa210140be
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Tasuku Suzuki 2017-01-13 20:19:17 +09:00
parent 12cc564878
commit cfcc462166
9 changed files with 73 additions and 3 deletions

View File

@ -18,7 +18,7 @@ CONFIG += link_pkgconfig wayland-scanner
qtConfig(xkbcommon-evdev): \ qtConfig(xkbcommon-evdev): \
QMAKE_USE_PRIVATE += xkbcommon_evdev QMAKE_USE_PRIVATE += xkbcommon_evdev
QMAKE_USE += wayland-client wayland-cursor QMAKE_USE += wayland-client
INCLUDEPATH += $$PWD/../shared INCLUDEPATH += $$PWD/../shared
@ -35,7 +35,6 @@ SOURCES += qwaylandintegration.cpp \
qwaylandnativeinterface.cpp \ qwaylandnativeinterface.cpp \
qwaylandshmbackingstore.cpp \ qwaylandshmbackingstore.cpp \
qwaylandinputdevice.cpp \ qwaylandinputdevice.cpp \
qwaylandcursor.cpp \
qwaylanddisplay.cpp \ qwaylanddisplay.cpp \
qwaylandwindow.cpp \ qwaylandwindow.cpp \
qwaylandscreen.cpp \ qwaylandscreen.cpp \
@ -69,7 +68,6 @@ SOURCES += qwaylandintegration.cpp \
HEADERS += qwaylandintegration_p.h \ HEADERS += qwaylandintegration_p.h \
qwaylandnativeinterface_p.h \ qwaylandnativeinterface_p.h \
qwaylandcursor_p.h \
qwaylanddisplay_p.h \ qwaylanddisplay_p.h \
qwaylandwindow_p.h \ qwaylandwindow_p.h \
qwaylandscreen_p.h \ qwaylandscreen_p.h \
@ -116,6 +114,15 @@ include(shellintegration/shellintegration.pri)
include(inputdeviceintegration/inputdeviceintegration.pri) include(inputdeviceintegration/inputdeviceintegration.pri)
include(global/global.pri) include(global/global.pri)
qtConfig(cursor) {
QMAKE_USE += wayland-cursor
HEADERS += \
qwaylandcursor_p.h
SOURCES += \
qwaylandcursor.cpp
}
CONFIG += generated_privates CONFIG += generated_privates
MODULE_PLUGIN_TYPES = \ MODULE_PLUGIN_TYPES = \
wayland-graphics-integration-client \ wayland-graphics-integration-client \

View File

@ -372,7 +372,9 @@ bool QWaylandBradientDecoration::handleMouse(QWaylandInputDevice *inputDevice, c
} else if (local.x() > window()->width() + margins().left()) { } else if (local.x() > window()->width() + margins().left()) {
processMouseRight(inputDevice,local,b,mods); processMouseRight(inputDevice,local,b,mods);
} else { } else {
#if QT_CONFIG(cursor)
waylandWindow()->restoreMouseCursor(inputDevice); waylandWindow()->restoreMouseCursor(inputDevice);
#endif
setMouseButtons(b); setMouseButtons(b);
return false; return false;
} }
@ -409,19 +411,27 @@ void QWaylandBradientDecoration::processMouseTop(QWaylandInputDevice *inputDevic
if (local.y() <= margins().bottom()) { if (local.y() <= margins().bottom()) {
if (local.x() <= margins().left()) { if (local.x() <= margins().left()) {
//top left bit //top left bit
#if QT_CONFIG(cursor)
waylandWindow()->setMouseCursor(inputDevice, Qt::SizeFDiagCursor); waylandWindow()->setMouseCursor(inputDevice, Qt::SizeFDiagCursor);
#endif
startResize(inputDevice,WL_SHELL_SURFACE_RESIZE_TOP_LEFT,b); startResize(inputDevice,WL_SHELL_SURFACE_RESIZE_TOP_LEFT,b);
} else if (local.x() > window()->width() + margins().left()) { } else if (local.x() > window()->width() + margins().left()) {
//top right bit //top right bit
#if QT_CONFIG(cursor)
waylandWindow()->setMouseCursor(inputDevice, Qt::SizeBDiagCursor); waylandWindow()->setMouseCursor(inputDevice, Qt::SizeBDiagCursor);
#endif
startResize(inputDevice,WL_SHELL_SURFACE_RESIZE_TOP_RIGHT,b); startResize(inputDevice,WL_SHELL_SURFACE_RESIZE_TOP_RIGHT,b);
} else { } else {
//top reszie bit //top reszie bit
#if QT_CONFIG(cursor)
waylandWindow()->setMouseCursor(inputDevice, Qt::SplitVCursor); waylandWindow()->setMouseCursor(inputDevice, Qt::SplitVCursor);
#endif
startResize(inputDevice,WL_SHELL_SURFACE_RESIZE_TOP,b); startResize(inputDevice,WL_SHELL_SURFACE_RESIZE_TOP,b);
} }
} else { } else {
#if QT_CONFIG(cursor)
waylandWindow()->restoreMouseCursor(inputDevice); waylandWindow()->restoreMouseCursor(inputDevice);
#endif
startMove(inputDevice,b); startMove(inputDevice,b);
} }
@ -432,15 +442,21 @@ void QWaylandBradientDecoration::processMouseBottom(QWaylandInputDevice *inputDe
Q_UNUSED(mods); Q_UNUSED(mods);
if (local.x() <= margins().left()) { if (local.x() <= margins().left()) {
//bottom left bit //bottom left bit
#if QT_CONFIG(cursor)
waylandWindow()->setMouseCursor(inputDevice, Qt::SizeBDiagCursor); waylandWindow()->setMouseCursor(inputDevice, Qt::SizeBDiagCursor);
#endif
startResize(inputDevice, WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT,b); startResize(inputDevice, WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT,b);
} else if (local.x() > window()->width() + margins().left()) { } else if (local.x() > window()->width() + margins().left()) {
//bottom right bit //bottom right bit
#if QT_CONFIG(cursor)
waylandWindow()->setMouseCursor(inputDevice, Qt::SizeFDiagCursor); waylandWindow()->setMouseCursor(inputDevice, Qt::SizeFDiagCursor);
#endif
startResize(inputDevice, WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT,b); startResize(inputDevice, WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT,b);
} else { } else {
//bottom bit //bottom bit
#if QT_CONFIG(cursor)
waylandWindow()->setMouseCursor(inputDevice, Qt::SplitVCursor); waylandWindow()->setMouseCursor(inputDevice, Qt::SplitVCursor);
#endif
startResize(inputDevice,WL_SHELL_SURFACE_RESIZE_BOTTOM,b); startResize(inputDevice,WL_SHELL_SURFACE_RESIZE_BOTTOM,b);
} }
} }
@ -449,7 +465,9 @@ void QWaylandBradientDecoration::processMouseLeft(QWaylandInputDevice *inputDevi
{ {
Q_UNUSED(local); Q_UNUSED(local);
Q_UNUSED(mods); Q_UNUSED(mods);
#if QT_CONFIG(cursor)
waylandWindow()->setMouseCursor(inputDevice, Qt::SplitHCursor); waylandWindow()->setMouseCursor(inputDevice, Qt::SplitHCursor);
#endif
startResize(inputDevice,WL_SHELL_SURFACE_RESIZE_LEFT,b); startResize(inputDevice,WL_SHELL_SURFACE_RESIZE_LEFT,b);
} }
@ -457,7 +475,9 @@ void QWaylandBradientDecoration::processMouseRight(QWaylandInputDevice *inputDev
{ {
Q_UNUSED(local); Q_UNUSED(local);
Q_UNUSED(mods); Q_UNUSED(mods);
#if QT_CONFIG(cursor)
waylandWindow()->setMouseCursor(inputDevice, Qt::SplitHCursor); waylandWindow()->setMouseCursor(inputDevice, Qt::SplitHCursor);
#endif
startResize(inputDevice, WL_SHELL_SURFACE_RESIZE_RIGHT,b); startResize(inputDevice, WL_SHELL_SURFACE_RESIZE_RIGHT,b);
} }

View File

@ -55,6 +55,8 @@
#include <QtCore/QMap> #include <QtCore/QMap>
#include <QtWaylandClient/qtwaylandclientglobal.h> #include <QtWaylandClient/qtwaylandclientglobal.h>
#if QT_CONFIG(cursor)
struct wl_cursor; struct wl_cursor;
struct wl_cursor_image; struct wl_cursor_image;
struct wl_cursor_theme; struct wl_cursor_theme;
@ -128,4 +130,5 @@ private:
QT_END_NAMESPACE QT_END_NAMESPACE
#endif // cursor
#endif // QWAYLANDCURSOR_H #endif // QWAYLANDCURSOR_H

View File

@ -62,7 +62,9 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/mman.h> #include <sys/mman.h>
#if QT_CONFIG(cursor)
#include <wayland-cursor.h> #include <wayland-cursor.h>
#endif
#include <QtGui/QGuiApplication> #include <QtGui/QGuiApplication>
@ -145,10 +147,14 @@ QWaylandInputDevice::Pointer::Pointer(QWaylandInputDevice *p)
: mParent(p) : mParent(p)
, mFocus(0) , mFocus(0)
, mEnterSerial(0) , mEnterSerial(0)
#if QT_CONFIG(cursor)
, mCursorSerial(0) , mCursorSerial(0)
#endif
, mButtons(0) , mButtons(0)
#if QT_CONFIG(cursor)
, mCursorBuffer(nullptr) , mCursorBuffer(nullptr)
, mCursorShape(Qt::BitmapCursor) , mCursorShape(Qt::BitmapCursor)
#endif
{ {
} }
@ -344,6 +350,7 @@ Qt::KeyboardModifiers QWaylandInputDevice::Keyboard::modifiers() const
return ret; return ret;
} }
#if QT_CONFIG(cursor)
uint32_t QWaylandInputDevice::cursorSerial() const uint32_t QWaylandInputDevice::cursorSerial() const
{ {
if (mPointer) if (mPointer)
@ -415,6 +422,7 @@ void QWaylandInputDevice::setCursor(const QSharedPointer<QWaylandBuffer> &buffer
setCursor(buffer->buffer(), hotSpot, buffer->size()); setCursor(buffer->buffer(), hotSpot, buffer->size());
mPixmapCursor = buffer; mPixmapCursor = buffer;
} }
#endif
class EnterEvent : public QWaylandPointerEvent class EnterEvent : public QWaylandPointerEvent
{ {
@ -431,7 +439,9 @@ void QWaylandInputDevice::Pointer::pointer_enter(uint32_t serial, struct wl_surf
return; return;
QWaylandWindow *window = QWaylandWindow::fromWlSurface(surface); QWaylandWindow *window = QWaylandWindow::fromWlSurface(surface);
#if QT_CONFIG(cursor)
window->window()->setCursor(window->window()->cursor()); window->window()->setCursor(window->window()->cursor());
#endif
mFocus = window; mFocus = window;
mSurfacePos = QPointF(wl_fixed_to_double(sx), wl_fixed_to_double(sy)); mSurfacePos = QPointF(wl_fixed_to_double(sx), wl_fixed_to_double(sy));

View File

@ -72,7 +72,9 @@
#include <QtCore/QDebug> #include <QtCore/QDebug>
#if QT_CONFIG(cursor)
struct wl_cursor_image; struct wl_cursor_image;
#endif
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -100,10 +102,12 @@ public:
struct ::wl_seat *wl_seat() { return QtWayland::wl_seat::object(); } struct ::wl_seat *wl_seat() { return QtWayland::wl_seat::object(); }
#if QT_CONFIG(cursor)
void setCursor(const QCursor &cursor, QWaylandScreen *screen); void setCursor(const QCursor &cursor, QWaylandScreen *screen);
void setCursor(struct wl_buffer *buffer, struct ::wl_cursor_image *image); 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(struct wl_buffer *buffer, const QPoint &hotSpot, const QSize &size);
void setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot); void setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot);
#endif
void handleWindowDestroyed(QWaylandWindow *window); void handleWindowDestroyed(QWaylandWindow *window);
void handleEndDrag(); void handleEndDrag();
@ -247,12 +251,16 @@ public:
QWaylandInputDevice *mParent; QWaylandInputDevice *mParent;
QWaylandWindow *mFocus; QWaylandWindow *mFocus;
uint32_t mEnterSerial; uint32_t mEnterSerial;
#if QT_CONFIG(cursor)
uint32_t mCursorSerial; uint32_t mCursorSerial;
#endif
QPointF mSurfacePos; QPointF mSurfacePos;
QPointF mGlobalPos; QPointF mGlobalPos;
Qt::MouseButtons mButtons; Qt::MouseButtons mButtons;
#if QT_CONFIG(cursor)
wl_buffer *mCursorBuffer; wl_buffer *mCursorBuffer;
Qt::CursorShape mCursorShape; Qt::CursorShape mCursorShape;
#endif
}; };
class Q_WAYLAND_CLIENT_EXPORT QWaylandInputDevice::Touch : public QtWayland::wl_touch class Q_WAYLAND_CLIENT_EXPORT QWaylandInputDevice::Touch : public QtWayland::wl_touch

View File

@ -64,18 +64,24 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
, mFormat(QImage::Format_ARGB32_Premultiplied) , mFormat(QImage::Format_ARGB32_Premultiplied)
, mOutputName(QStringLiteral("Screen%1").arg(id)) , mOutputName(QStringLiteral("Screen%1").arg(id))
, m_orientation(Qt::PrimaryOrientation) , m_orientation(Qt::PrimaryOrientation)
#if QT_CONFIG(cursor)
, mWaylandCursor(0) , mWaylandCursor(0)
#endif
{ {
} }
QWaylandScreen::~QWaylandScreen() QWaylandScreen::~QWaylandScreen()
{ {
#if QT_CONFIG(cursor)
delete mWaylandCursor; delete mWaylandCursor;
#endif
} }
void QWaylandScreen::init() void QWaylandScreen::init()
{ {
#if QT_CONFIG(cursor)
mWaylandCursor = new QWaylandCursor(this); mWaylandCursor = new QWaylandCursor(this);
#endif
} }
QWaylandDisplay * QWaylandScreen::display() const QWaylandDisplay * QWaylandScreen::display() const
@ -156,10 +162,12 @@ qreal QWaylandScreen::refreshRate() const
return mRefreshRate / 1000.f; return mRefreshRate / 1000.f;
} }
#if QT_CONFIG(cursor)
QPlatformCursor *QWaylandScreen::cursor() const QPlatformCursor *QWaylandScreen::cursor() const
{ {
return mWaylandCursor; return mWaylandCursor;
} }
#endif
QWaylandScreen * QWaylandScreen::waylandScreenFromWindow(QWindow *window) QWaylandScreen * QWaylandScreen::waylandScreenFromWindow(QWindow *window)
{ {

View File

@ -90,8 +90,10 @@ public:
QString name() const Q_DECL_OVERRIDE { return mOutputName; } QString name() const Q_DECL_OVERRIDE { return mOutputName; }
#if QT_CONFIG(cursor)
QPlatformCursor *cursor() const Q_DECL_OVERRIDE; QPlatformCursor *cursor() const Q_DECL_OVERRIDE;
QWaylandCursor *waylandCursor() const { return mWaylandCursor; }; QWaylandCursor *waylandCursor() const { return mWaylandCursor; };
#endif
uint32_t outputId() const { return m_outputId; } uint32_t outputId() const { return m_outputId; }
::wl_output *output() { return object(); } ::wl_output *output() { return object(); }
@ -121,7 +123,9 @@ private:
QString mOutputName; QString mOutputName;
Qt::ScreenOrientation m_orientation; Qt::ScreenOrientation m_orientation;
#if QT_CONFIG(cursor)
QWaylandCursor *mWaylandCursor; QWaylandCursor *mWaylandCursor;
#endif
}; };
} }

View File

@ -709,8 +709,10 @@ void QWaylandWindow::handleMouse(QWaylandInputDevice *inputDevice, const QWaylan
} }
} }
#if QT_CONFIG(cursor)
if (e.type == QWaylandPointerEvent::Enter) if (e.type == QWaylandPointerEvent::Enter)
restoreMouseCursor(inputDevice); restoreMouseCursor(inputDevice);
#endif
} }
void QWaylandWindow::handleMouseLeave(QWaylandInputDevice *inputDevice) void QWaylandWindow::handleMouseLeave(QWaylandInputDevice *inputDevice)
@ -722,7 +724,9 @@ void QWaylandWindow::handleMouseLeave(QWaylandInputDevice *inputDevice)
} else { } else {
QWindowSystemInterface::handleLeaveEvent(window()); QWindowSystemInterface::handleLeaveEvent(window());
} }
#if QT_CONFIG(cursor)
restoreMouseCursor(inputDevice); restoreMouseCursor(inputDevice);
#endif
} }
bool QWaylandWindow::touchDragDecoration(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, Qt::TouchPointState state, Qt::KeyboardModifiers mods) 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.setX(globalTranslated.x() - marg.left());
globalTranslated.setY(globalTranslated.y() - marg.top()); globalTranslated.setY(globalTranslated.y() - marg.top());
if (!mMouseEventsInContentArea) { if (!mMouseEventsInContentArea) {
#if QT_CONFIG(cursor)
restoreMouseCursor(inputDevice); restoreMouseCursor(inputDevice);
#endif
QWindowSystemInterface::handleEnterEvent(window()); QWindowSystemInterface::handleEnterEvent(window());
} }
@ -780,6 +786,7 @@ void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDe
} }
} }
#if QT_CONFIG(cursor)
void QWaylandWindow::setMouseCursor(QWaylandInputDevice *device, const QCursor &cursor) void QWaylandWindow::setMouseCursor(QWaylandInputDevice *device, const QCursor &cursor)
{ {
device->setCursor(cursor, mScreen); device->setCursor(cursor, mScreen);
@ -789,6 +796,7 @@ void QWaylandWindow::restoreMouseCursor(QWaylandInputDevice *device)
{ {
setMouseCursor(device, window()->cursor()); setMouseCursor(device, window()->cursor());
} }
#endif
void QWaylandWindow::requestActivateWindow() void QWaylandWindow::requestActivateWindow()
{ {

View File

@ -176,8 +176,10 @@ public:
inline bool isMaximized() const { return mState == Qt::WindowMaximized; } inline bool isMaximized() const { return mState == Qt::WindowMaximized; }
inline bool isFullscreen() const { return mState == Qt::WindowFullScreen; } inline bool isFullscreen() const { return mState == Qt::WindowFullScreen; }
#if QT_CONFIG(cursor)
void setMouseCursor(QWaylandInputDevice *device, const QCursor &cursor); void setMouseCursor(QWaylandInputDevice *device, const QCursor &cursor);
void restoreMouseCursor(QWaylandInputDevice *device); void restoreMouseCursor(QWaylandInputDevice *device);
#endif
QWaylandWindow *transientParent() const; QWaylandWindow *transientParent() const;