summaryrefslogtreecommitdiffstats
path: root/src/compositor/compositor_api
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@theqtcompany.com>2015-07-30 15:16:48 +0200
committerJørgen Lind <jorgen.lind@theqtcompany.com>2015-08-28 13:09:42 +0200
commit8ea41bfe32de3b4dd4c15ec91c8925b1c6508c53 (patch)
treed7e830542ac28e890278bdf1af76a0c37c4cc267 /src/compositor/compositor_api
parentce58545b220a49354533a27ef79cdbc8d50186cd (diff)
Public input apis
Diffstat (limited to 'src/compositor/compositor_api')
-rw-r--r--src/compositor/compositor_api/compositor_api.pri14
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor.cpp45
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor.h12
-rw-r--r--src/compositor/compositor_api/qwaylanddestroylistener.cpp72
-rw-r--r--src/compositor/compositor_api/qwaylanddestroylistener.h64
-rw-r--r--src/compositor/compositor_api/qwaylanddestroylistener_p.h66
-rw-r--r--src/compositor/compositor_api/qwaylanddrag.cpp10
-rw-r--r--src/compositor/compositor_api/qwaylanddrag.h6
-rw-r--r--src/compositor/compositor_api/qwaylandinput.cpp88
-rw-r--r--src/compositor/compositor_api/qwaylandinput.h42
-rw-r--r--src/compositor/compositor_api/qwaylandkeyboard.cpp111
-rw-r--r--src/compositor/compositor_api/qwaylandkeyboard.h113
-rw-r--r--src/compositor/compositor_api/qwaylandoutput.cpp5
-rw-r--r--src/compositor/compositor_api/qwaylandoutput.h2
-rw-r--r--src/compositor/compositor_api/qwaylandoutputspace.cpp5
-rw-r--r--src/compositor/compositor_api/qwaylandoutputspace.h3
-rw-r--r--src/compositor/compositor_api/qwaylandpointer.cpp257
-rw-r--r--src/compositor/compositor_api/qwaylandpointer.h131
-rw-r--r--src/compositor/compositor_api/qwaylandsurface.cpp22
-rw-r--r--src/compositor/compositor_api/qwaylandsurface.h4
-rw-r--r--src/compositor/compositor_api/qwaylandsurfaceitem.cpp12
-rw-r--r--src/compositor/compositor_api/qwaylandsurfaceview.cpp7
-rw-r--r--src/compositor/compositor_api/qwaylandsurfaceview.h2
23 files changed, 999 insertions, 94 deletions
diff --git a/src/compositor/compositor_api/compositor_api.pri b/src/compositor/compositor_api/compositor_api.pri
index 0cb5392dc..2da46ae76 100644
--- a/src/compositor/compositor_api/compositor_api.pri
+++ b/src/compositor/compositor_api/compositor_api.pri
@@ -6,6 +6,9 @@ HEADERS += \
compositor_api/qwaylandsurface.h \
compositor_api/qwaylandsurface_p.h \
compositor_api/qwaylandinput.h \
+ compositor_api/qwaylandkeyboard.h \
+ compositor_api/qwaylandpointer.h \
+ compositor_api/qwaylandtouch.h \
compositor_api/qwaylandinputpanel.h \
compositor_api/qwaylandoutput.h \
compositor_api/qwaylanddrag.h \
@@ -13,19 +16,26 @@ HEADERS += \
compositor_api/qwaylandsurfaceview.h \
compositor_api/qwaylandsurfaceview_p.h \
compositor_api/qwaylandoutputspace.h \
- compositor_api/qwaylandoutputspace_p.h
+ compositor_api/qwaylandoutputspace_p.h \
+ compositor_api/qwaylanddestroylistener.h \
+ compositor_api/qwaylanddestroylistener_p.h \
+
SOURCES += \
compositor_api/qwaylandcompositor.cpp \
compositor_api/qwaylandclient.cpp \
compositor_api/qwaylandsurface.cpp \
compositor_api/qwaylandinput.cpp \
+ compositor_api/qwaylandkeyboard.cpp \
+ compositor_api/qwaylandpointer.cpp \
+ compositor_api/qwaylandtouch.cpp \
compositor_api/qwaylandinputpanel.cpp \
compositor_api/qwaylandoutput.cpp \
compositor_api/qwaylanddrag.cpp \
compositor_api/qwaylandbufferref.cpp \
compositor_api/qwaylandsurfaceview.cpp \
- compositor_api/qwaylandoutputspace.cpp
+ compositor_api/qwaylandoutputspace.cpp \
+ compositor_api/qwaylanddestroylistener.cpp \
QT += core-private
diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp
index cc1826fc7..ff4a12ab4 100644
--- a/src/compositor/compositor_api/qwaylandcompositor.cpp
+++ b/src/compositor/compositor_api/qwaylandcompositor.cpp
@@ -42,6 +42,9 @@
#include "qwaylandoutput.h"
#include "qwaylandsurfaceview.h"
#include "qwaylandclient.h"
+#include "qwaylandkeyboard.h"
+#include "qwaylandpointer.h"
+#include "qwaylandtouch.h"
#include "wayland_wrapper/qwlcompositor_p.h"
#include "wayland_wrapper/qwldatadevice_p.h"
@@ -115,6 +118,11 @@ struct wl_display *QWaylandCompositor::waylandDisplay() const
return m_compositor->wl_display();
}
+uint32_t QWaylandCompositor::nextSerial()
+{
+ return wl_display_next_serial(waylandDisplay());
+}
+
void QWaylandCompositor::destroyClientForSurface(QWaylandSurface *surface)
{
destroyClient(surface->client());
@@ -170,6 +178,11 @@ void QWaylandCompositor::removeOutputSpace(QWaylandOutputSpace *outputSpace)
m_compositor->removeOutputSpace(outputSpace);
}
+uint QWaylandCompositor::currentTimeMsecs() const
+{
+ return m_compositor->currentTimeMsecs();
+}
+
QWaylandOutput *QWaylandCompositor::createOutput(QWaylandOutputSpace *outputSpace,
QWindow *window,
const QString &manufacturer,
@@ -193,15 +206,24 @@ QWaylandSurfaceView *QWaylandCompositor::createView()
return new QWaylandSurfaceView();
}
-/*!
- Override this to handle QDesktopServices::openUrl() requests from the clients.
+QWaylandInputDevice *QWaylandCompositor::createInputDevice()
+{
+ return new QWaylandInputDevice(this);
+}
- The default implementation simply forwards the request to QDesktopServices::openUrl().
-*/
-bool QWaylandCompositor::openUrl(QWaylandClient *client, const QUrl &url)
+QWaylandPointer *QWaylandCompositor::createPointerDevice(QWaylandInputDevice *inputDevice)
{
- Q_UNUSED(client);
- return QDesktopServices::openUrl(url);
+ return new QWaylandPointer(inputDevice);
+}
+
+QWaylandKeyboard *QWaylandCompositor::createKeyboardDevice(QWaylandInputDevice *inputDevice)
+{
+ return new QWaylandKeyboard(inputDevice);
+}
+
+QWaylandTouch *QWaylandCompositor::createTouchDevice(QWaylandInputDevice *inputDevice)
+{
+ return new QWaylandTouch(inputDevice);
}
QtWayland::Compositor * QWaylandCompositor::handle() const
@@ -228,11 +250,6 @@ void QWaylandCompositor::overrideSelection(const QMimeData *data)
m_compositor->overrideSelection(data);
}
-void QWaylandCompositor::setClientFullScreenHint(bool value)
-{
- m_compositor->setClientFullScreenHint(value);
-}
-
#if QT_DEPRECATED_SINCE(5, 5)
/*!
Set the screen orientation based on accelerometer data or similar.
@@ -296,12 +313,12 @@ int QWaylandCompositor::outputRefreshRate() const
QWaylandInputDevice *QWaylandCompositor::defaultInputDevice() const
{
- return m_compositor->defaultInputDevice()->handle();
+ return m_compositor->defaultInputDevice();
}
QWaylandDrag *QWaylandCompositor::drag() const
{
- return m_compositor->defaultInputDevice()->dragHandle();
+ return m_compositor->defaultInputDevice()->drag();
}
bool QWaylandCompositor::isDragging() const
diff --git a/src/compositor/compositor_api/qwaylandcompositor.h b/src/compositor/compositor_api/qwaylandcompositor.h
index 984624383..f22468239 100644
--- a/src/compositor/compositor_api/qwaylandcompositor.h
+++ b/src/compositor/compositor_api/qwaylandcompositor.h
@@ -61,6 +61,9 @@ class QWaylandGlobalInterface;
class QWaylandSurfaceView;
class QWaylandOutput;
class QWaylandOutputSpace;
+class QWaylandPointer;
+class QWaylandKeyboard;
+class QWaylandTouch;
namespace QtWayland
{
@@ -104,6 +107,7 @@ public:
ExtensionFlags extensionFlags() const;
::wl_display *waylandDisplay() const;
+ uint32_t nextSerial();
Q_INVOKABLE void destroyClientForSurface(QWaylandSurface *surface);
Q_INVOKABLE void destroyClient(QWaylandClient *client);
@@ -119,7 +123,7 @@ public:
void addOutputSpace(QWaylandOutputSpace *outputSpace);
void removeOutputSpace(QWaylandOutputSpace *outputSpace);
- virtual bool openUrl(QWaylandClient *client, const QUrl &url);
+ uint currentTimeMsecs() const;
QtWayland::Compositor *handle() const;
@@ -127,8 +131,6 @@ public:
bool retainedSelectionEnabled() const;
void overrideSelection(const QMimeData *data);
- void setClientFullScreenHint(bool value);
-
#if QT_DEPRECATED_SINCE(5, 5)
void setScreenOrientation(Qt::ScreenOrientation orientation);
@@ -176,6 +178,10 @@ protected:
const QString &model);
virtual QWaylandSurface *createSurface(QWaylandClient *client, quint32 id, int version);
virtual QWaylandSurfaceView *createView();
+ virtual QWaylandInputDevice *createInputDevice();
+ virtual QWaylandPointer *createPointerDevice(QWaylandInputDevice *inputDevice);
+ virtual QWaylandKeyboard *createKeyboardDevice(QWaylandInputDevice *inputDevice);
+ virtual QWaylandTouch *createTouchDevice(QWaylandInputDevice *inputDevice);
friend class QtWayland::Compositor;
friend class QWaylandOutputSpacePrivate;
diff --git a/src/compositor/compositor_api/qwaylanddestroylistener.cpp b/src/compositor/compositor_api/qwaylanddestroylistener.cpp
new file mode 100644
index 000000000..13ec63849
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylanddestroylistener.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylanddestroylistener.h"
+#include "qwaylanddestroylistener_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QWaylandDestroyListenerPrivate::QWaylandDestroyListenerPrivate()
+{
+ listener.parent = this;
+ listener.listener.notify = handler;
+ wl_list_init(&listener.listener.link);
+}
+
+QWaylandDestroyListener::QWaylandDestroyListener(QObject *parent)
+ : QObject(* new QWaylandDestroyListenerPrivate(), parent)
+{
+}
+void QWaylandDestroyListener::listenForDestruction(::wl_resource *resource)
+{
+ Q_D(QWaylandDestroyListener);
+ wl_resource_add_destroy_listener(resource, &d->listener.listener);
+}
+
+void QWaylandDestroyListener::reset()
+{
+ Q_D(QWaylandDestroyListener);
+ wl_list_remove(&d->listener.listener.link);
+ wl_list_init(&d->listener.listener.link);
+}
+
+void QWaylandDestroyListenerPrivate::handler(wl_listener *listener, void *data)
+{
+ QWaylandDestroyListenerPrivate *that = reinterpret_cast<Listener *>(listener)->parent;
+ emit that->q_func()->fired(data);
+}
+
+QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylanddestroylistener.h b/src/compositor/compositor_api/qwaylanddestroylistener.h
new file mode 100644
index 000000000..6e141b828
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylanddestroylistener.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
+** Copyright (C) 2015 Digia Plc and/or its subsidi ary(-ies).
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDDESTROYLISTENER_H
+#define QWAYLANDDESTROYLISTENER_H
+
+#include <QtCore/QObject>
+#include <QtCompositor/qwaylandexport.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandDestroyListenerPrivate;
+
+class Q_COMPOSITOR_EXPORT QWaylandDestroyListener : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandDestroyListener)
+public:
+ QWaylandDestroyListener(QObject *parent = 0);
+ void listenForDestruction(struct wl_resource *resource);
+ void reset();
+
+Q_SIGNALS:
+ void fired(void *data);
+
+};
+
+QT_END_NAMESPACE
+
+#endif /*QWAYLANDDESTROYLISTENER_H*/
diff --git a/src/compositor/compositor_api/qwaylanddestroylistener_p.h b/src/compositor/compositor_api/qwaylanddestroylistener_p.h
new file mode 100644
index 000000000..7e9c43778
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylanddestroylistener_p.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTWAYLAND_QWLLISTENER_H
+#define QTWAYLAND_QWLLISTENER_H
+
+#include "qwaylanddestroylistener.h"
+
+#include <QtCore/private/qobject_p.h>
+
+#include <wayland-server.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandDestroyListenerPrivate : public QObjectPrivate
+{
+public:
+ Q_DECLARE_PUBLIC(QWaylandDestroyListener)
+
+ QWaylandDestroyListenerPrivate();
+
+ static void handler(wl_listener *listener, void *data);
+
+ struct Listener {
+ wl_listener listener;
+ QWaylandDestroyListenerPrivate *parent;
+ };
+ Listener listener;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/compositor/compositor_api/qwaylanddrag.cpp b/src/compositor/compositor_api/qwaylanddrag.cpp
index 281e64c2e..d3bae5a72 100644
--- a/src/compositor/compositor_api/qwaylanddrag.cpp
+++ b/src/compositor/compositor_api/qwaylanddrag.cpp
@@ -49,16 +49,16 @@ QT_BEGIN_NAMESPACE
class QWaylandDragPrivate : public QObjectPrivate
{
public:
- QWaylandDragPrivate(QtWayland::InputDevice *id)
+ QWaylandDragPrivate(QWaylandInputDevice *id)
: inputDevice(id)
{
}
- QtWayland::InputDevice *inputDevice;
+ QWaylandInputDevice *inputDevice;
};
-QWaylandDrag::QWaylandDrag(QtWayland::InputDevice *inputDevice)
+QWaylandDrag::QWaylandDrag(QWaylandInputDevice *inputDevice)
: QObject(* new QWaylandDragPrivate(inputDevice))
{
}
@@ -67,7 +67,7 @@ QWaylandSurfaceView *QWaylandDrag::icon() const
{
Q_D(const QWaylandDrag);
- const QtWayland::DataDevice *dataDevice = d->inputDevice->dataDevice();
+ const QtWayland::DataDevice *dataDevice = QWaylandInputDevicePrivate::get(d->inputDevice)->dataDevice();
if (!dataDevice)
return 0;
@@ -78,7 +78,7 @@ bool QWaylandDrag::visible() const
{
Q_D(const QWaylandDrag);
- const QtWayland::DataDevice *dataDevice = d->inputDevice->dataDevice();
+ const QtWayland::DataDevice *dataDevice = QWaylandInputDevicePrivate::get(d->inputDevice)->dataDevice();
if (!dataDevice)
return false;
diff --git a/src/compositor/compositor_api/qwaylanddrag.h b/src/compositor/compositor_api/qwaylanddrag.h
index 3fe34f48d..e4b7e8bfe 100644
--- a/src/compositor/compositor_api/qwaylanddrag.h
+++ b/src/compositor/compositor_api/qwaylanddrag.h
@@ -46,10 +46,8 @@ QT_BEGIN_NAMESPACE
class QWaylandDragPrivate;
class QWaylandSurface;
class QWaylandSurfaceView;
+class QWaylandInputDevice;
-namespace QtWayland {
-class InputDevice;
-}
class Q_COMPOSITOR_EXPORT QWaylandDrag : public QObject
{
Q_OBJECT
@@ -59,7 +57,7 @@ class Q_COMPOSITOR_EXPORT QWaylandDrag : public QObject
Q_PROPERTY(bool visible READ visible NOTIFY iconChanged)
public:
- explicit QWaylandDrag(QtWayland::InputDevice *inputDevice);
+ explicit QWaylandDrag(QWaylandInputDevice *inputDevice);
QWaylandSurfaceView *icon() const;
bool visible() const;
diff --git a/src/compositor/compositor_api/qwaylandinput.cpp b/src/compositor/compositor_api/qwaylandinput.cpp
index 34d4ac8ba..b2176c7f9 100644
--- a/src/compositor/compositor_api/qwaylandinput.cpp
+++ b/src/compositor/compositor_api/qwaylandinput.cpp
@@ -57,28 +57,24 @@ QWaylandKeymap::QWaylandKeymap(const QString &layout, const QString &variant, co
QWaylandInputDevice::QWaylandInputDevice(QWaylandCompositor *compositor, CapabilityFlags caps)
- : d(new QtWayland::InputDevice(this,compositor->handle(), caps))
+ : QObject(*new QWaylandInputDevicePrivate(this,compositor, caps))
{
}
QWaylandInputDevice::~QWaylandInputDevice()
{
- delete d;
}
-void QWaylandInputDevice::sendMousePressEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos)
+void QWaylandInputDevice::sendMousePressEvent(Qt::MouseButton button)
{
- d->sendMousePressEvent(button,localPos,globalPos);
+ Q_D(QWaylandInputDevice);
+ d->sendMousePressEvent(button);
}
-void QWaylandInputDevice::sendMouseReleaseEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos)
+void QWaylandInputDevice::sendMouseReleaseEvent(Qt::MouseButton button)
{
- d->sendMouseReleaseEvent(button,localPos,globalPos);
-}
-
-void QWaylandInputDevice::sendMouseMoveEvent(const QPointF &localPos, const QPointF &globalPos)
-{
- d->sendMouseMoveEvent(localPos,globalPos);
+ Q_D(QWaylandInputDevice);
+ d->sendMouseReleaseEvent(button);
}
/** Convenience function that will set the mouse focus to the surface, then send the mouse move event.
@@ -86,120 +82,130 @@ void QWaylandInputDevice::sendMouseMoveEvent(const QPointF &localPos, const QPoi
**/
void QWaylandInputDevice::sendMouseMoveEvent(QWaylandSurfaceView *surface, const QPointF &localPos, const QPointF &globalPos)
{
+ Q_D(QWaylandInputDevice);
d->sendMouseMoveEvent(surface,localPos,globalPos);
}
void QWaylandInputDevice::sendMouseWheelEvent(Qt::Orientation orientation, int delta)
{
+ Q_D(QWaylandInputDevice);
d->sendMouseWheelEvent(orientation, delta);
}
-void QWaylandInputDevice::sendMouseEnterEvent(QWaylandSurfaceView *view, const QPointF &localPos)
-{
- d->sendMouseEnterEvent(view,localPos);
-}
-
-void QWaylandInputDevice::sendMouseLeaveEvent(QWaylandSurfaceView *view)
+void QWaylandInputDevice::sendResetCurrentMouseView()
{
- d->sendMouseLeaveEvent(view);
+ Q_D(QWaylandInputDevice);
+ d->sendResetCurrentMouseView();
}
void QWaylandInputDevice::sendKeyPressEvent(uint code)
{
- d->keyboardDevice()->sendKeyPressEvent(code);
+ keyboard()->sendKeyPressEvent(code);
}
void QWaylandInputDevice::sendKeyReleaseEvent(uint code)
{
- d->keyboardDevice()->sendKeyReleaseEvent(code);
+ keyboard()->sendKeyReleaseEvent(code);
}
-void QWaylandInputDevice::sendTouchPointEvent(int id, double x, double y, Qt::TouchPointState state)
+void QWaylandInputDevice::sendTouchPointEvent(int id, const QPointF &point, Qt::TouchPointState state)
{
- d->sendTouchPointEvent(id,x,y,state);
+ Q_D(QWaylandInputDevice);
+ d->sendTouchPointEvent(id, point, state);
}
void QWaylandInputDevice::sendTouchFrameEvent()
{
+ Q_D(QWaylandInputDevice);
d->sendTouchFrameEvent();
}
void QWaylandInputDevice::sendTouchCancelEvent()
{
+ Q_D(QWaylandInputDevice);
d->sendTouchCancelEvent();
}
void QWaylandInputDevice::sendFullTouchEvent(QTouchEvent *event)
{
+ Q_D(QWaylandInputDevice);
d->sendFullTouchEvent(event);
}
void QWaylandInputDevice::sendFullKeyEvent(QKeyEvent *event)
{
+ Q_D(QWaylandInputDevice);
d->sendFullKeyEvent(event);
}
void QWaylandInputDevice::sendFullKeyEvent(QWaylandSurface *surface, QKeyEvent *event)
{
- d->sendFullKeyEvent(surface->handle(), event);
+ Q_D(QWaylandInputDevice);
+ d->sendFullKeyEvent(surface, event);
+}
+
+QWaylandKeyboard *QWaylandInputDevice::keyboard() const
+{
+ Q_D(const QWaylandInputDevice);
+ return d->keyboardDevice();
}
QWaylandSurface *QWaylandInputDevice::keyboardFocus() const
{
- QtWayland::Surface *wlsurface = d->keyboardFocus();
- if (wlsurface)
- return wlsurface->waylandSurface();
- return 0;
+ Q_D(const QWaylandInputDevice);
+ QWaylandSurface *surface = d->keyboardFocus();
+ return surface;
}
bool QWaylandInputDevice::setKeyboardFocus(QWaylandSurface *surface)
{
- QtWayland::Surface *wlsurface = surface?surface->handle():0;
- return d->setKeyboardFocus(wlsurface);
+ Q_D(QWaylandInputDevice);
+ return d->setKeyboardFocus(surface);
}
void QWaylandInputDevice::setKeymap(const QWaylandKeymap &keymap)
{
- if (handle()->keyboardDevice())
- handle()->keyboardDevice()->setKeymap(keymap);
+ if (keyboard())
+ keyboard()->setKeymap(keymap);
}
QWaylandSurfaceView *QWaylandInputDevice::mouseFocus() const
{
+ Q_D(const QWaylandInputDevice);
return d->mouseFocus();
}
-void QWaylandInputDevice::setMouseFocus(QWaylandSurfaceView *surface, const QPointF &localPos, const QPointF &globalPos)
-{
- d->setMouseFocus(surface,localPos,globalPos);
-}
-
QWaylandOutputSpace *QWaylandInputDevice::outputSpace() const
{
+ Q_D(const QWaylandInputDevice);
return d->outputSpace();
}
void QWaylandInputDevice::setOutputSpace(QWaylandOutputSpace *outputSpace)
{
+ Q_D(QWaylandInputDevice);
d->setOutputSpace(outputSpace);
}
QWaylandCompositor *QWaylandInputDevice::compositor() const
{
- return d->compositor()->waylandCompositor();
+ Q_D(const QWaylandInputDevice);
+ return d->compositor();
}
-QtWayland::InputDevice *QWaylandInputDevice::handle() const
+QWaylandDrag *QWaylandInputDevice::drag() const
{
- return d;
+ Q_D(const QWaylandInputDevice);
+ return d->dragHandle();
}
-QWaylandInputDevice::CapabilityFlags QWaylandInputDevice::capabilities()
+QWaylandInputDevice::CapabilityFlags QWaylandInputDevice::capabilities() const
{
+ Q_D(const QWaylandInputDevice);
return d->capabilities();
}
-bool QWaylandInputDevice::isOwner(QInputEvent *inputEvent)
+bool QWaylandInputDevice::isOwner(QInputEvent *inputEvent) const
{
Q_UNUSED(inputEvent);
return true;
diff --git a/src/compositor/compositor_api/qwaylandinput.h b/src/compositor/compositor_api/qwaylandinput.h
index 013f6d789..84a630f4a 100644
--- a/src/compositor/compositor_api/qwaylandinput.h
+++ b/src/compositor/compositor_api/qwaylandinput.h
@@ -42,6 +42,8 @@
#include <QtCore/QString>
#include <QtCompositor/qwaylandexport.h>
+#include <QtCompositor/qwaylandextension.h>
+#include <QtCompositor/qwaylandkeyboard.h>
QT_BEGIN_NAMESPACE
@@ -52,6 +54,11 @@ class QTouchEvent;
class QWaylandSurfaceView;
class QInputEvent;
class QWaylandOutputSpace;
+class QWaylandInputDevicePrivate;
+class QWaylandDrag;
+class QWaylandKeyboard;
+class QWaylandPointer;
+class QWaylandTouch;
namespace QtWayland {
class InputDevice;
@@ -77,8 +84,10 @@ private:
QString m_model;
};
-class Q_COMPOSITOR_EXPORT QWaylandInputDevice
+class Q_COMPOSITOR_EXPORT QWaylandInputDevice : public QObject, public QWaylandExtensionContainer
{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandInputDevice)
public:
enum CapabilityFlag {
// The order should match the enum WL_SEAT_CAPABILITY_*
@@ -93,13 +102,11 @@ public:
QWaylandInputDevice(QWaylandCompositor *compositor, CapabilityFlags caps = DefaultCapabilities);
virtual ~QWaylandInputDevice();
- void sendMousePressEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos = QPointF());
- void sendMouseReleaseEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos = QPointF());
- void sendMouseMoveEvent(const QPointF &localPos, const QPointF &globalPos = QPointF());
+ void sendMousePressEvent(Qt::MouseButton button);
+ void sendMouseReleaseEvent(Qt::MouseButton button);
void sendMouseMoveEvent(QWaylandSurfaceView *surface , const QPointF &localPos, const QPointF &globalPos = QPointF());
void sendMouseWheelEvent(Qt::Orientation orientation, int delta);
- void sendMouseEnterEvent(QWaylandSurfaceView *view, const QPointF &localPos);
- void sendMouseLeaveEvent(QWaylandSurfaceView *view);
+ void sendResetCurrentMouseView();
void sendKeyPressEvent(uint code);
void sendKeyReleaseEvent(uint code);
@@ -107,32 +114,37 @@ public:
void sendFullKeyEvent(QKeyEvent *event);
void sendFullKeyEvent(QWaylandSurface *surface, QKeyEvent *event);
- void sendTouchPointEvent(int id, double x, double y, Qt::TouchPointState state);
+ void sendTouchPointEvent(int id, const QPointF &point, Qt::TouchPointState state);
void sendTouchFrameEvent();
void sendTouchCancelEvent();
void sendFullTouchEvent(QTouchEvent *event);
+ QWaylandPointer *pointer() const;
+
+ QWaylandSurfaceView *mouseFocus() const;
+ void setMouseFocus(QWaylandSurfaceView *view);
+
+ QWaylandKeyboard *keyboard() const;
QWaylandSurface *keyboardFocus() const;
bool setKeyboardFocus(QWaylandSurface *surface);
void setKeymap(const QWaylandKeymap &keymap);
- QWaylandSurfaceView *mouseFocus() const;
- void setMouseFocus(QWaylandSurfaceView *surface, const QPointF &local_pos, const QPointF &global_pos = QPointF());
+ QWaylandTouch *touch() const;
QWaylandOutputSpace *outputSpace() const;
void setOutputSpace(QWaylandOutputSpace *outputSpace);
QWaylandCompositor *compositor() const;
- QtWayland::InputDevice *handle() const;
- QWaylandInputDevice::CapabilityFlags capabilities();
+ QWaylandDrag *drag() const;
- virtual bool isOwner(QInputEvent *inputEvent);
+ QWaylandInputDevice::CapabilityFlags capabilities() const;
-private:
- QtWayland::InputDevice *d;
- Q_DISABLE_COPY(QWaylandInputDevice)
+ virtual bool isOwner(QInputEvent *inputEvent) const;
+
+Q_SIGNALS:
+ void mouseFocusChanged();
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QWaylandInputDevice::CapabilityFlags)
diff --git a/src/compositor/compositor_api/qwaylandkeyboard.cpp b/src/compositor/compositor_api/qwaylandkeyboard.cpp
new file mode 100644
index 000000000..be828cd63
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandkeyboard.cpp
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Digia Plc and/or its subsidi ary(-ies).
+** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandkeyboard.h"
+#include "qwlkeyboard_p.h"
+#include <QtCompositor/QWaylandInputDevice>
+#include <QtCompositor/QWaylandClient>
+
+QT_BEGIN_NAMESPACE
+
+QWaylandKeyboardGrabber::~QWaylandKeyboardGrabber()
+{
+}
+
+QWaylandKeyboard::QWaylandKeyboard(QWaylandInputDevice *seat, QObject *parent)
+ : QObject(* new QWaylandKeyboardPrivate(seat), parent)
+{
+ Q_D(QWaylandKeyboard);
+ connect(&d->m_focusDestroyListener, &QWaylandDestroyListener::fired, this, &QWaylandKeyboard::focusDestroyed);
+}
+
+void QWaylandKeyboard::focusDestroyed(void *data)
+{
+ Q_UNUSED(data);
+ Q_D(QWaylandKeyboard);
+ d->m_focusDestroyListener.reset();
+
+ d->m_focus = 0;
+ d->m_focusResource = 0;
+}
+
+QWaylandClient *QWaylandKeyboard::focusClient() const
+{
+ Q_D(const QWaylandKeyboard);
+ if (!d->focusResource())
+ return Q_NULLPTR;
+ return QWaylandClient::fromWlClient(d->focusResource()->client());
+}
+
+void QWaylandKeyboard::sendKeyModifiers(QWaylandClient *client, uint serial)
+{
+ Q_D(QWaylandKeyboard);
+ QtWaylandServer::wl_keyboard::Resource *resource = d->resourceMap().value(client->client());
+ if (resource)
+ d->sendKeyModifiers(resource, serial);
+}
+void QWaylandKeyboard::sendKeyPressEvent(uint code)
+{
+ Q_D(QWaylandKeyboard);
+ d->sendKeyPressEvent(code);
+}
+
+void QWaylandKeyboard::sendKeyReleaseEvent(uint code)
+{
+ Q_D(QWaylandKeyboard);
+ d->sendKeyReleaseEvent(code);
+}
+
+QWaylandSurface *QWaylandKeyboard::focus() const
+{
+ Q_D(const QWaylandKeyboard);
+ return d->focus();
+}
+
+void QWaylandKeyboard::setFocus(QWaylandSurface *surface)
+{
+ Q_D(QWaylandKeyboard);
+ d->setFocus(surface);
+}
+
+void QWaylandKeyboard::setKeymap(const QWaylandKeymap &keymap)
+{
+ Q_D(QWaylandKeyboard);
+ d->setKeymap(keymap);
+}
+
+QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandkeyboard.h b/src/compositor/compositor_api/qwaylandkeyboard.h
new file mode 100644
index 000000000..53e207379
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandkeyboard.h
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Digia Plc and/or its subsidi ary(-ies).
+** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDKEYBOARD_H
+#define QWAYLANDKEYBOARD_H
+
+#include <QtCore/QObject>
+
+#include <QtCompositor/QWaylandExtensionContainer>
+#include <QtCompositor/QWaylandSurface>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandKeyboard;
+class QWaylandKeyboardPrivate;
+class QWaylandInputDevice;
+
+class Q_COMPOSITOR_EXPORT QWaylandKeyboardGrabber {
+public:
+ virtual ~QWaylandKeyboardGrabber();
+ virtual void focused(QWaylandSurface *surface) = 0;
+ virtual void key(uint32_t serial, uint32_t time, uint32_t key, uint32_t state) = 0;
+ virtual void modifiers(uint32_t serial, uint32_t mods_depressed,
+ uint32_t mods_latched, uint32_t mods_locked, uint32_t group) = 0;
+
+ QWaylandKeyboard *m_keyboard;
+};
+
+class Q_COMPOSITOR_EXPORT QWaylandKeymap
+{
+public:
+ QWaylandKeymap(const QString &layout = QLatin1String("us"), const QString &variant = QString(), const QString &options = QString(),
+ const QString &model = QLatin1String("pc105"), const QString &rules = QLatin1String("evdev"));
+
+ inline QString layout() const { return m_layout; }
+ inline QString variant() const { return m_variant; }
+ inline QString options() const { return m_options; }
+ inline QString rules() const { return m_rules; }
+ inline QString model() const { return m_model; }
+
+private:
+ QString m_layout;
+ QString m_variant;
+ QString m_options;
+ QString m_rules;
+ QString m_model;
+};
+
+class Q_COMPOSITOR_EXPORT QWaylandKeyboard : public QObject, public QWaylandExtensionContainer
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandKeyboard)
+
+public:
+ QWaylandKeyboard(QWaylandInputDevice *seat, QObject *parent = 0);
+
+ void setFocus(QWaylandSurface *surface);
+ virtual void setKeymap(const QWaylandKeymap &keymap);
+
+ virtual void sendKeyModifiers(QWaylandClient *client, uint32_t serial);
+ virtual void sendKeyPressEvent(uint code);
+ virtual void sendKeyReleaseEvent(uint code);
+
+ QWaylandSurface *focus() const;
+ QWaylandClient *focusClient() const;
+
+ void startGrab(QWaylandKeyboardGrabber *grab);
+ void endGrab();
+ QWaylandKeyboardGrabber *currentGrab() const;
+
+Q_SIGNALS:
+ void focusChanged(QWaylandSurface *surface);
+private:
+ void focusDestroyed(void *data);
+};
+
+QT_END_NAMESPACE
+
+#endif //QWAYLANDKEYBOARD_H
diff --git a/src/compositor/compositor_api/qwaylandoutput.cpp b/src/compositor/compositor_api/qwaylandoutput.cpp
index d94f38878..6cc7efbce 100644
--- a/src/compositor/compositor_api/qwaylandoutput.cpp
+++ b/src/compositor/compositor_api/qwaylandoutput.cpp
@@ -306,6 +306,11 @@ void QWaylandOutput::setHeight(int newHeight)
d_ptr->setHeight(newHeight);
}
+QPointF QWaylandOutput::mapToOutputSpace(const QPointF &point)
+{
+ return point + d_ptr->topLeft();
+}
+
void QWaylandOutput::windowDestroyed()
{
delete this;
diff --git a/src/compositor/compositor_api/qwaylandoutput.h b/src/compositor/compositor_api/qwaylandoutput.h
index c602bf223..910507ab2 100644
--- a/src/compositor/compositor_api/qwaylandoutput.h
+++ b/src/compositor/compositor_api/qwaylandoutput.h
@@ -164,6 +164,8 @@ public:
Q_INVOKABLE virtual QWaylandSurfaceView *pickView(const QPointF &outputPosition) const;
Q_INVOKABLE virtual QPointF mapToView(QWaylandSurfaceView *view, const QPointF &surfacePosition) const;
+ Q_INVOKABLE QPointF mapToOutputSpace(const QPointF &point);
+
Q_SIGNALS:
void positionChanged();
void geometryChanged();
diff --git a/src/compositor/compositor_api/qwaylandoutputspace.cpp b/src/compositor/compositor_api/qwaylandoutputspace.cpp
index 3f78158d0..65497644d 100644
--- a/src/compositor/compositor_api/qwaylandoutputspace.cpp
+++ b/src/compositor/compositor_api/qwaylandoutputspace.cpp
@@ -188,4 +188,9 @@ QPointF QWaylandOutputSpace::mapToView(QWaylandSurfaceView *view, const QPointF
return globalPosition - (view->requestedPosition() + view->output()->geometry().topLeft());
}
+QPointF QWaylandOutputSpace::mapToSpace(QWaylandSurfaceView *view, const QPointF &local) const
+{
+ return local + view->requestedPosition() + view->output()->geometry().topLeft();
+}
+
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandoutputspace.h b/src/compositor/compositor_api/qwaylandoutputspace.h
index d8c40cf0c..c06ba3681 100644
--- a/src/compositor/compositor_api/qwaylandoutputspace.h
+++ b/src/compositor/compositor_api/qwaylandoutputspace.h
@@ -86,7 +86,8 @@ public:
Q_INVOKABLE QList<QWaylandOutput *>outputs(const QPoint &point) const;
Q_INVOKABLE QWaylandSurfaceView *pickView(const QPointF &globalPosition) const;
- Q_INVOKABLE QPointF mapToView(QWaylandSurfaceView *view, const QPointF &surfacePosition) const;
+ Q_INVOKABLE QPointF mapToView(QWaylandSurfaceView *view, const QPointF &spacePoint) const;
+ Q_INVOKABLE QPointF mapToSpace(QWaylandSurfaceView *view, const QPointF &local) const;
signals:
void surfaceRequestedPositionChanged(QWaylandSurface *surface, const QPointF &point);
diff --git a/src/compositor/compositor_api/qwaylandpointer.cpp b/src/compositor/compositor_api/qwaylandpointer.cpp
new file mode 100644
index 000000000..07f327adf
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandpointer.cpp
@@ -0,0 +1,257 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandpointer.h"
+#include "qwlpointer_p.h"
+#include <QtCompositor/QWaylandClient>
+#include <QtCompositor/QWaylandCompositor>
+
+QT_BEGIN_NAMESPACE
+
+QWaylandPointerGrabber::~QWaylandPointerGrabber()
+{
+}
+
+QWaylandPointer::QWaylandPointer(QWaylandInputDevice *seat, QObject *parent)
+ : QObject(* new QWaylandPointerPrivate(this, seat), parent)
+{
+ connect(&d_func()->m_focusDestroyListener, &QWaylandDestroyListener::fired, this, &QWaylandPointer::focusDestroyed);
+}
+
+void QWaylandDefaultPointerGrabber::focus()
+{
+// if (buttonPressed())
+// return;
+//
+// setFocus(m_currentPosition.view(), m_currentPosition.position());
+}
+
+void QWaylandDefaultPointerGrabber::motion(uint32_t time)
+{
+ struct wl_resource *focusResource = pointer->focusResource();
+ if (focusResource) {
+ wl_fixed_t x = wl_fixed_from_double(pointer->currentLocalPosition().x());
+ wl_fixed_t y = wl_fixed_from_double(pointer->currentLocalPosition().y());
+ wl_pointer_send_motion(focusResource, time, x, y);
+ }
+}
+
+void QWaylandDefaultPointerGrabber::button(uint32_t time, Qt::MouseButton button, uint32_t state)
+{
+ struct wl_resource *focusResource = pointer->focusResource();
+ if (focusResource) {
+ pointer->sendButton(focusResource, time, button, state);
+ }
+}
+
+QWaylandInputDevice *QWaylandPointer::inputDevice() const
+{
+ Q_D(const QWaylandPointer);
+ return d->seat();
+}
+
+QWaylandCompositor *QWaylandPointer::compositor() const
+{
+ Q_D(const QWaylandPointer);
+ return d->seat()->compositor();
+}
+
+QWaylandOutput *QWaylandPointer::output() const
+{
+ Q_D(const QWaylandPointer);
+ return d->output();
+}
+
+void QWaylandPointer::setOutput(QWaylandOutput *output)
+{
+ Q_D(QWaylandPointer);
+ d->setOutput(output);
+}
+
+void QWaylandPointer::startGrab(QWaylandPointerGrabber *currentGrab)
+{
+ Q_D(QWaylandPointer);
+ d->startGrab(currentGrab);
+}
+
+void QWaylandPointer::endGrab()
+{
+ Q_D(QWaylandPointer);
+ d->endGrab();
+}
+
+QWaylandPointerGrabber *QWaylandPointer::currentGrab() const
+{
+ Q_D(const QWaylandPointer);
+ return d->currentGrab();
+}
+
+Qt::MouseButton QWaylandPointer::grabButton() const
+{
+ Q_D(const QWaylandPointer);
+ return d->grabButton();
+}
+
+uint32_t QWaylandPointer::grabTime() const
+{
+ Q_D(const QWaylandPointer);
+ return d->grabTime();
+
+}
+
+uint32_t QWaylandPointer::grabSerial() const
+{
+ Q_D(const QWaylandPointer);
+ return d->grabSerial();
+}
+
+void QWaylandPointer::sendMousePressEvent(Qt::MouseButton button)
+{
+ Q_D(QWaylandPointer);
+ d->sendMousePressEvent(button);
+}
+void QWaylandPointer::sendMouseReleaseEvent(Qt::MouseButton button)
+{
+ Q_D(QWaylandPointer);
+ d->sendMouseReleaseEvent(button);
+}
+void QWaylandPointer::sendMouseMoveEvent(QWaylandSurfaceView *view, const QPointF &localPos, const QPointF &outputSpacePos)
+{
+ Q_D(QWaylandPointer);
+ d->sendMouseMoveEvent(view, localPos, outputSpacePos);
+}
+
+void QWaylandPointer::sendMouseWheelEvent(Qt::Orientation orientation, int delta)
+{
+ Q_D(QWaylandPointer);
+ d->sendMouseWheelEvent(orientation, delta);
+}
+
+void QWaylandPointer::resetCurrentView()
+{
+ Q_D(QWaylandPointer);
+ d->resetCurrentState();
+}
+
+QWaylandSurfaceView *QWaylandPointer::currentView() const
+{
+ Q_D(const QWaylandPointer);
+ return d->focusView();
+}
+
+QPointF QWaylandPointer::currentLocalPosition() const
+{
+ Q_D(const QWaylandPointer);
+ return d->currentLocalPosition();
+}
+
+QPointF QWaylandPointer::currentSpacePosition() const
+{
+ Q_D(const QWaylandPointer);
+ return d->currentSpacePosition();
+}
+
+bool QWaylandPointer::isButtonPressed() const
+{
+ Q_D(const QWaylandPointer);
+ return d->buttonPressed();
+}
+
+void QWaylandPointer::addClient(QWaylandClient *client, uint32_t id)
+{
+ Q_D(QWaylandPointer);
+ d->add(client->client(), id, QtWaylandServer::wl_pointer::interfaceVersion());
+}
+
+struct wl_resource *QWaylandPointer::focusResource() const
+{
+ Q_D(const QWaylandPointer);
+ if (!d->focusResource())
+ return Q_NULLPTR;
+
+ return d->focusResource()->handle;
+}
+
+void QWaylandPointer::sendButton(struct wl_resource *resource, uint32_t time, Qt::MouseButton button, uint32_t state)
+{
+ Q_D(QWaylandPointer);
+ uint32_t serial = compositor()->nextSerial();
+ d->send_button(resource, serial, time, toWaylandButton(button), state);
+}
+
+uint32_t QWaylandPointer::toWaylandButton(Qt::MouseButton button)
+{
+#ifndef BTN_LEFT
+ uint32_t BTN_LEFT = 0x110;
+#endif
+ // the range of valid buttons (evdev module) is from 0x110
+ // through 0x11f. 0x120 is the first 'Joystick' button.
+ switch (button) {
+ case Qt::LeftButton: return BTN_LEFT;
+ case Qt::RightButton: return uint32_t(0x111);
+ case Qt::MiddleButton: return uint32_t(0x112);
+ case Qt::ExtraButton1: return uint32_t(0x113); // AKA Qt::BackButton, Qt::XButton1
+ case Qt::ExtraButton2: return uint32_t(0x114); // AKA Qt::ForwardButton, Qt::XButton2
+ case Qt::ExtraButton3: return uint32_t(0x115);
+ case Qt::ExtraButton4: return uint32_t(0x116);
+ case Qt::ExtraButton5: return uint32_t(0x117);
+ case Qt::ExtraButton6: return uint32_t(0x118);
+ case Qt::ExtraButton7: return uint32_t(0x119);
+ case Qt::ExtraButton8: return uint32_t(0x11a);
+ case Qt::ExtraButton9: return uint32_t(0x11b);
+ case Qt::ExtraButton10: return uint32_t(0x11c);
+ case Qt::ExtraButton11: return uint32_t(0x11d);
+ case Qt::ExtraButton12: return uint32_t(0x11e);
+ case Qt::ExtraButton13: return uint32_t(0x11f);
+ // default should not occur; but if it does, then return Wayland's highest possible button number.
+ default: return uint32_t(0x11f);
+ }
+}
+
+void QWaylandPointer::focusDestroyed(void *data)
+{
+ Q_D(QWaylandPointer);
+ Q_UNUSED(data)
+ d->m_focusDestroyListener.reset();
+
+ d->m_currentPosition.reset();
+ d->m_focusResource = 0;
+ d->m_buttonCount = 0;
+ endGrab();
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/compositor/compositor_api/qwaylandpointer.h b/src/compositor/compositor_api/qwaylandpointer.h
new file mode 100644
index 000000000..a11140733
--- /dev/null
+++ b/src/compositor/compositor_api/qwaylandpointer.h
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDPOINTER_H
+#define QWAYLANDPOINTER_H
+
+#include <QtCompositor/QWaylandExtensionContainer>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandPointer;
+class QWaylandPointerPrivate;
+class QWaylandInputDevice;
+class QWaylandSurfaceView;
+class QWaylandOutput;
+class QWaylandClient;
+
+class Q_COMPOSITOR_EXPORT QWaylandPointerGrabber
+{
+public:
+ QWaylandPointerGrabber()
+ : pointer(Q_NULLPTR)
+ {}
+ virtual ~QWaylandPointerGrabber();
+
+ virtual void focus() = 0;
+ virtual void motion(uint32_t time) = 0;
+ virtual void button(uint32_t time, Qt::MouseButton button, uint32_t state) = 0;
+
+ QWaylandPointer *pointer;
+};
+
+class Q_COMPOSITOR_EXPORT QWaylandDefaultPointerGrabber : public QWaylandPointerGrabber
+{
+public:
+ QWaylandDefaultPointerGrabber()
+ : QWaylandPointerGrabber()
+ {}
+ QWaylandDefaultPointerGrabber(QWaylandPointer *pointer)
+ : QWaylandPointerGrabber()
+ { this->pointer = pointer; }
+
+ void focus() Q_DECL_OVERRIDE;
+ void motion(uint32_t time) Q_DECL_OVERRIDE;
+ void button(uint32_t time, Qt::MouseButton button, uint32_t state) Q_DECL_OVERRIDE;
+};
+class Q_COMPOSITOR_EXPORT QWaylandPointer : public QObject, public QWaylandExtensionContainer
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandPointer)
+ Q_PROPERTY(bool isButtonPressed READ isButtonPressed NOTIFY buttonPressedChanged)
+public:
+ QWaylandPointer(QWaylandInputDevice *seat, QObject *parent = 0);
+
+ QWaylandInputDevice *inputDevice() const;
+ QWaylandCompositor *compositor() const;
+
+ QWaylandOutput *output() const;
+ void setOutput(QWaylandOutput *output);
+
+ void startGrab(QWaylandPointerGrabber *currentGrab);
+ void endGrab();
+ QWaylandPointerGrabber *currentGrab() const;
+ Qt::MouseButton grabButton() const;
+
+ uint32_t grabTime() const;
+ uint32_t grabSerial() const;
+
+ virtual void sendMousePressEvent(Qt::MouseButton button);
+ virtual void sendMouseReleaseEvent(Qt::MouseButton button);
+ virtual void sendMouseMoveEvent(QWaylandSurfaceView *view, const QPointF &localPos, const QPointF &outputSpacePos);
+ virtual void sendMouseWheelEvent(Qt::Orientation orientation, int delta);
+
+ void resetCurrentView();
+ QWaylandSurfaceView *currentView() const;
+ QPointF currentLocalPosition() const;
+ QPointF currentSpacePosition() const;
+
+ bool isButtonPressed() const;
+
+ void addClient(QWaylandClient *client, uint32_t id);
+
+ struct wl_resource *focusResource() const;
+
+ static uint32_t toWaylandButton(Qt::MouseButton button);
+ void sendButton(struct wl_resource *resource, uint32_t time, Qt::MouseButton button, uint32_t state);
+Q_SIGNALS:
+ void outputChanged();
+ void buttonPressedChanged();
+
+private:
+ void focusDestroyed(void *data);
+ void pointerFocusChanged();
+};
+
+QT_END_NAMESPACE
+
+#endif /*QWAYLANDPOINTER_H*/
diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp
index cc463d08a..caf816353 100644
--- a/src/compositor/compositor_api/qwaylandsurface.cpp
+++ b/src/compositor/compositor_api/qwaylandsurface.cpp
@@ -300,6 +300,18 @@ void QWaylandSurface::leave(QWaylandOutput *output)
d->send_leave(outputResource->handle);
}
+void QWaylandSurface::markAsCursorSurface(bool cursorSurface)
+{
+ Q_D(QWaylandSurface);
+ d->setCursorSurface(cursorSurface);
+}
+
+bool QWaylandSurface::isCursorSurface() const
+{
+ Q_D(const QWaylandSurface);
+ return d->isCursorSurface();
+}
+
/*!
Updates the surface with the compositor's retained clipboard selection. While this
is done automatically when the surface receives keyboard focus, this function is
@@ -308,9 +320,9 @@ void QWaylandSurface::leave(QWaylandOutput *output)
void QWaylandSurface::updateSelection()
{
Q_D(QWaylandSurface);
- const QtWayland::InputDevice *inputDevice = d->compositor()->defaultInputDevice();
+ QWaylandInputDevice *inputDevice = d->compositor()->defaultInputDevice();
if (inputDevice) {
- const QtWayland::DataDevice *dataDevice = inputDevice->dataDevice();
+ const QtWayland::DataDevice *dataDevice = QWaylandInputDevicePrivate::get(inputDevice)->dataDevice();
if (dataDevice) {
d->compositor()->dataDeviceManager()->offerRetainedSelection(
dataDevice->resourceMap().value(d->resource()->client())->handle);
@@ -351,6 +363,12 @@ QWaylandSurface *QWaylandSurface::fromResource(::wl_resource *res)
return Q_NULLPTR;
}
+struct wl_resource *QWaylandSurface::resource() const
+{
+ Q_D(const QWaylandSurface);
+ return d->resource()->handle;
+}
+
QWaylandSurfacePrivate *QWaylandSurfacePrivate::get(QWaylandSurface *surface)
{
return surface ? surface->d_func() : Q_NULLPTR;
diff --git a/src/compositor/compositor_api/qwaylandsurface.h b/src/compositor/compositor_api/qwaylandsurface.h
index 96be55f7d..c84aee05a 100644
--- a/src/compositor/compositor_api/qwaylandsurface.h
+++ b/src/compositor/compositor_api/qwaylandsurface.h
@@ -169,10 +169,14 @@ public:
QList<QWaylandSurfaceView *> views() const;
static QWaylandSurface *fromResource(::wl_resource *resource);
+ struct wl_resource *resource() const;
void enter(QWaylandOutput *output);
void leave(QWaylandOutput *output);
+ void markAsCursorSurface(bool cursorSurface);
+ bool isCursorSurface() const;
+
public Q_SLOTS:
void updateSelection();
diff --git a/src/compositor/compositor_api/qwaylandsurfaceitem.cpp b/src/compositor/compositor_api/qwaylandsurfaceitem.cpp
index 3b0ec3a3e..b174961d9 100644
--- a/src/compositor/compositor_api/qwaylandsurfaceitem.cpp
+++ b/src/compositor/compositor_api/qwaylandsurfaceitem.cpp
@@ -192,9 +192,7 @@ void QWaylandSurfaceItem::mousePressEvent(QMouseEvent *event)
}
QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event);
- if (inputDevice->mouseFocus() != this)
- inputDevice->setMouseFocus(this, event->localPos(), event->windowPos());
- inputDevice->sendMousePressEvent(event->button(), event->localPos(), event->windowPos());
+ inputDevice->sendMousePressEvent(event->button());
}
void QWaylandSurfaceItem::mouseMoveEvent(QMouseEvent *event)
@@ -211,7 +209,7 @@ void QWaylandSurfaceItem::mouseReleaseEvent(QMouseEvent *event)
{
if (shouldSendInputEvents()) {
QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event);
- inputDevice->sendMouseReleaseEvent(event->button(), event->localPos(), event->windowPos());
+ inputDevice->sendMouseReleaseEvent(event->button());
} else {
event->ignore();
}
@@ -226,7 +224,7 @@ void QWaylandSurfaceItem::hoverEnterEvent(QHoverEvent *event)
}
if (shouldSendInputEvents()) {
QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event);
- inputDevice->sendMouseEnterEvent(this, event->pos());
+ inputDevice->sendMouseMoveEvent(this, event->pos(), QPoint());
} else {
event->ignore();
}
@@ -251,7 +249,7 @@ void QWaylandSurfaceItem::hoverLeaveEvent(QHoverEvent *event)
{
if (shouldSendInputEvents()) {
QWaylandInputDevice *inputDevice = compositor()->inputDeviceFor(event);
- inputDevice->sendMouseLeaveEvent(this);
+ inputDevice->sendResetCurrentMouseView();
} else {
event->ignore();
}
@@ -315,7 +313,7 @@ void QWaylandSurfaceItem::touchEvent(QTouchEvent *event)
event->accept();
if (inputDevice->mouseFocus() != this) {
- inputDevice->setMouseFocus(this, pointPos, pointPos);
+ inputDevice->sendMouseMoveEvent(this, pointPos, QPointF());
}
inputDevice->sendFullTouchEvent(event);
} else {
diff --git a/src/compositor/compositor_api/qwaylandsurfaceview.cpp b/src/compositor/compositor_api/qwaylandsurfaceview.cpp
index cfb9aa2ea..545532590 100644
--- a/src/compositor/compositor_api/qwaylandsurfaceview.cpp
+++ b/src/compositor/compositor_api/qwaylandsurfaceview.cpp
@@ -185,6 +185,13 @@ void QWaylandSurfaceView::setBroadcastRequestedPositionChanged(bool broadcast)
d->broadcastRequestedPositionChanged = broadcast;
}
+struct wl_resource *QWaylandSurfaceView::surfaceResource() const
+{
+ if (!d->surface)
+ return Q_NULLPTR;
+ return d->surface->resource();
+}
+
void QWaylandSurfaceView::waylandSurfaceChanged(QWaylandSurface *newSurface, QWaylandSurface *oldSurface)
{
if (d->output)
diff --git a/src/compositor/compositor_api/qwaylandsurfaceview.h b/src/compositor/compositor_api/qwaylandsurfaceview.h
index 07e8e661c..231244454 100644
--- a/src/compositor/compositor_api/qwaylandsurfaceview.h
+++ b/src/compositor/compositor_api/qwaylandsurfaceview.h
@@ -74,6 +74,8 @@ public:
bool broadcastRequestedPositionChanged() const;
void setBroadcastRequestedPositionChanged(bool broadcast);
+
+ struct wl_resource *surfaceResource() const;
protected:
virtual void waylandSurfaceChanged(QWaylandSurface *newSurface, QWaylandSurface *oldSurface);
virtual void waylandSurfaceDestroyed();