summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@theqtcompany.com>2015-08-19 11:22:54 +0200
committerJørgen Lind <jorgen.lind@theqtcompany.com>2015-08-28 13:10:33 +0200
commit9c88f97492959025f7433c9a379b474095efc0dd (patch)
treed4168230e7ca4d8e4322b20cc925113e7c729e14
parentb4a796f3c15f4fc47957aa2f3dd2a87c45e151fc (diff)
Move qwltouch_p.h into qwaylandtouch_p.h
-rw-r--r--src/compositor/compositor_api/compositor_api.pri1
-rw-r--r--src/compositor/compositor_api/qwaylandtouch.cpp92
-rw-r--r--src/compositor/compositor_api/qwaylandtouch_p.h (renamed from src/compositor/wayland_wrapper/qwltouch_p.h)40
-rw-r--r--src/compositor/wayland_wrapper/qwltouch.cpp159
-rw-r--r--src/compositor/wayland_wrapper/wayland_wrapper.pri2
5 files changed, 94 insertions, 200 deletions
diff --git a/src/compositor/compositor_api/compositor_api.pri b/src/compositor/compositor_api/compositor_api.pri
index ee07ff737..b8d97b205 100644
--- a/src/compositor/compositor_api/compositor_api.pri
+++ b/src/compositor/compositor_api/compositor_api.pri
@@ -13,6 +13,7 @@ HEADERS += \
compositor_api/qwaylandpointer.h \
compositor_api/qwaylandpointer_p.h \
compositor_api/qwaylandtouch.h \
+ compositor_api/qwaylandtouch_p.h \
compositor_api/qwaylandinputpanel.h \
compositor_api/qwaylandoutput.h \
compositor_api/qwaylanddrag.h \
diff --git a/src/compositor/compositor_api/qwaylandtouch.cpp b/src/compositor/compositor_api/qwaylandtouch.cpp
index dcce43f92..a5e35ae7d 100644
--- a/src/compositor/compositor_api/qwaylandtouch.cpp
+++ b/src/compositor/compositor_api/qwaylandtouch.cpp
@@ -35,16 +35,45 @@
****************************************************************************/
#include "qwaylandtouch.h"
+#include "qwaylandtouch_p.h"
#include <QtCompositor/QWaylandCompositor>
#include <QtCompositor/QWaylandInputDevice>
#include <QtCompositor/QWaylandView>
#include <QtCompositor/QWaylandClient>
-#include "qwltouch_p.h"
+#include <QtCompositor/private/qwlqttouch_p.h>
QT_BEGIN_NAMESPACE
+QWaylandTouchPrivate::QWaylandTouchPrivate(QWaylandTouch *touch, QWaylandInputDevice *seat)
+ : wl_touch()
+ , seat(seat)
+ , focusResource()
+ , defaultGrab()
+ , grab(&defaultGrab)
+{
+ grab->touch = touch;
+}
+
+void QWaylandTouchPrivate::resetFocusState()
+{
+ focusDestroyListener.reset();
+ focusResource = 0;
+}
+
+void QWaylandTouchPrivate::touch_destroy_resource(Resource *resource)
+{
+ if (focusResource == resource) {
+ resetFocusState();
+ }
+}
+
+void QWaylandTouchPrivate::touch_release(Resource *resource)
+{
+ wl_resource_destroy(resource->handle);
+}
+
QWaylandTouchGrabber::QWaylandTouchGrabber()
{
}
@@ -90,13 +119,13 @@ void QWaylandDefaultTouchGrabber::motion(uint32_t time, int touch_id, const QPoi
QWaylandTouch::QWaylandTouch(QWaylandInputDevice *seat, QObject *parent)
: QObject(*new QWaylandTouchPrivate(this, seat), parent)
{
- connect(&d_func()->m_focusDestroyListener, &QWaylandDestroyListener::fired, this, &QWaylandTouch::focusDestroyed);
+ connect(&d_func()->focusDestroyListener, &QWaylandDestroyListener::fired, this, &QWaylandTouch::focusDestroyed);
}
QWaylandInputDevice *QWaylandTouch::inputDevice() const
{
Q_D(const QWaylandTouch);
- return d->m_seat;
+ return d->seat;
}
QWaylandCompositor *QWaylandTouch::compositor() const
@@ -109,37 +138,76 @@ QWaylandCompositor *QWaylandTouch::compositor() const
void QWaylandTouch::startGrab(QWaylandTouchGrabber *grab)
{
Q_D(QWaylandTouch);
- d->startGrab(grab);
+ d->grab = grab;
+ grab->touch = this;
}
void QWaylandTouch::endGrab()
{
Q_D(QWaylandTouch);
- d->endGrab();
+ d->grab = &d->defaultGrab;
}
void QWaylandTouch::sendTouchPointEvent(int id, const QPointF &position, Qt::TouchPointState state)
{
Q_D(QWaylandTouch);
- d->sendTouchPoint(id, position, state);
+ switch (state) {
+ case Qt::TouchPointPressed:
+ d->sendDown(id, position);
+ break;
+ case Qt::TouchPointMoved:
+ d->sendMotion(id, position);
+ break;
+ case Qt::TouchPointReleased:
+ d->sendUp(id);
+ break;
+ case Qt::TouchPointStationary:
+ // stationary points are not sent through wayland, the client must cache them
+ break;
+ default:
+ break;
+ }
}
void QWaylandTouch::sendFrameEvent()
{
Q_D(QWaylandTouch);
- d->sendFrame();
+ if (d->focusResource)
+ d->send_frame(d->focusResource->handle);
}
void QWaylandTouch::sendCancelEvent()
{
Q_D(QWaylandTouch);
- d->sendCancel();
+ if (d->focusResource)
+ d->send_cancel(d->focusResource->handle);
}
void QWaylandTouch::sendFullTouchEvent(QTouchEvent *event)
{
Q_D(QWaylandTouch);
- d->sendFullTouchEvent(event);
+ if (event->type() == QEvent::TouchCancel) {
+ sendCancelEvent();
+ return;
+ }
+
+ QtWayland::TouchExtensionGlobal *ext = QtWayland::TouchExtensionGlobal::findIn(d->compositor());
+ if (ext && ext->postTouchEvent(event, d->seat->mouseFocus()))
+ return;
+
+ const QList<QTouchEvent::TouchPoint> points = event->touchPoints();
+ if (points.isEmpty())
+ return;
+
+ const int pointCount = points.count();
+ QPointF pos = d->seat->mouseFocus()->requestedPosition();
+ for (int i = 0; i < pointCount; ++i) {
+ const QTouchEvent::TouchPoint &tp(points.at(i));
+ // Convert the local pos in the compositor window to surface-relative.
+ QPointF p = tp.pos() - pos;
+ sendTouchPointEvent(tp.id(), p, tp.state());
+ }
+ sendFrameEvent();
}
void QWaylandTouch::addClient(QWaylandClient *client, uint32_t id)
@@ -151,15 +219,15 @@ void QWaylandTouch::addClient(QWaylandClient *client, uint32_t id)
struct wl_resource *QWaylandTouch::focusResource() const
{
Q_D(const QWaylandTouch);
- if (!d->focusResource())
+ if (!d->focusResource)
return Q_NULLPTR;
- return d->focusResource()->handle;
+ return d->focusResource->handle;
}
QWaylandView *QWaylandTouch::mouseFocus() const
{
Q_D(const QWaylandTouch);
- return d->m_seat->mouseFocus();
+ return d->seat->mouseFocus();
}
void QWaylandTouch::focusDestroyed(void *data)
diff --git a/src/compositor/wayland_wrapper/qwltouch_p.h b/src/compositor/compositor_api/qwaylandtouch_p.h
index c970d1c87..934221690 100644
--- a/src/compositor/wayland_wrapper/qwltouch_p.h
+++ b/src/compositor/compositor_api/qwaylandtouch_p.h
@@ -42,8 +42,8 @@
#include <QtCompositor/QWaylandDestroyListener>
#include <QtCompositor/QWaylandTouch>
#include <QtCompositor/QWaylandInputDevice>
-#include <QtCompositor/QWaylandClient>
#include <QtCompositor/QWaylandView>
+#include <QtCompositor/QWaylandCompositor>
#include <QtCore/QPoint>
#include <QtCore/private/qobject_p.h>
@@ -52,55 +52,41 @@
QT_BEGIN_NAMESPACE
-class QWaylandView;
-class QWaylandCompositor;
-
class Q_COMPOSITOR_EXPORT QWaylandTouchPrivate : public QObjectPrivate, public QtWaylandServer::wl_touch
{
Q_DECLARE_PUBLIC(QWaylandTouch)
public:
explicit QWaylandTouchPrivate(QWaylandTouch *touch, QWaylandInputDevice *seat);
- QWaylandCompositor *compositor() const { return m_seat->compositor(); }
-
- void startGrab(QWaylandTouchGrabber *grab);
- void endGrab();
-
- void sendCancel();
- void sendFrame();
-
- void sendTouchPoint(int id, const QPointF &point, Qt::TouchPointState state);
- void sendDown(int touch_id, const QPointF &position);
- void sendMotion(int touch_id, const QPointF &position);
- void sendUp(int touch_id);
-
- void sendFullTouchEvent(QTouchEvent *event);
+ QWaylandCompositor *compositor() const { return seat->compositor(); }
- Resource *focusResource() const { return m_focusResource; }
+ void sendDown(int touch_id, const QPointF &position) { grab->down(compositor()->currentTimeMsecs(), touch_id, position);}
+ void sendMotion(int touch_id, const QPointF &position) { grab->motion(compositor()->currentTimeMsecs(), touch_id, position); }
+ void sendUp(int touch_id) { grab->up(compositor()->currentTimeMsecs(), touch_id); }
void setFocusResource()
{
- if (m_focusResource)
+ if (focusResource)
return;
- QWaylandView *mouseFocus = m_seat->mouseFocus();
+ QWaylandView *mouseFocus = seat->mouseFocus();
if (!mouseFocus || !mouseFocus->surface())
return;
- m_focusResource = resourceMap().value(mouseFocus->surface()->waylandClient());
+ focusResource = resourceMap().value(mouseFocus->surface()->waylandClient());
}
private:
void resetFocusState();
void touch_destroy_resource(Resource *resource) Q_DECL_OVERRIDE;
void touch_release(Resource *resource) Q_DECL_OVERRIDE;
- QWaylandInputDevice *m_seat;
+ QWaylandInputDevice *seat;
- Resource *m_focusResource;
- QWaylandDestroyListener m_focusDestroyListener;
+ Resource *focusResource;
+ QWaylandDestroyListener focusDestroyListener;
- QWaylandDefaultTouchGrabber m_defaultGrab;
- QWaylandTouchGrabber *m_grab;
+ QWaylandDefaultTouchGrabber defaultGrab;
+ QWaylandTouchGrabber *grab;
};
QT_END_NAMESPACE
diff --git a/src/compositor/wayland_wrapper/qwltouch.cpp b/src/compositor/wayland_wrapper/qwltouch.cpp
deleted file mode 100644
index 226f68b6a..000000000
--- a/src/compositor/wayland_wrapper/qwltouch.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** 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 "qwltouch_p.h"
-
-#include <QtCompositor/QWaylandCompositor>
-#include "qwaylandview.h"
-#include "qwlqttouch_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QWaylandTouchPrivate::QWaylandTouchPrivate(QWaylandTouch *touch, QWaylandInputDevice *seat)
- : wl_touch()
- , m_seat(seat)
- , m_focusResource()
- , m_defaultGrab()
- , m_grab(&m_defaultGrab)
-{
- m_grab->touch = touch;
-}
-
-void QWaylandTouchPrivate::startGrab(QWaylandTouchGrabber *grab)
-{
- Q_Q(QWaylandTouch);
- m_grab = grab;
- grab->touch = q;
-}
-
-void QWaylandTouchPrivate::endGrab()
-{
- m_grab = &m_defaultGrab;
-}
-
-void QWaylandTouchPrivate::resetFocusState()
-{
- m_focusDestroyListener.reset();
- m_focusResource = 0;
-}
-
-void QWaylandTouchPrivate::touch_destroy_resource(Resource *resource)
-{
- if (m_focusResource == resource) {
- resetFocusState();
- }
-}
-
-void QWaylandTouchPrivate::touch_release(Resource *resource)
-{
- wl_resource_destroy(resource->handle);
-}
-
-void QWaylandTouchPrivate::sendCancel()
-{
- if (m_focusResource)
- send_cancel(m_focusResource->handle);
-}
-
-void QWaylandTouchPrivate::sendFrame()
-{
- if (m_focusResource)
- send_frame(m_focusResource->handle);
-}
-
-void QWaylandTouchPrivate::sendTouchPoint(int id, const QPointF &point, Qt::TouchPointState state)
-{
- switch (state) {
- case Qt::TouchPointPressed:
- sendDown(id, point);
- break;
- case Qt::TouchPointMoved:
- sendMotion(id, point);
- break;
- case Qt::TouchPointReleased:
- sendUp(id);
- break;
- case Qt::TouchPointStationary:
- // stationary points are not sent through wayland, the client must cache them
- break;
- default:
- break;
- }
-}
-
-void QWaylandTouchPrivate::sendDown(int touch_id, const QPointF &position)
-{
- m_grab->down(compositor()->currentTimeMsecs(), touch_id, position);
-}
-
-void QWaylandTouchPrivate::sendMotion(int touch_id, const QPointF &position)
-{
- m_grab->motion(compositor()->currentTimeMsecs(), touch_id, position);
-}
-
-void QWaylandTouchPrivate::sendUp(int touch_id)
-{
- m_grab->up(compositor()->currentTimeMsecs(), touch_id);
-}
-
-void QWaylandTouchPrivate::sendFullTouchEvent(QTouchEvent *event)
-{
- if (event->type() == QEvent::TouchCancel) {
- sendCancel();
- return;
- }
-
- QtWayland::TouchExtensionGlobal *ext = QtWayland::TouchExtensionGlobal::findIn(compositor());
- if (ext && ext->postTouchEvent(event, m_seat->mouseFocus()))
- return;
-
- const QList<QTouchEvent::TouchPoint> points = event->touchPoints();
- if (points.isEmpty())
- return;
-
- const int pointCount = points.count();
- QPointF pos = m_seat->mouseFocus()->requestedPosition();
- for (int i = 0; i < pointCount; ++i) {
- const QTouchEvent::TouchPoint &tp(points.at(i));
- // Convert the local pos in the compositor window to surface-relative.
- QPointF p = tp.pos() - pos;
- sendTouchPoint(tp.id(), p, tp.state());
- }
- sendFrame();
-}
-
-QT_END_NAMESPACE
diff --git a/src/compositor/wayland_wrapper/wayland_wrapper.pri b/src/compositor/wayland_wrapper/wayland_wrapper.pri
index 6355bbb2c..0de06a94a 100644
--- a/src/compositor/wayland_wrapper/wayland_wrapper.pri
+++ b/src/compositor/wayland_wrapper/wayland_wrapper.pri
@@ -13,7 +13,6 @@ HEADERS += \
wayland_wrapper/qwlinputmethodcontext_p.h \
wayland_wrapper/qwlregion_p.h \
wayland_wrapper/qwlsurfacebuffer_p.h \
- wayland_wrapper/qwltouch_p.h \
../shared/qwaylandxkb.h \
SOURCES += \
@@ -25,7 +24,6 @@ SOURCES += \
wayland_wrapper/qwlinputmethodcontext.cpp \
wayland_wrapper/qwlregion.cpp \
wayland_wrapper/qwlsurfacebuffer.cpp \
- wayland_wrapper/qwltouch.cpp \
../shared/qwaylandxkb.cpp \
INCLUDEPATH += wayland_wrapper