summaryrefslogtreecommitdiffstats
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
parentce58545b220a49354533a27ef79cdbc8d50186cd (diff)
Public input apis
-rw-r--r--examples/wayland/qwindow-compositor/qwindowcompositor.cpp6
-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.h (renamed from src/compositor/wayland_wrapper/qwllistener.cpp)39
-rw-r--r--src/compositor/compositor_api/qwaylanddestroylistener_p.h (renamed from src/compositor/wayland_wrapper/qwllistener_p.h)20
-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
-rw-r--r--src/compositor/extensions/extensions.pri1
-rw-r--r--src/compositor/extensions/qwaylandwindowmanagerextension.cpp60
-rw-r--r--src/compositor/extensions/qwaylandwindowmanagerextension.h30
-rw-r--r--src/compositor/extensions/qwaylandwindowmanagerextension_p.h61
-rw-r--r--src/compositor/extensions/qwlshellsurface.cpp67
-rw-r--r--src/compositor/extensions/qwlshellsurface_p.h14
-rw-r--r--src/compositor/extensions/qwltextinput.cpp4
-rw-r--r--src/compositor/global/qwaylandextension.h2
-rw-r--r--src/compositor/wayland_wrapper/qwlcompositor.cpp32
-rw-r--r--src/compositor/wayland_wrapper/qwlcompositor_p.h8
-rw-r--r--src/compositor/wayland_wrapper/qwldatadevice.cpp54
-rw-r--r--src/compositor/wayland_wrapper/qwldatadevice_p.h13
-rw-r--r--src/compositor/wayland_wrapper/qwldatadevicemanager.cpp10
-rw-r--r--src/compositor/wayland_wrapper/qwlinputdevice.cpp217
-rw-r--r--src/compositor/wayland_wrapper/qwlinputdevice_p.h71
-rw-r--r--src/compositor/wayland_wrapper/qwlinputmethod.cpp10
-rw-r--r--src/compositor/wayland_wrapper/qwlinputmethod_p.h11
-rw-r--r--src/compositor/wayland_wrapper/qwlkeyboard.cpp103
-rw-r--r--src/compositor/wayland_wrapper/qwlkeyboard_p.h71
-rw-r--r--src/compositor/wayland_wrapper/qwloutput_p.h1
-rw-r--r--src/compositor/wayland_wrapper/qwlpointer.cpp273
-rw-r--r--src/compositor/wayland_wrapper/qwlpointer_p.h105
-rw-r--r--src/compositor/wayland_wrapper/qwlsurface.cpp3
-rw-r--r--src/compositor/wayland_wrapper/qwltouch.cpp136
-rw-r--r--src/compositor/wayland_wrapper/qwltouch_p.h55
-rw-r--r--src/compositor/wayland_wrapper/wayland_wrapper.pri2
50 files changed, 1464 insertions, 978 deletions
diff --git a/examples/wayland/qwindow-compositor/qwindowcompositor.cpp b/examples/wayland/qwindow-compositor/qwindowcompositor.cpp
index a4de89696..b42855fd3 100644
--- a/examples/wayland/qwindow-compositor/qwindowcompositor.cpp
+++ b/examples/wayland/qwindow-compositor/qwindowcompositor.cpp
@@ -396,7 +396,7 @@ bool QWindowCompositor::eventFilter(QObject *obj, QEvent *event)
m_surfaces.append(target->surface());
m_renderScheduler.start(0);
}
- input->sendMousePressEvent(me->button(), local, me->localPos());
+ input->sendMousePressEvent(me->button());
}
return true;
}
@@ -410,7 +410,7 @@ bool QWindowCompositor::eventFilter(QObject *obj, QEvent *event)
QPointF localPos;
if (target)
localPos = toView(target, me->localPos());
- input->sendMouseReleaseEvent(me->button(), localPos, me->localPos());
+ input->sendMouseReleaseEvent(me->button());
}
return true;
}
@@ -466,7 +466,7 @@ bool QWindowCompositor::eventFilter(QObject *obj, QEvent *event)
target = viewAt(pointPos);
}
if (target && target != input->mouseFocus())
- input->setMouseFocus(target, pointPos, pointPos);
+ input->sendMouseMoveEvent(target, pointPos, pointPos);
if (input->mouseFocus())
input->sendFullTouchEvent(te);
break;
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/wayland_wrapper/qwllistener.cpp b/src/compositor/compositor_api/qwaylanddestroylistener.h
index 3099cc108..6e141b828 100644
--- a/src/compositor/wayland_wrapper/qwllistener.cpp
+++ b/src/compositor/compositor_api/qwaylanddestroylistener.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** 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.
@@ -34,32 +35,30 @@
**
****************************************************************************/
-#include "qwllistener_p.h"
+#ifndef QWAYLANDDESTROYLISTENER_H
+#define QWAYLANDDESTROYLISTENER_H
+
+#include <QtCore/QObject>
+#include <QtCompositor/qwaylandexport.h>
QT_BEGIN_NAMESPACE
-WlListener::WlListener()
-{
- m_listener.parent = this;
- m_listener.listener.notify = handler;
- wl_list_init(&m_listener.listener.link);
-}
+class QWaylandDestroyListenerPrivate;
-void WlListener::listenForDestruction(::wl_resource *resource)
+class Q_COMPOSITOR_EXPORT QWaylandDestroyListener : public QObject
{
- wl_resource_add_destroy_listener(resource, &m_listener.listener);
-}
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandDestroyListener)
+public:
+ QWaylandDestroyListener(QObject *parent = 0);
+ void listenForDestruction(struct wl_resource *resource);
+ void reset();
-void WlListener::reset()
-{
- wl_list_remove(&m_listener.listener.link);
- wl_list_init(&m_listener.listener.link);
-}
+Q_SIGNALS:
+ void fired(void *data);
-void WlListener::handler(wl_listener *listener, void *data)
-{
- WlListener *that = reinterpret_cast<Listener *>(listener)->parent;
- emit that->fired(data);
-}
+};
QT_END_NAMESPACE
+
+#endif /*QWAYLANDDESTROYLISTENER_H*/
diff --git a/src/compositor/wayland_wrapper/qwllistener_p.h b/src/compositor/compositor_api/qwaylanddestroylistener_p.h
index 8ecab6f7f..7e9c43778 100644
--- a/src/compositor/wayland_wrapper/qwllistener_p.h
+++ b/src/compositor/compositor_api/qwaylanddestroylistener_p.h
@@ -37,32 +37,28 @@
#ifndef QTWAYLAND_QWLLISTENER_H
#define QTWAYLAND_QWLLISTENER_H
-#include <QObject>
+#include "qwaylanddestroylistener.h"
+
+#include <QtCore/private/qobject_p.h>
#include <wayland-server.h>
QT_BEGIN_NAMESPACE
-class WlListener : public QObject
+class QWaylandDestroyListenerPrivate : public QObjectPrivate
{
- Q_OBJECT
public:
- WlListener();
-
- void listenForDestruction(::wl_resource *resource);
- void reset();
+ Q_DECLARE_PUBLIC(QWaylandDestroyListener)
-signals:
- void fired(void *data);
+ QWaylandDestroyListenerPrivate();
-private:
static void handler(wl_listener *listener, void *data);
struct Listener {
wl_listener listener;
- WlListener *parent;
+ QWaylandDestroyListenerPrivate *parent;
};
- Listener m_listener;
+ Listener listener;
};
QT_END_NAMESPACE
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();
diff --git a/src/compositor/extensions/extensions.pri b/src/compositor/extensions/extensions.pri
index 070c319c2..526ded510 100644
--- a/src/compositor/extensions/extensions.pri
+++ b/src/compositor/extensions/extensions.pri
@@ -13,6 +13,7 @@ HEADERS += \
extensions/qwlqtkey_p.h \
extensions/qwlshellsurface_p.h \
extensions/qwaylandwindowmanagerextension.h \
+ extensions/qwaylandwindowmanagerextension_p.h \
extensions/qwltextinput_p.h \
extensions/qwltextinputmanager_p.h \
extensions/qwlinputpanel_p.h \
diff --git a/src/compositor/extensions/qwaylandwindowmanagerextension.cpp b/src/compositor/extensions/qwaylandwindowmanagerextension.cpp
index 160fb690f..58abd661d 100644
--- a/src/compositor/extensions/qwaylandwindowmanagerextension.cpp
+++ b/src/compositor/extensions/qwaylandwindowmanagerextension.cpp
@@ -35,64 +35,64 @@
****************************************************************************/
#include "qwaylandwindowmanagerextension.h"
+#include "qwaylandwindowmanagerextension_p.h"
-#include <wayland_wrapper/qwldisplay_p.h>
-#include <wayland_wrapper/qwlcompositor_p.h>
+#include <QtCompositor/QWaylandCompositor>
+#include <QtCompositor/QWaylandClient>
-#include <compositor_api/qwaylandclient.h>
-#include <compositor_api/qwaylandcompositor.h>
-
-#include <wayland-server.h>
-
-#include <QUrl>
+#include <QtCore/QUrl>
QT_BEGIN_NAMESPACE
-WindowManagerServerIntegration::WindowManagerServerIntegration(QWaylandCompositor *compositor, QObject *parent)
- : QWaylandExtension(compositor)
- , QtWaylandServer::qt_windowmanager()
- , m_showIsFullScreen(false)
- , m_compositor(compositor)
-{
-}
-
-WindowManagerServerIntegration::~WindowManagerServerIntegration()
+QWaylandWindowManagerExtension::QWaylandWindowManagerExtension(QWaylandCompositor *compositor, QObject *parent)
+ : QWaylandExtensionTemplate(*new QWaylandWindowManagerExtensionPrivate(compositor), parent)
{
}
-void WindowManagerServerIntegration::initialize(QtWayland::Display *waylandDisplay)
+QWaylandWindowManagerExtensionPrivate::QWaylandWindowManagerExtensionPrivate(QWaylandCompositor *compositor)
+ : QWaylandExtensionTemplatePrivateImpl(compositor)
+ , m_showIsFullScreen(false)
+ , m_compositor(compositor)
{
- init(waylandDisplay->handle(), 1);
+ init(compositor->waylandDisplay(), 1);
}
-void WindowManagerServerIntegration::setShowIsFullScreen(bool value)
+void QWaylandWindowManagerExtension::setShowIsFullScreen(bool value)
{
- m_showIsFullScreen = value;
- Q_FOREACH (Resource *resource, resourceMap().values()) {
- send_hints(resource->handle, static_cast<int32_t>(m_showIsFullScreen));
+ Q_D(QWaylandWindowManagerExtension);
+ d->m_showIsFullScreen = value;
+ Q_FOREACH (QWaylandWindowManagerExtensionPrivate::Resource *resource, d->resourceMap().values()) {
+ d->send_hints(resource->handle, static_cast<int32_t>(d->m_showIsFullScreen));
}
}
-void WindowManagerServerIntegration::sendQuitMessage(wl_client *client)
+void QWaylandWindowManagerExtension::sendQuitMessage(wl_client *client)
{
- Resource *resource = resourceMap().value(client);
+ Q_D(QWaylandWindowManagerExtension);
+ QWaylandWindowManagerExtensionPrivate::Resource *resource = d->resourceMap().value(client);
if (resource)
- send_quit(resource->handle);
+ d->send_quit(resource->handle);
+}
+
+QWaylandWindowManagerExtension *QWaylandWindowManagerExtension::get(QWaylandExtensionContainer *container)
+{
+ return static_cast<QWaylandWindowManagerExtension *>(container->extension(QtWaylandServer::qt_windowmanager::interface()));
}
-void WindowManagerServerIntegration::windowmanager_bind_resource(Resource *resource)
+void QWaylandWindowManagerExtensionPrivate::windowmanager_bind_resource(Resource *resource)
{
send_hints(resource->handle, static_cast<int32_t>(m_showIsFullScreen));
}
-void WindowManagerServerIntegration::windowmanager_destroy_resource(Resource *resource)
+void QWaylandWindowManagerExtensionPrivate::windowmanager_destroy_resource(Resource *resource)
{
m_urls.remove(resource);
}
-void WindowManagerServerIntegration::windowmanager_open_url(Resource *resource, uint32_t remaining, const QString &newUrl)
+void QWaylandWindowManagerExtensionPrivate::windowmanager_open_url(Resource *resource, uint32_t remaining, const QString &newUrl)
{
+ Q_Q(QWaylandWindowManagerExtension);
QString url = m_urls.value(resource, QString());
url.append(newUrl);
@@ -101,7 +101,7 @@ void WindowManagerServerIntegration::windowmanager_open_url(Resource *resource,
m_urls.insert(resource, url);
else {
m_urls.remove(resource);
- m_compositor->openUrl(QWaylandClient::fromWlClient(resource->client()), QUrl(url));
+ q->openUrl(QWaylandClient::fromWlClient(resource->client()), QUrl(url));
}
}
diff --git a/src/compositor/extensions/qwaylandwindowmanagerextension.h b/src/compositor/extensions/qwaylandwindowmanagerextension.h
index 5cd64e06d..6c17c3961 100644
--- a/src/compositor/extensions/qwaylandwindowmanagerextension.h
+++ b/src/compositor/extensions/qwaylandwindowmanagerextension.h
@@ -37,11 +37,10 @@
#ifndef WAYLANDWINDOWMANAGERINTEGRATION_H
#define WAYLANDWINDOWMANAGERINTEGRATION_H
-#include <QtCompositor/qwaylandexport.h>
-#include <QtCompositor/private/qwayland-server-windowmanager.h>
+#include <QtCompositor/qwaylandextension.h>
+#include <QtCompositor/QWaylandClient>
-#include <QtCompositor/QWaylandExtension>
-#include <QMap>
+#include <QtCore/QUrl>
QT_BEGIN_NAMESPACE
@@ -51,28 +50,21 @@ namespace QtWayland {
class QWaylandCompositor;
-class Q_COMPOSITOR_EXPORT WindowManagerServerIntegration : public QWaylandExtension, public QtWaylandServer::qt_windowmanager
+class QWaylandWindowManagerExtensionPrivate;
+
+class Q_COMPOSITOR_EXPORT QWaylandWindowManagerExtension : public QWaylandExtensionTemplate
{
Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandWindowManagerExtension)
public:
- explicit WindowManagerServerIntegration(QWaylandCompositor *compositor, QObject *parent = 0);
- ~WindowManagerServerIntegration();
-
- void initialize(QtWayland::Display *waylandDisplay);
+ explicit QWaylandWindowManagerExtension(QWaylandCompositor *compositor, QObject *parent = 0);
void setShowIsFullScreen(bool value);
void sendQuitMessage(wl_client *client);
- const wl_interface *interface() const Q_DECL_OVERRIDE { return QtWaylandServer::qt_windowmanager::interface(); }
-protected:
- void windowmanager_bind_resource(Resource *resource) Q_DECL_OVERRIDE;
- void windowmanager_destroy_resource(Resource *resource) Q_DECL_OVERRIDE;
- void windowmanager_open_url(Resource *resource, uint32_t remaining, const QString &url) Q_DECL_OVERRIDE;
-
-private:
- bool m_showIsFullScreen;
- QWaylandCompositor *m_compositor;
- QMap<Resource*, QString> m_urls;
+ static QWaylandWindowManagerExtension *get(QWaylandExtensionContainer *container);
+signals:
+ void openUrl(QWaylandClient *client, const QUrl &url);
};
QT_END_NAMESPACE
diff --git a/src/compositor/extensions/qwaylandwindowmanagerextension_p.h b/src/compositor/extensions/qwaylandwindowmanagerextension_p.h
new file mode 100644
index 000000000..94f389034
--- /dev/null
+++ b/src/compositor/extensions/qwaylandwindowmanagerextension_p.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** 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 QWAYLANDWINDOWMANAGEREXTENSION_P_H
+#define QWAYLANDWINDOWMANAGEREXTENSION_P_H
+
+#include <QtCompositor/private/qwaylandextension_p.h>
+
+#include <QtCompositor/private/qwayland-server-windowmanager.h>
+
+#include <QMap>
+
+class Q_COMPOSITOR_EXPORT QWaylandWindowManagerExtensionPrivate : public QWaylandExtensionTemplatePrivateImpl<QtWaylandServer::qt_windowmanager>
+{
+ Q_DECLARE_PUBLIC(QWaylandWindowManagerExtension)
+public:
+ QWaylandWindowManagerExtensionPrivate(QWaylandCompositor *compositor);
+
+protected:
+ void windowmanager_bind_resource(Resource *resource) Q_DECL_OVERRIDE;
+ void windowmanager_destroy_resource(Resource *resource) Q_DECL_OVERRIDE;
+ void windowmanager_open_url(Resource *resource, uint32_t remaining, const QString &url) Q_DECL_OVERRIDE;
+private:
+ bool m_showIsFullScreen;
+ QWaylandCompositor *m_compositor;
+ QMap<Resource*, QString> m_urls;
+};
+#endif /*QWAYLANDWINDOWMANAGEREXTENSION_P_H*/
diff --git a/src/compositor/extensions/qwlshellsurface.cpp b/src/compositor/extensions/qwlshellsurface.cpp
index de53f60eb..ad171aa0e 100644
--- a/src/compositor/extensions/qwlshellsurface.cpp
+++ b/src/compositor/extensions/qwlshellsurface.cpp
@@ -66,7 +66,7 @@ const wl_interface *Shell::interface() const
return &wl_shell_interface;
}
-ShellSurfacePopupGrabber *Shell::getPopupGrabber(InputDevice *input)
+ShellSurfacePopupGrabber *Shell::getPopupGrabber(QWaylandInputDevice *input)
{
if (!m_popupGrabber.contains(input))
m_popupGrabber.insert(input, new ShellSurfacePopupGrabber(input));
@@ -223,10 +223,10 @@ void ShellSurface::shell_surface_move(Resource *resource,
return;
}
- InputDevice *input_device = InputDevice::fromSeatResource(input_device_super);
- Pointer *pointer = input_device->pointerDevice();
+ QWaylandInputDevicePrivate *input_device = QWaylandInputDevicePrivate::fromSeatResource(input_device_super);
+ QWaylandPointer *pointer = input_device->pointerDevice();
- m_moveGrabber = new ShellSurfaceMoveGrabber(this, pointer->position() - m_view->requestedPosition());
+ m_moveGrabber = new ShellSurfaceMoveGrabber(this, pointer->currentSpacePosition() - m_view->requestedPosition());
pointer->startGrab(m_moveGrabber);
}
@@ -246,10 +246,10 @@ void ShellSurface::shell_surface_resize(Resource *resource,
m_resizeGrabber = new ShellSurfaceResizeGrabber(this);
- InputDevice *input_device = InputDevice::fromSeatResource(input_device_super);
- Pointer *pointer = input_device->pointerDevice();
+ QWaylandInputDevicePrivate *input_device = QWaylandInputDevicePrivate::fromSeatResource(input_device_super);
+ QWaylandPointer *pointer = input_device->pointerDevice();
- m_resizeGrabber->point = pointer->position();
+ m_resizeGrabber->point = pointer->currentSpacePosition();
m_resizeGrabber->resize_edges = static_cast<wl_shell_surface_resize>(edges);
m_resizeGrabber->width = m_view->surface()->size().width();
m_resizeGrabber->height = m_view->surface()->size().height();
@@ -327,8 +327,8 @@ void ShellSurface::shell_surface_set_popup(Resource *resource, wl_resource *inpu
Q_UNUSED(input_device);
Q_UNUSED(flags);
- InputDevice *input = InputDevice::fromSeatResource(input_device);
- m_popupGrabber = m_shell->getPopupGrabber(input);
+ QWaylandInputDevicePrivate *input = QWaylandInputDevicePrivate::fromSeatResource(input_device);
+ m_popupGrabber = m_shell->getPopupGrabber(input->q_func());
m_popupSerial = serial;
m_surface->setTransientParent(Surface::fromResource(parent));
@@ -394,7 +394,7 @@ void ShellSurface::shell_surface_set_class(Resource *resource,
}
ShellSurfaceGrabber::ShellSurfaceGrabber(ShellSurface *shellSurface)
- : PointerGrabber()
+ : QWaylandPointerGrabber()
, shell_surface(shellSurface)
{
}
@@ -416,8 +416,8 @@ void ShellSurfaceResizeGrabber::motion(uint32_t time)
{
Q_UNUSED(time);
- int width_delta = point.x() - m_pointer->position().x();
- int height_delta = point.y() - m_pointer->position().y();
+ int width_delta = point.x() - pointer->currentSpacePosition().x();
+ int height_delta = point.y() - pointer->currentSpacePosition().y();
int new_height = height;
if (resize_edges & WL_SHELL_SURFACE_RESIZE_TOP)
@@ -439,7 +439,7 @@ void ShellSurfaceResizeGrabber::button(uint32_t time, Qt::MouseButton button, ui
Q_UNUSED(time)
if (button == Qt::LeftButton && !state) {
- m_pointer->endGrab();
+ pointer->endGrab();
shell_surface->resetResizeGrabber();
delete this;
}
@@ -459,7 +459,7 @@ void ShellSurfaceMoveGrabber::motion(uint32_t time)
{
Q_UNUSED(time);
- QPointF pos(m_pointer->position() - m_offset);
+ QPointF pos(pointer->currentSpacePosition() - m_offset);
shell_surface->m_view->setRequestedPosition(pos);
if (shell_surface->m_surface->transientParent()) {
QWaylandSurfaceView *view = shell_surface->m_surface->transientParent()->waylandSurface()->views().first();
@@ -474,15 +474,15 @@ void ShellSurfaceMoveGrabber::button(uint32_t time, Qt::MouseButton button, uint
Q_UNUSED(time)
if (button == Qt::LeftButton && !state) {
- m_pointer->setFocus(0, QPointF());
- m_pointer->endGrab();
+ pointer->resetCurrentView();
+ pointer->endGrab();
shell_surface->resetMoveGrabber();
delete this;
}
}
-ShellSurfacePopupGrabber::ShellSurfacePopupGrabber(InputDevice *inputDevice)
- : PointerGrabber()
+ShellSurfacePopupGrabber::ShellSurfacePopupGrabber(QWaylandInputDevice *inputDevice)
+ : QWaylandDefaultPointerGrabber()
, m_inputDevice(inputDevice)
, m_client(0)
, m_surfaces()
@@ -492,7 +492,7 @@ ShellSurfacePopupGrabber::ShellSurfacePopupGrabber(InputDevice *inputDevice)
uint32_t ShellSurfacePopupGrabber::grabSerial() const
{
- return m_inputDevice->pointerDevice()->grabSerial();
+ return QWaylandInputDevicePrivate::get(m_inputDevice)->pointerDevice()->grabSerial();
}
struct ::wl_client *ShellSurfacePopupGrabber::client() const
@@ -510,11 +510,11 @@ void ShellSurfacePopupGrabber::addPopup(ShellSurface *surface)
if (m_surfaces.isEmpty()) {
m_client = surface->resource()->client();
- if (m_inputDevice->pointerDevice()->buttonPressed())
+ if (QWaylandInputDevicePrivate::get(m_inputDevice)->pointerDevice()->isButtonPressed())
m_initialUp = false;
m_surfaces.append(surface);
- m_inputDevice->pointerDevice()->startGrab(this);
+ QWaylandInputDevicePrivate::get(m_inputDevice)->pointerDevice()->startGrab(this);
} else {
m_surfaces.append(surface);
}
@@ -527,30 +527,17 @@ void ShellSurfacePopupGrabber::removePopup(ShellSurface *surface)
m_surfaces.removeOne(surface);
if (m_surfaces.isEmpty())
- m_inputDevice->pointerDevice()->endGrab();
-}
-
-void ShellSurfacePopupGrabber::focus()
-{
- if (m_pointer->current() && m_pointer->current()->surface()->handle()->resource()->client() == m_client)
- m_pointer->setFocus(m_pointer->current(), m_pointer->currentPosition());
- else
- m_pointer->setFocus(0, QPointF());
-}
-
-void ShellSurfacePopupGrabber::motion(uint32_t time)
-{
- m_pointer->motion(time);
+ QWaylandInputDevicePrivate::get(m_inputDevice)->pointerDevice()->endGrab();
}
void ShellSurfacePopupGrabber::button(uint32_t time, Qt::MouseButton button, uint32_t state)
{
- if (m_pointer->focusResource()) {
- m_pointer->sendButton(time, button, state);
+ if (pointer->focusResource()) {
+ pointer->sendButton(pointer->focusResource(), time, button, state);
} else if (state == QtWaylandServer::wl_pointer::button_state_pressed &&
- (m_initialUp || time - m_pointer->grabTime() > 500) &&
- m_pointer->currentGrab() == this) {
- m_pointer->endGrab();
+ (m_initialUp || time - pointer->grabTime() > 500) &&
+ pointer->currentGrab() == this) {
+ pointer->endGrab();
Q_FOREACH (ShellSurface *surface, m_surfaces) {
surface->send_popup_done();
}
diff --git a/src/compositor/extensions/qwlshellsurface_p.h b/src/compositor/extensions/qwlshellsurface_p.h
index 804ee2cff..ddb373d80 100644
--- a/src/compositor/extensions/qwlshellsurface_p.h
+++ b/src/compositor/extensions/qwlshellsurface_p.h
@@ -70,12 +70,12 @@ public:
const wl_interface *interface() const Q_DECL_OVERRIDE;
- ShellSurfacePopupGrabber* getPopupGrabber(InputDevice *input);
+ ShellSurfacePopupGrabber* getPopupGrabber(QWaylandInputDevice *input);
private:
void shell_get_shell_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface) Q_DECL_OVERRIDE;
- QHash<InputDevice*, ShellSurfacePopupGrabber*> m_popupGrabber;
+ QHash<QWaylandInputDevice *, ShellSurfacePopupGrabber*> m_popupGrabber;
};
class Q_COMPOSITOR_EXPORT ShellSurface : public QWaylandExtension, public QtWaylandServer::wl_shell_surface
@@ -176,7 +176,7 @@ private:
friend class ShellSurfaceMoveGrabber;
};
-class ShellSurfaceGrabber : public PointerGrabber
+class ShellSurfaceGrabber : public QWaylandPointerGrabber
{
public:
ShellSurfaceGrabber(ShellSurface *shellSurface);
@@ -213,10 +213,10 @@ private:
QPointF m_offset;
};
-class ShellSurfacePopupGrabber : public PointerGrabber
+class ShellSurfacePopupGrabber : public QWaylandDefaultPointerGrabber
{
public:
- ShellSurfacePopupGrabber(InputDevice *inputDevice);
+ ShellSurfacePopupGrabber(QWaylandInputDevice *inputDevice);
uint32_t grabSerial() const;
@@ -226,12 +226,10 @@ public:
void addPopup(ShellSurface *surface);
void removePopup(ShellSurface *surface);
- 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;
private:
- InputDevice *m_inputDevice;
+ QWaylandInputDevice *m_inputDevice;
struct ::wl_client *m_client;
QList<ShellSurface *> m_surfaces;
bool m_initialUp;
diff --git a/src/compositor/extensions/qwltextinput.cpp b/src/compositor/extensions/qwltextinput.cpp
index af1b73cb6..5b5f8a6df 100644
--- a/src/compositor/extensions/qwltextinput.cpp
+++ b/src/compositor/extensions/qwltextinput.cpp
@@ -102,7 +102,7 @@ void TextInput::text_input_activate(Resource *, wl_resource *seat, wl_resource *
bool wasEmpty = m_activeInputMethods.isEmpty();
- InputMethod *inputMethod = InputDevice::fromSeatResource(seat)->inputMethod();
+ InputMethod *inputMethod = QWaylandInputDevicePrivate::fromSeatResource(seat)->inputMethod();
if (!m_activeInputMethods.contains(inputMethod)) {
m_activeInputMethods.append(inputMethod);
@@ -115,7 +115,7 @@ void TextInput::text_input_activate(Resource *, wl_resource *seat, wl_resource *
void TextInput::text_input_deactivate(Resource *, wl_resource *seat)
{
- InputMethod *inputMethod = InputDevice::fromSeatResource(seat)->inputMethod();
+ InputMethod *inputMethod = QWaylandInputDevicePrivate::fromSeatResource(seat)->inputMethod();
deactivate(inputMethod);
}
diff --git a/src/compositor/global/qwaylandextension.h b/src/compositor/global/qwaylandextension.h
index c051e366f..e31c6398d 100644
--- a/src/compositor/global/qwaylandextension.h
+++ b/src/compositor/global/qwaylandextension.h
@@ -48,6 +48,7 @@ QT_BEGIN_NAMESPACE
class QWaylandCompositor;
class QWaylandExtensionContainer;
class QWaylandExtensionPrivate;
+class QWaylandExtensionTemplatePrivate;
class Q_COMPOSITOR_EXPORT QWaylandExtension : public QObject
{
@@ -81,7 +82,6 @@ protected:
QVector<QWaylandExtension *> extension_vector;
};
-class QWaylandExtensionTemplatePrivate;
class Q_COMPOSITOR_EXPORT QWaylandExtensionTemplate : public QWaylandExtension
{
Q_OBJECT
diff --git a/src/compositor/wayland_wrapper/qwlcompositor.cpp b/src/compositor/wayland_wrapper/qwlcompositor.cpp
index 2de42fc2d..0aef63671 100644
--- a/src/compositor/wayland_wrapper/qwlcompositor.cpp
+++ b/src/compositor/wayland_wrapper/qwlcompositor.cpp
@@ -305,16 +305,6 @@ void Compositor::destroySurface(Surface *surface)
m_destroyed_surfaces << surface->waylandSurface();
}
-void Compositor::resetInputDevice(Surface *surface)
-{
- foreach (QWaylandInputDevice *dev, m_inputDevices) {
- if (dev->keyboardFocus() == surface->waylandSurface())
- dev->setKeyboardFocus(0);
- if (dev->mouseFocus() && dev->mouseFocus()->surface() == surface->waylandSurface())
- dev->setMouseFocus(0, QPointF(), QPointF());
- }
-}
-
void Compositor::unregisterSurface(QWaylandSurface *surface)
{
if (!m_all_surfaces.removeOne(surface))
@@ -403,18 +393,15 @@ void Compositor::initializeExtensions()
new TextInputManager(this);
new QWaylandInputPanel(waylandCompositor());
}
- if (m_extensions & QWaylandCompositor::WindowManagerExtension) {
- WindowManagerServerIntegration *wmint = new WindowManagerServerIntegration(m_qt_compositor, this);
- wmint->initialize(m_display);
- }
- if (m_extensions & QWaylandCompositor::DefaultShellExtension) {
+ if (m_extensions & QWaylandCompositor::WindowManagerExtension)
+ new QWaylandWindowManagerExtension(waylandCompositor());
+ if (m_extensions & QWaylandCompositor::DefaultShellExtension)
new Shell(waylandCompositor());
- }
}
void Compositor::initializeDefaultInputDevice()
{
- m_default_wayland_input_device = new QWaylandInputDevice(m_qt_compositor);
+ m_default_wayland_input_device = m_qt_compositor->createInputDevice();
registerInputDevice(m_default_wayland_input_device);
}
@@ -423,22 +410,15 @@ QList<QWaylandClient *> Compositor::clients() const
return m_clients;
}
-void Compositor::setClientFullScreenHint(bool value)
-{
- WindowManagerServerIntegration *wmExtension = static_cast<WindowManagerServerIntegration *>(waylandCompositor()->extension(QtWaylandServer::qt_windowmanager::name()));
- if (wmExtension)
- wmExtension->setShowIsFullScreen(value);
-}
-
QWaylandCompositor::ExtensionFlags Compositor::extensions() const
{
return m_extensions;
}
-InputDevice* Compositor::defaultInputDevice()
+QWaylandInputDevice *Compositor::defaultInputDevice()
{
// The list gets prepended so that default is the last element
- return m_inputDevices.last()->handle();
+ return m_inputDevices.last();
}
DataDeviceManager *Compositor::dataDeviceManager() const
diff --git a/src/compositor/wayland_wrapper/qwlcompositor_p.h b/src/compositor/wayland_wrapper/qwlcompositor_p.h
index 0862477e4..750807449 100644
--- a/src/compositor/wayland_wrapper/qwlcompositor_p.h
+++ b/src/compositor/wayland_wrapper/qwlcompositor_p.h
@@ -89,9 +89,7 @@ public:
void init();
- void sendFrameCallbacks(QList<QWaylandSurface *> visibleSurfaces);
-
- InputDevice *defaultInputDevice();
+ QWaylandInputDevice *defaultInputDevice();
void registerInputDevice(QWaylandInputDevice *device);
QList<QWaylandInputDevice *> inputDevices() const { return m_inputDevices; }
@@ -128,8 +126,6 @@ public:
QList<QWaylandClient *> clients() const;
- void setClientFullScreenHint(bool value);
-
QWaylandCompositor::ExtensionFlags extensions() const;
InputPanel *inputPanel() const;
@@ -145,8 +141,6 @@ public:
void overrideSelection(const QMimeData *data);
void feedRetainedSelectionData(QMimeData *data);
- void resetInputDevice(Surface *surface);
-
void unregisterSurface(QWaylandSurface *surface);
public slots:
diff --git a/src/compositor/wayland_wrapper/qwldatadevice.cpp b/src/compositor/wayland_wrapper/qwldatadevice.cpp
index c3a059f74..fd5c6d3ca 100644
--- a/src/compositor/wayland_wrapper/qwldatadevice.cpp
+++ b/src/compositor/wayland_wrapper/qwldatadevice.cpp
@@ -48,6 +48,7 @@
#include "qwaylanddrag.h"
#include "qwaylandsurfaceview.h"
+#include <QtCompositor/QWaylandClient>
#include <QDebug>
@@ -55,7 +56,7 @@ QT_BEGIN_NAMESPACE
namespace QtWayland {
-DataDevice::DataDevice(InputDevice *inputDevice)
+DataDevice::DataDevice(QWaylandInputDevice *inputDevice)
: wl_data_device()
, m_compositor(inputDevice->compositor())
, m_inputDevice(inputDevice)
@@ -68,12 +69,12 @@ DataDevice::DataDevice(InputDevice *inputDevice)
{
}
-void DataDevice::setFocus(QtWaylandServer::wl_keyboard::Resource *focusResource)
+void DataDevice::setFocus(QWaylandClient *focusClient)
{
- if (!focusResource)
+ if (!focusClient)
return;
- Resource *resource = resourceMap().value(focusResource->client());
+ Resource *resource = resourceMap().value(focusClient->client());
if (!resource)
return;
@@ -103,7 +104,7 @@ void DataDevice::setDragFocus(QWaylandSurfaceView *focus, const QPointF &localPo
if (!resource)
return;
- uint32_t serial = wl_display_next_serial(m_compositor->wl_display());
+ uint32_t serial = wl_display_next_serial(m_compositor->waylandDisplay());
DataOffer *offer = m_dragDataSource ? new DataOffer(m_dragDataSource, resource) : 0;
@@ -131,20 +132,20 @@ void DataDevice::sourceDestroyed(DataSource *source)
void DataDevice::focus()
{
- QWaylandSurfaceView *focus = outputSpace()->pickView(m_pointer->currentPosition());
-
- if (focus != m_dragFocus)
- setDragFocus(focus, outputSpace()->mapToView(focus, m_pointer->currentPosition()));
+ QWaylandSurfaceView *focus = pointer->currentView();
+ if (focus != m_dragFocus) {
+ setDragFocus(focus, pointer->currentLocalPosition());
+ }
}
void DataDevice::motion(uint32_t time)
{
if (m_dragIcon) {
- m_dragIcon->setRequestedPosition(m_pointer->currentPosition());
+ m_dragIcon->setRequestedPosition(pointer->currentSpacePosition());
}
if (m_dragFocusResource && m_dragFocus) {
- const QPointF &surfacePoint = outputSpace()->mapToView(m_dragFocus, m_pointer->currentPosition());
+ const QPointF &surfacePoint = outputSpace()->mapToView(m_dragFocus, pointer->currentSpacePosition());
send_motion(m_dragFocusResource->handle, time,
wl_fixed_from_double(surfacePoint.x()), wl_fixed_from_double(surfacePoint.y()));
}
@@ -155,37 +156,36 @@ void DataDevice::button(uint32_t time, Qt::MouseButton button, uint32_t state)
Q_UNUSED(time);
if (m_dragFocusResource &&
- m_pointer->grabButton() == button &&
- state == Pointer::button_state_released)
+ pointer->grabButton() == button &&
+ state == QWaylandPointerPrivate::button_state_released)
send_drop(m_dragFocusResource->handle);
- if (!m_pointer->buttonPressed() &&
- state == Pointer::button_state_released) {
+ if (!pointer->isButtonPressed() &&
+ state == QWaylandPointerPrivate::button_state_released) {
if (m_dragIcon) {
m_dragIcon = 0;
- Q_EMIT m_inputDevice->dragHandle()->iconChanged();
+ Q_EMIT QWaylandInputDevicePrivate::get(m_inputDevice)->dragHandle()->iconChanged();
}
setDragFocus(0, QPointF());
- m_pointer->endGrab();
+ pointer->endGrab();
}
}
void DataDevice::data_device_start_drag(Resource *resource, struct ::wl_resource *source, struct ::wl_resource *origin, struct ::wl_resource *icon, uint32_t serial)
{
- if (m_inputDevice->pointerDevice()->grabSerial() == serial) {
- if (!m_inputDevice->pointerDevice()->buttonPressed() ||
- m_inputDevice->pointerDevice()->focusSurface()->surface()->handle() != Surface::fromResource(origin))
+ if (QWaylandInputDevicePrivate::get(m_inputDevice)->pointerDevice()->grabSerial() == serial) {
+ if (!QWaylandInputDevicePrivate::get(m_inputDevice)->pointerDevice()->isButtonPressed() ||
+ QWaylandInputDevicePrivate::get(m_inputDevice)->pointerDevice()->currentView()->surface()->handle() != Surface::fromResource(origin))
return;
m_dragClient = resource->client();
m_dragDataSource = source != 0 ? DataSource::fromResource(source) : 0;
- m_dragIcon = icon != 0 ? m_compositor->waylandCompositor()->createSurfaceView(Surface::fromResource(icon)->waylandSurface()) : 0;
- Q_EMIT m_inputDevice->dragHandle()->iconChanged();
+ m_dragIcon = icon != 0 ? m_compositor->createSurfaceView(Surface::fromResource(icon)->waylandSurface()) : 0;
+ Q_EMIT QWaylandInputDevicePrivate::get(m_inputDevice)->dragHandle()->iconChanged();
- m_inputDevice->pointerDevice()->setFocus(0, QPointF());
- m_inputDevice->pointerDevice()->startGrab(this);
+ QWaylandInputDevicePrivate::get(m_inputDevice)->pointerDevice()->startGrab(this);
}
}
@@ -199,12 +199,12 @@ void DataDevice::data_device_set_selection(Resource *, struct ::wl_resource *sou
m_selectionSource->cancel();
m_selectionSource = dataSource;
- m_compositor->dataDeviceManager()->setCurrentSelectionSource(m_selectionSource);
+ m_compositor->handle()->dataDeviceManager()->setCurrentSelectionSource(m_selectionSource);
if (m_selectionSource)
m_selectionSource->setDevice(this);
- QtWaylandServer::wl_keyboard::Resource *focusResource = m_inputDevice->keyboardDevice()->focusResource();
- Resource *resource = focusResource ? resourceMap().value(focusResource->client()) : 0;
+ QWaylandClient *focusClient = m_inputDevice->keyboard()->focusClient();
+ Resource *resource = focusClient ? resourceMap().value(focusClient->client()) : 0;
if (resource && m_selectionSource) {
DataOffer *offer = new DataOffer(m_selectionSource, resource);
diff --git a/src/compositor/wayland_wrapper/qwldatadevice_p.h b/src/compositor/wayland_wrapper/qwldatadevice_p.h
index 59a9d2b27..a2facc111 100644
--- a/src/compositor/wayland_wrapper/qwldatadevice_p.h
+++ b/src/compositor/wayland_wrapper/qwldatadevice_p.h
@@ -39,6 +39,7 @@
#include <QtCompositor/private/qwayland-server-wayland.h>
#include <qwlinputdevice_p.h>
+#include <QtCompositor/QWaylandPointerGrabber>
#include <qwlpointer_p.h>
#include <QtCompositor/QWaylandOutputSpace>
@@ -53,12 +54,12 @@ class DataSource;
class InputDevice;
class Surface;
-class DataDevice : public QtWaylandServer::wl_data_device, public PointerGrabber
+class DataDevice : public QtWaylandServer::wl_data_device, public QWaylandPointerGrabber
{
public:
- DataDevice(InputDevice *inputDevice);
+ DataDevice(QWaylandInputDevice *inputDevice);
- void setFocus(QtWaylandServer::wl_keyboard::Resource *focusResource);
+ void setFocus(QWaylandClient *client);
void setDragFocus(QWaylandSurfaceView *focus, const QPointF &localPosition);
@@ -74,9 +75,9 @@ protected:
void data_device_set_selection(Resource *resource, struct ::wl_resource *source, uint32_t serial) Q_DECL_OVERRIDE;
private:
- QWaylandOutputSpace *outputSpace() const { return m_inputDevice->handle()->outputSpace(); }
- Compositor *m_compositor;
- InputDevice *m_inputDevice;
+ QWaylandOutputSpace *outputSpace() const { return m_inputDevice->outputSpace(); }
+ QWaylandCompositor *m_compositor;
+ QWaylandInputDevice *m_inputDevice;
DataSource *m_selectionSource;
diff --git a/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp b/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp
index feb97e4af..35bbf59f4 100644
--- a/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp
+++ b/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp
@@ -44,6 +44,8 @@
#include "qwlsurface_p.h"
#include "qwaylandmimehelper.h"
+#include <QtCompositor/private/qwaylandsurface_p.h>
+
#include <QtCore/QDebug>
#include <QtCore/QSocketNotifier>
#include <fcntl.h>
@@ -198,11 +200,11 @@ void DataDeviceManager::overrideSelection(const QMimeData &mimeData)
m_compositorOwnsSelection = true;
- InputDevice *dev = m_compositor->defaultInputDevice();
- Surface *focusSurface = dev->keyboardFocus();
+ QWaylandInputDevice *dev = m_compositor->defaultInputDevice();
+ QWaylandSurface *focusSurface = QWaylandInputDevicePrivate::get(dev)->keyboardFocus();
if (focusSurface)
offerFromCompositorToClient(
- dev->dataDevice()->resourceMap().value(focusSurface->resource()->client())->handle);
+ QWaylandInputDevicePrivate::get(dev)->dataDevice()->resourceMap().value(QWaylandSurfacePrivate::get(focusSurface)->resource()->client())->handle);
}
bool DataDeviceManager::offerFromCompositorToClient(wl_resource *clientDataDeviceResource)
@@ -242,7 +244,7 @@ void DataDeviceManager::data_device_manager_create_data_source(Resource *resourc
void DataDeviceManager::data_device_manager_get_data_device(Resource *resource, uint32_t id, struct ::wl_resource *seat)
{
- InputDevice *input_device = InputDevice::fromSeatResource(seat);
+ QWaylandInputDevicePrivate *input_device = QWaylandInputDevicePrivate::fromSeatResource(seat);
input_device->clientRequestedDataDevice(this, resource->client(), id);
}
diff --git a/src/compositor/wayland_wrapper/qwlinputdevice.cpp b/src/compositor/wayland_wrapper/qwlinputdevice.cpp
index 2e1720a9f..768050435 100644
--- a/src/compositor/wayland_wrapper/qwlinputdevice.cpp
+++ b/src/compositor/wayland_wrapper/qwlinputdevice.cpp
@@ -48,93 +48,79 @@
#include "qwlkeyboard_p.h"
#include "qwltouch_p.h"
#include "qwaylandsurfaceview.h"
+#include <QtCompositor/QWaylandClient>
#include <QtGui/QTouchEvent>
QT_BEGIN_NAMESPACE
-namespace QtWayland {
-
-InputDevice::InputDevice(QWaylandInputDevice *handle, Compositor *compositor, QWaylandInputDevice::CapabilityFlags caps)
- : QtWaylandServer::wl_seat(compositor->wl_display(), 3)
- , m_handle(handle)
- , m_dragHandle(new QWaylandDrag(this))
+QWaylandInputDevicePrivate::QWaylandInputDevicePrivate(QWaylandInputDevice *inputdevice, QWaylandCompositor *compositor, QWaylandInputDevice::CapabilityFlags caps)
+ : QObjectPrivate()
+ , QtWaylandServer::wl_seat(compositor->waylandDisplay(), 3)
+ , m_dragHandle(new QWaylandDrag(inputdevice))
, m_compositor(compositor)
, m_outputSpace(compositor->primaryOutputSpace())
, m_capabilities(caps)
- , m_pointer(m_capabilities & QWaylandInputDevice::Pointer ? new Pointer(m_compositor, this) : 0)
- , m_keyboard(m_capabilities & QWaylandInputDevice::Keyboard ? new Keyboard(m_compositor, this) : 0)
- , m_touch(m_capabilities & QWaylandInputDevice::Touch ? new Touch(m_compositor) : 0)
- , m_inputMethod(m_compositor->extensions() & QWaylandCompositor::TextInputExtension ? new InputMethod(m_compositor, this) : 0)
+ , m_pointer(m_capabilities & QWaylandInputDevice::Pointer ? new QWaylandPointer(inputdevice) : 0)
+ , m_keyboard(m_capabilities & QWaylandInputDevice::Keyboard ? new QWaylandKeyboard(inputdevice) : 0)
+ , m_touch(m_capabilities & QWaylandInputDevice::Touch ? new QWaylandTouch(inputdevice) : 0)
+ , m_inputMethod(m_compositor->extensionFlags() & QWaylandCompositor::TextInputExtension ? new QtWayland::InputMethod(m_compositor, inputdevice) : 0)
, m_data_device()
{
}
-InputDevice::~InputDevice()
+QWaylandInputDevicePrivate::~QWaylandInputDevicePrivate()
{
}
-Pointer *InputDevice::pointerDevice()
+QWaylandPointer *QWaylandInputDevicePrivate::pointerDevice() const
{
return m_pointer.data();
}
-Keyboard *InputDevice::keyboardDevice()
+QWaylandKeyboard *QWaylandInputDevicePrivate::keyboardDevice() const
{
return m_keyboard.data();
}
-Touch *InputDevice::touchDevice()
+QWaylandTouch *QWaylandInputDevicePrivate::touchDevice() const
{
return m_touch.data();
}
-InputMethod *InputDevice::inputMethod()
+QtWayland::InputMethod *QWaylandInputDevicePrivate::inputMethod()
{
return m_inputMethod.data();
}
-const Pointer *InputDevice::pointerDevice() const
-{
- return m_pointer.data();
-}
-const Keyboard *InputDevice::keyboardDevice() const
-{
- return m_keyboard.data();
-}
-
-const Touch *InputDevice::touchDevice() const
-{
- return m_touch.data();
-}
-
-void InputDevice::seat_destroy_resource(wl_seat::Resource *)
+void QWaylandInputDevicePrivate::seat_destroy_resource(wl_seat::Resource *)
{
// cleanupDataDeviceForClient(resource->client(), true);
}
-void InputDevice::seat_bind_resource(wl_seat::Resource *resource)
+void QWaylandInputDevicePrivate::seat_bind_resource(wl_seat::Resource *resource)
{
// The order of m_capabilities matches the order defined in the wayland protocol
wl_seat::send_capabilities(resource->handle, (uint32_t)m_capabilities);
}
-void InputDevice::setCapabilities(QWaylandInputDevice::CapabilityFlags caps)
+void QWaylandInputDevicePrivate::setCapabilities(QWaylandInputDevice::CapabilityFlags caps)
{
+ Q_Q(QWaylandInputDevice);
if (m_capabilities != caps) {
QWaylandInputDevice::CapabilityFlags changed = caps ^ m_capabilities;
if (changed & QWaylandInputDevice::Pointer) {
- m_pointer.reset(m_pointer.isNull() ? new Pointer(m_compositor, this) : 0);
+ m_pointer.reset(m_pointer.isNull() ? new QWaylandPointer(q) : 0);
}
if (changed & QWaylandInputDevice::Keyboard) {
- m_keyboard.reset(m_keyboard.isNull() ? new Keyboard(m_compositor, this) : 0);
+ m_keyboard.reset(m_keyboard.isNull() ? new QWaylandKeyboard(q) : 0);
}
if (changed & QWaylandInputDevice::Touch) {
- m_touch.reset(m_touch.isNull() ? new Touch(m_compositor) : 0);
+ m_touch.reset(m_touch.isNull() ? new QWaylandTouch(q) : 0);
}
m_capabilities = caps;
@@ -145,110 +131,83 @@ void InputDevice::setCapabilities(QWaylandInputDevice::CapabilityFlags caps)
}
}
-void InputDevice::seat_get_pointer(wl_seat::Resource *resource, uint32_t id)
+void QWaylandInputDevicePrivate::seat_get_pointer(wl_seat::Resource *resource, uint32_t id)
{
if (!m_pointer.isNull()) {
- m_pointer->add(resource->client(), id, resource->version());
+ m_pointer->addClient(QWaylandClient::fromWlClient(resource->client()), id);
}
}
-void InputDevice::seat_get_keyboard(wl_seat::Resource *resource, uint32_t id)
+void QWaylandInputDevicePrivate::seat_get_keyboard(wl_seat::Resource *resource, uint32_t id)
{
if (!m_keyboard.isNull()) {
- m_keyboard->add(resource->client(), id, resource->version());
+ QWaylandKeyboardPrivate::get(m_keyboard.data())->add(resource->client(), id, resource->version());
}
}
-void InputDevice::seat_get_touch(wl_seat::Resource *resource, uint32_t id)
+void QWaylandInputDevicePrivate::seat_get_touch(wl_seat::Resource *resource, uint32_t id)
{
if (!m_touch.isNull()) {
- m_touch->add(resource->client(), id, resource->version());
+ m_touch->addClient(QWaylandClient::fromWlClient(resource->client()), id);
}
}
-void InputDevice::sendMousePressEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos)
+void QWaylandInputDevicePrivate::sendMousePressEvent(Qt::MouseButton button)
{
- pointerDevice()->sendMousePressEvent(button, localPos, globalPos);
+ pointerDevice()->sendMousePressEvent(button);
}
-void InputDevice::sendMouseReleaseEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos)
+void QWaylandInputDevicePrivate::sendMouseReleaseEvent(Qt::MouseButton button)
{
- pointerDevice()->sendMouseReleaseEvent(button, localPos, globalPos);
+ pointerDevice()->sendMouseReleaseEvent(button);
}
-void InputDevice::sendMouseMoveEvent(const QPointF &localPos, const QPointF &globalPos)
+void QWaylandInputDevicePrivate::sendMouseMoveEvent(QWaylandSurfaceView *surface, const QPointF &localPos, const QPointF &globalPos)
{
- pointerDevice()->sendMouseMoveEvent(localPos, globalPos);
+ pointerDevice()->sendMouseMoveEvent(surface, localPos,globalPos);
}
-void InputDevice::sendMouseMoveEvent(QWaylandSurfaceView *surface, const QPointF &localPos, const QPointF &globalPos)
-{
- setMouseFocus(surface,localPos,globalPos);
- sendMouseMoveEvent(localPos,globalPos);
-}
-
-void InputDevice::sendMouseWheelEvent(Qt::Orientation orientation, int delta)
+void QWaylandInputDevicePrivate::sendMouseWheelEvent(Qt::Orientation orientation, int delta)
{
pointerDevice()->sendMouseWheelEvent(orientation, delta);
}
-void InputDevice::sendMouseEnterEvent(QWaylandSurfaceView *view, const QPointF &localPos)
-{
- pointerDevice()->sendMouseEnterEvent(view, localPos);
-}
-
-void InputDevice::sendMouseLeaveEvent(QWaylandSurfaceView *view)
+void QWaylandInputDevicePrivate::sendResetCurrentMouseView()
{
- pointerDevice()->sendMouseLeaveEvent(view);
+ pointerDevice()->resetCurrentView();
}
-void InputDevice::sendTouchPointEvent(int id, double x, double y, Qt::TouchPointState state)
+void QWaylandInputDevicePrivate::sendTouchPointEvent(int id, const QPointF &point, Qt::TouchPointState state)
{
if (m_touch.isNull()) {
return;
}
-
- switch (state) {
- case Qt::TouchPointPressed:
- m_touch->sendDown(id, QPointF(x, y));
- break;
- case Qt::TouchPointMoved:
- m_touch->sendMotion(id, QPointF(x, y));
- break;
- case Qt::TouchPointReleased:
- m_touch->sendUp(id);
- break;
- case Qt::TouchPointStationary:
- // stationary points are not sent through wayland, the client must cache them
- break;
- default:
- break;
- }
+ m_touch->sendTouchPointEvent(id, point,state);
}
-void InputDevice::sendTouchFrameEvent()
+void QWaylandInputDevicePrivate::sendTouchFrameEvent()
{
if (!m_touch.isNull()) {
- m_touch->sendFrame();
+ m_touch->sendFrameEvent();
}
}
-void InputDevice::sendTouchCancelEvent()
+void QWaylandInputDevicePrivate::sendTouchCancelEvent()
{
if (!m_touch.isNull()) {
- m_touch->sendCancel();
+ m_touch->sendCancelEvent();
}
}
-void InputDevice::sendFullKeyEvent(QKeyEvent *event)
+void QWaylandInputDevicePrivate::sendFullKeyEvent(QKeyEvent *event)
{
if (!keyboardFocus()) {
qWarning("Cannot send key event, no keyboard focus, fix the compositor");
return;
}
- QtKeyExtensionGlobal *ext = QtKeyExtensionGlobal::get(m_compositor->waylandCompositor());
- if (ext && ext->postQtKeyEvent(event, keyboardFocus()))
+ QtWayland::QtKeyExtensionGlobal *ext = QtWayland::QtKeyExtensionGlobal::get(m_compositor);
+ if (ext && ext->postQtKeyEvent(event, keyboardFocus()->handle()))
return;
if (!m_keyboard.isNull() && !event->isAutoRepeat()) {
@@ -259,124 +218,92 @@ void InputDevice::sendFullKeyEvent(QKeyEvent *event)
}
}
-void InputDevice::sendFullKeyEvent(Surface *surface, QKeyEvent *event)
+void QWaylandInputDevicePrivate::sendFullKeyEvent(QWaylandSurface *surface, QKeyEvent *event)
{
- QtKeyExtensionGlobal *ext = QtKeyExtensionGlobal::get(m_compositor->waylandCompositor());
+ QtWayland::QtKeyExtensionGlobal *ext = QtWayland::QtKeyExtensionGlobal::get(m_compositor);
if (ext)
- ext->postQtKeyEvent(event, surface);
+ ext->postQtKeyEvent(event, surface->handle());
}
-void InputDevice::sendFullTouchEvent(QTouchEvent *event)
+void QWaylandInputDevicePrivate::sendFullTouchEvent(QTouchEvent *event)
{
if (!mouseFocus()) {
qWarning("Cannot send touch event, no pointer focus, fix the compositor");
return;
}
- if (event->type() == QEvent::TouchCancel) {
- sendTouchCancelEvent();
+ if (!m_touch)
return;
- }
- TouchExtensionGlobal *ext = TouchExtensionGlobal::get(m_compositor->waylandCompositor());
- if (ext && ext->postTouchEvent(event, mouseFocus()))
- return;
-
- const QList<QTouchEvent::TouchPoint> points = event->touchPoints();
- if (points.isEmpty())
- return;
-
- const int pointCount = points.count();
- QPointF pos = 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.x(), p.y(), tp.state());
- }
- sendTouchFrameEvent();
+ m_touch->sendFullTouchEvent(event);
}
-Surface *InputDevice::keyboardFocus() const
+QWaylandSurface *QWaylandInputDevicePrivate::keyboardFocus() const
{
- return m_keyboard.isNull() ? 0 : m_keyboard->focus();
+ if (m_keyboard.isNull() || !m_keyboard->focus())
+ return Q_NULLPTR;
+
+ return m_keyboard->focus();
}
/*!
* \return True if the keyboard focus is changed successfully. False for inactive transient surfaces.
*/
-bool InputDevice::setKeyboardFocus(Surface *surface)
+bool QWaylandInputDevicePrivate::setKeyboardFocus(QWaylandSurface *surface)
{
- if (surface && (surface->transientInactive() || surface->isDestroyed()))
+ if (surface && (surface->transientInactive() || surface->handle()->isDestroyed()))
return false;
if (!m_keyboard.isNull()) {
m_keyboard->setFocus(surface);
if (m_data_device)
- m_data_device->setFocus(m_keyboard->focusResource());
+ m_data_device->setFocus(m_keyboard->focusClient());
return true;
}
return false;
}
-QWaylandSurfaceView *InputDevice::mouseFocus() const
+QWaylandSurfaceView *QWaylandInputDevicePrivate::mouseFocus() const
{
- return m_pointer.isNull() ? 0 : m_pointer->focusSurface();
-}
-
-void InputDevice::setMouseFocus(QWaylandSurfaceView *view, const QPointF &localPos, const QPointF &globalPos)
-{
- if (view && view->surface()->handle()->isDestroyed())
- return;
-
- if (!m_pointer.isNull()) {
- m_pointer->setMouseFocus(view, localPos, globalPos);
- }
-
- if (!m_touch.isNull()) {
- // We have no separate touch focus management so make it match the pointer focus always.
- // No wl_touch_set_focus() is available so set it manually.
- m_touch->setFocus(view);
- }
+ return m_pointer.isNull() ? 0 : m_pointer->currentView();
}
-void InputDevice::clientRequestedDataDevice(DataDeviceManager *, struct wl_client *client, uint32_t id)
+void QWaylandInputDevicePrivate::clientRequestedDataDevice(QtWayland::DataDeviceManager *, struct wl_client *client, uint32_t id)
{
+ Q_Q(QWaylandInputDevice);
if (!m_data_device)
- m_data_device.reset(new DataDevice(this));
+ m_data_device.reset(new QtWayland::DataDevice(q));
m_data_device->add(client, id, 1);
}
-Compositor *InputDevice::compositor() const
+QWaylandCompositor *QWaylandInputDevicePrivate::compositor() const
{
return m_compositor;
}
-QWaylandInputDevice *InputDevice::handle() const
-{
- return m_handle;
-}
-
-QWaylandDrag *InputDevice::dragHandle() const
+QWaylandDrag *QWaylandInputDevicePrivate::dragHandle() const
{
return m_dragHandle.data();
}
-const DataDevice *InputDevice::dataDevice() const
+const QtWayland::DataDevice *QWaylandInputDevicePrivate::dataDevice() const
{
return m_data_device.data();
}
-QWaylandOutputSpace *InputDevice::outputSpace() const
+QWaylandOutputSpace *QWaylandInputDevicePrivate::outputSpace() const
{
return m_outputSpace;
}
-void InputDevice::setOutputSpace(QWaylandOutputSpace *outputSpace)
+void QWaylandInputDevicePrivate::setOutputSpace(QWaylandOutputSpace *outputSpace)
{
m_outputSpace = outputSpace;
}
+QWaylandInputDevicePrivate *QWaylandInputDevicePrivate::get(QWaylandInputDevice *device)
+{
+ return device->d_func();
}
QT_END_NAMESPACE
diff --git a/src/compositor/wayland_wrapper/qwlinputdevice_p.h b/src/compositor/wayland_wrapper/qwlinputdevice_p.h
index da59dd208..dba63c05a 100644
--- a/src/compositor/wayland_wrapper/qwlinputdevice_p.h
+++ b/src/compositor/wayland_wrapper/qwlinputdevice_p.h
@@ -45,6 +45,7 @@
#include <QtCore/QList>
#include <QtCore/QPoint>
#include <QtCore/QScopedPointer>
+#include <QtCore/private/qobject_p.h>
#ifndef QT_NO_WAYLAND_XKB
#include <xkbcommon/xkbcommon.h>
@@ -71,74 +72,70 @@ class Keyboard;
class Touch;
class InputMethod;
-class Q_COMPOSITOR_EXPORT InputDevice : public QtWaylandServer::wl_seat
+}
+
+class Q_COMPOSITOR_EXPORT QWaylandInputDevicePrivate : public QObjectPrivate, public QtWaylandServer::wl_seat
{
public:
- InputDevice(QWaylandInputDevice *handle, Compositor *compositor, QWaylandInputDevice::CapabilityFlags caps);
- ~InputDevice();
+ Q_DECLARE_PUBLIC(QWaylandInputDevice)
+
+ QWaylandInputDevicePrivate(QWaylandInputDevice *device, QWaylandCompositor *compositor, QWaylandInputDevice::CapabilityFlags caps);
+ ~QWaylandInputDevicePrivate();
- 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 sendMouseMoveEvent(QWaylandSurfaceView *surface, 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 &spacePos = QPointF());
void sendMouseWheelEvent(Qt::Orientation orientation, int delta);
- void sendMouseEnterEvent(QWaylandSurfaceView *view, const QPointF &localPos);
- void sendMouseLeaveEvent(QWaylandSurfaceView *view);
+ void sendResetCurrentMouseView();
- 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 sendFullKeyEvent(QKeyEvent *event);
- void sendFullKeyEvent(Surface *surface, QKeyEvent *event);
+ void sendFullKeyEvent(QWaylandSurface *surface, QKeyEvent *event);
void sendFullTouchEvent(QTouchEvent *event);
- Surface *keyboardFocus() const;
- bool setKeyboardFocus(Surface *surface);
+ QWaylandSurface *keyboardFocus() const;
+ bool setKeyboardFocus(QWaylandSurface *surface);
QWaylandSurfaceView *mouseFocus() const;
- void setMouseFocus(QWaylandSurfaceView *surface, const QPointF &localPos, const QPointF &globalPos);
- void clientRequestedDataDevice(DataDeviceManager *dndSelection, struct wl_client *client, uint32_t id);
- const DataDevice *dataDevice() const;
+ void clientRequestedDataDevice(QtWayland::DataDeviceManager *dndSelection, struct wl_client *client, uint32_t id);
+ const QtWayland::DataDevice *dataDevice() const;
QWaylandOutputSpace *outputSpace() const;
void setOutputSpace(QWaylandOutputSpace *outputSpace);
- Compositor *compositor() const;
- QWaylandInputDevice *handle() const;
+ QWaylandCompositor *compositor() const;
QWaylandDrag *dragHandle() const;
- Pointer *pointerDevice();
- Keyboard *keyboardDevice();
- Touch *touchDevice();
- InputMethod *inputMethod();
+ QWaylandPointer *pointerDevice() const;
+ QWaylandKeyboard *keyboardDevice() const;
+ QWaylandTouch *touchDevice() const;
+ QtWayland::InputMethod *inputMethod();
- const Pointer *pointerDevice() const;
- const Keyboard *keyboardDevice() const;
- const Touch *touchDevice() const;
-
- static InputDevice *fromSeatResource(struct ::wl_resource *resource)
+ static QWaylandInputDevicePrivate *fromSeatResource(struct ::wl_resource *resource)
{
- return static_cast<InputDevice *>(wl_seat::Resource::fromResource(resource)->seat_object);
+ return static_cast<QWaylandInputDevicePrivate *>(wl_seat::Resource::fromResource(resource)->seat_object);
}
- QWaylandInputDevice::CapabilityFlags capabilities() { return m_capabilities; }
+ QWaylandInputDevice::CapabilityFlags capabilities() const { return m_capabilities; }
void setCapabilities(QWaylandInputDevice::CapabilityFlags caps);
+ static QWaylandInputDevicePrivate *get(QWaylandInputDevice *device);
private:
- QWaylandInputDevice *m_handle;
QScopedPointer<QWaylandDrag> m_dragHandle;
- Compositor *m_compositor;
+ QWaylandCompositor *m_compositor;
QWaylandOutputSpace *m_outputSpace;
QWaylandInputDevice::CapabilityFlags m_capabilities;
- QScopedPointer<Pointer> m_pointer;
- QScopedPointer<Keyboard> m_keyboard;
- QScopedPointer<Touch> m_touch;
- QScopedPointer<InputMethod> m_inputMethod;
- QScopedPointer<DataDevice> m_data_device;
+ QScopedPointer<QWaylandPointer> m_pointer;
+ QScopedPointer<QWaylandKeyboard> m_keyboard;
+ QScopedPointer<QWaylandTouch> m_touch;
+ QScopedPointer<QtWayland::InputMethod> m_inputMethod;
+ QScopedPointer<QtWayland::DataDevice> m_data_device;
void seat_bind_resource(wl_seat::Resource *resource) Q_DECL_OVERRIDE;
@@ -152,8 +149,6 @@ private:
void seat_destroy_resource(wl_seat::Resource *resource) Q_DECL_OVERRIDE;
};
-}
-
QT_END_NAMESPACE
#endif // WLINPUTDEVICE_H
diff --git a/src/compositor/wayland_wrapper/qwlinputmethod.cpp b/src/compositor/wayland_wrapper/qwlinputmethod.cpp
index 187c4e13d..a9ea4bbb3 100644
--- a/src/compositor/wayland_wrapper/qwlinputmethod.cpp
+++ b/src/compositor/wayland_wrapper/qwlinputmethod.cpp
@@ -47,15 +47,15 @@ QT_BEGIN_NAMESPACE
namespace QtWayland {
-InputMethod::InputMethod(Compositor *compositor, InputDevice *seat)
- : QtWaylandServer::wl_input_method(seat->compositor()->wl_display(), 1)
+InputMethod::InputMethod(QWaylandCompositor *compositor, QWaylandInputDevice *seat)
+ : QtWaylandServer::wl_input_method(seat->compositor()->waylandDisplay(), 1)
, m_compositor(compositor)
, m_seat(seat)
, m_resource(0)
, m_textInput()
, m_context()
{
- connect(seat->keyboardDevice(), SIGNAL(focusChanged(Surface*)), this, SLOT(focusChanged(Surface*)));
+ connect(seat->keyboard(), SIGNAL(focusChanged(Surface*)), this, SLOT(focusChanged(Surface*)));
}
InputMethod::~InputMethod()
@@ -78,7 +78,7 @@ void InputMethod::activate(TextInput *textInput)
send_activate(m_resource->handle, m_context->resource()->handle);
- QWaylandInputPanelPrivate *panel = QWaylandInputPanelPrivate::get(m_compositor->waylandCompositor());
+ QWaylandInputPanelPrivate *panel = QWaylandInputPanelPrivate::get(m_compositor);
if (panel) {
panel->setFocus(textInput->focus());
panel->setCursorRectangle(textInput->cursorRectangle());
@@ -97,7 +97,7 @@ void InputMethod::deactivate()
m_textInput = 0;
m_context = 0;
- QWaylandInputPanelPrivate *panel = QWaylandInputPanelPrivate::get(m_compositor->waylandCompositor());
+ QWaylandInputPanelPrivate *panel = QWaylandInputPanelPrivate::get(m_compositor);
if (panel) {
panel->setFocus(0);
panel->setCursorRectangle(QRect());
diff --git a/src/compositor/wayland_wrapper/qwlinputmethod_p.h b/src/compositor/wayland_wrapper/qwlinputmethod_p.h
index 473810474..4d857c045 100644
--- a/src/compositor/wayland_wrapper/qwlinputmethod_p.h
+++ b/src/compositor/wayland_wrapper/qwlinputmethod_p.h
@@ -44,10 +44,11 @@
QT_BEGIN_NAMESPACE
+class QWaylandInputDevice;
+class QWaylandCompositor;
+
namespace QtWayland {
-class Compositor;
-class InputDevice;
class InputMethodContext;
class TextInput;
class Surface;
@@ -57,7 +58,7 @@ class InputMethod : public QObject, public QtWaylandServer::wl_input_method
Q_OBJECT
public:
- explicit InputMethod(Compositor *compositor, InputDevice *seat);
+ explicit InputMethod(QWaylandCompositor *compositor, QWaylandInputDevice *seat);
~InputMethod();
void activate(TextInput *textInput);
@@ -76,8 +77,8 @@ private slots:
void focusChanged(Surface *surface);
private:
- Compositor *m_compositor;
- InputDevice *m_seat;
+ QWaylandCompositor *m_compositor;
+ QWaylandInputDevice *m_seat;
Resource *m_resource;
TextInput *m_textInput;
InputMethodContext *m_context;
diff --git a/src/compositor/wayland_wrapper/qwlkeyboard.cpp b/src/compositor/wayland_wrapper/qwlkeyboard.cpp
index 8a76cbb40..9811f918a 100644
--- a/src/compositor/wayland_wrapper/qwlkeyboard.cpp
+++ b/src/compositor/wayland_wrapper/qwlkeyboard.cpp
@@ -40,6 +40,8 @@
#include <QFile>
#include <QStandardPaths>
+#include <QtCompositor/QWaylandClient>
+
#include "qwlcompositor_p.h"
#include "qwlsurface_p.h"
@@ -52,11 +54,8 @@
QT_BEGIN_NAMESPACE
-namespace QtWayland {
-
-Keyboard::Keyboard(Compositor *compositor, InputDevice *seat)
+QWaylandKeyboardPrivate::QWaylandKeyboardPrivate(QWaylandInputDevice *seat)
: QtWaylandServer::wl_keyboard()
- , m_compositor(compositor)
, m_seat(seat)
, m_grab(this)
, m_focus()
@@ -74,10 +73,9 @@ Keyboard::Keyboard(Compositor *compositor, InputDevice *seat)
#ifndef QT_NO_WAYLAND_XKB
initXKB();
#endif
- connect(&m_focusDestroyListener, &WlListener::fired, this, &Keyboard::focusDestroyed);
}
-Keyboard::~Keyboard()
+QWaylandKeyboardPrivate::~QWaylandKeyboardPrivate()
{
#ifndef QT_NO_WAYLAND_XKB
if (m_context) {
@@ -90,55 +88,57 @@ Keyboard::~Keyboard()
#endif
}
-KeyboardGrabber::~KeyboardGrabber()
-{
-}
-
-void Keyboard::startGrab(KeyboardGrabber *grab)
+void QWaylandKeyboardPrivate::startGrab(QWaylandKeyboardGrabber *grab)
{
+ Q_Q(QWaylandKeyboard);
m_grab = grab;
- m_grab->m_keyboard = this;
+ m_grab->m_keyboard = q;
m_grab->focused(m_focus);
}
-void Keyboard::endGrab()
+void QWaylandKeyboardPrivate::endGrab()
{
m_grab = this;
}
-KeyboardGrabber *Keyboard::currentGrab() const
+QWaylandKeyboardGrabber *QWaylandKeyboardPrivate::currentGrab() const
{
return m_grab;
}
-void Keyboard::focused(Surface *surface)
+QWaylandKeyboardPrivate *QWaylandKeyboardPrivate::get(QWaylandKeyboard *keyboard)
+{
+ return keyboard->d_func();
+}
+
+void QWaylandKeyboardPrivate::focused(QWaylandSurface *surface)
{
if (m_focusResource && m_focus != surface) {
- uint32_t serial = wl_display_next_serial(m_compositor->wl_display());
- send_leave(m_focusResource->handle, serial, m_focus->resource()->handle);
+ uint32_t serial = wl_display_next_serial(compositor()->waylandDisplay());
+ send_leave(m_focusResource->handle, serial, m_focus->handle()->resource()->handle);
m_focusDestroyListener.reset();
}
- Resource *resource = surface ? resourceMap().value(surface->resource()->client()) : 0;
+ Resource *resource = surface ? resourceMap().value(surface->client()->client()) : 0;
if (resource && (m_focus != surface || m_focusResource != resource)) {
- uint32_t serial = wl_display_next_serial(m_compositor->wl_display());
+ uint32_t serial = wl_display_next_serial(compositor()->waylandDisplay());
send_modifiers(resource->handle, serial, m_modsDepressed, m_modsLatched, m_modsLocked, m_group);
- send_enter(resource->handle, serial, surface->resource()->handle, QByteArray::fromRawData((char *)m_keys.data(), m_keys.size() * sizeof(uint32_t)));
- m_focusDestroyListener.listenForDestruction(surface->resource()->handle);
+ send_enter(resource->handle, serial, surface->resource(), QByteArray::fromRawData((char *)m_keys.data(), m_keys.size() * sizeof(uint32_t)));
+ m_focusDestroyListener.listenForDestruction(surface->resource());
}
m_focusResource = resource;
m_focus = surface;
- Q_EMIT focusChanged(m_focus);
+ Q_EMIT q_func()->focusChanged(m_focus);
}
-void Keyboard::setFocus(Surface* surface)
+void QWaylandKeyboardPrivate::setFocus(QWaylandSurface* surface)
{
m_grab->focused(surface);
}
-void Keyboard::setKeymap(const QWaylandKeymap &keymap)
+void QWaylandKeyboardPrivate::setKeymap(const QWaylandKeymap &keymap)
{
m_keymap = keymap;
@@ -152,41 +152,27 @@ void Keyboard::setKeymap(const QWaylandKeymap &keymap)
}
}
-void Keyboard::focusDestroyed(void *data)
-{
- Q_UNUSED(data)
- m_focusDestroyListener.reset();
-
- m_focus = 0;
- m_focusResource = 0;
-}
-
-void Keyboard::sendKeyModifiers(wl_keyboard::Resource *resource, uint32_t serial)
+void QWaylandKeyboardPrivate::sendKeyModifiers(wl_keyboard::Resource *resource, uint32_t serial)
{
send_modifiers(resource->handle, serial, m_modsDepressed, m_modsLatched, m_modsLocked, m_group);
}
-void Keyboard::sendKeyPressEvent(uint code)
+void QWaylandKeyboardPrivate::sendKeyPressEvent(uint code)
{
sendKeyEvent(code, WL_KEYBOARD_KEY_STATE_PRESSED);
}
-void Keyboard::sendKeyReleaseEvent(uint code)
+void QWaylandKeyboardPrivate::sendKeyReleaseEvent(uint code)
{
sendKeyEvent(code, WL_KEYBOARD_KEY_STATE_RELEASED);
}
-Surface *Keyboard::focus() const
+QWaylandSurface *QWaylandKeyboardPrivate::focus() const
{
return m_focus;
}
-QtWaylandServer::wl_keyboard::Resource *Keyboard::focusResource() const
-{
- return m_focusResource;
-}
-
-void Keyboard::keyboard_bind_resource(wl_keyboard::Resource *resource)
+void QWaylandKeyboardPrivate::keyboard_bind_resource(wl_keyboard::Resource *resource)
{
#ifndef QT_NO_WAYLAND_XKB
if (m_context) {
@@ -201,26 +187,33 @@ void Keyboard::keyboard_bind_resource(wl_keyboard::Resource *resource)
close(null_fd);
}
-void Keyboard::keyboard_destroy_resource(wl_keyboard::Resource *resource)
+void QWaylandKeyboardPrivate::keyboard_destroy_resource(wl_keyboard::Resource *resource)
{
if (m_focusResource == resource)
m_focusResource = 0;
}
-void Keyboard::keyboard_release(wl_keyboard::Resource *resource)
+void QWaylandKeyboardPrivate::keyboard_release(wl_keyboard::Resource *resource)
{
wl_resource_destroy(resource->handle);
}
-void Keyboard::key(uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
+void QWaylandKeyboardPrivate::key(uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
{
if (m_focusResource) {
send_key(m_focusResource->handle, serial, time, key, state);
}
}
-void Keyboard::keyEvent(uint code, uint32_t state)
+void QWaylandKeyboardPrivate::sendKeyEvent(uint code, uint32_t state)
{
+ // There must be no keys pressed when changing the keymap,
+ // see http://lists.freedesktop.org/archives/wayland-devel/2013-October/011395.html
+ if (m_pendingKeymap && m_keys.isEmpty())
+ updateKeymap();
+
+ uint32_t time = compositor()->currentTimeMsecs();
+ uint32_t serial = wl_display_next_serial(compositor()->waylandDisplay());
uint key = code - 8;
if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
m_keys << key;
@@ -241,7 +234,7 @@ void Keyboard::sendKeyEvent(uint code, uint32_t state)
m_grab->key(serial, time, key, state);
}
-void Keyboard::modifiers(uint32_t serial, uint32_t mods_depressed,
+void QWaylandKeyboardPrivate::modifiers(uint32_t serial, uint32_t mods_depressed,
uint32_t mods_latched, uint32_t mods_locked, uint32_t group)
{
if (m_focusResource) {
@@ -249,7 +242,7 @@ void Keyboard::modifiers(uint32_t serial, uint32_t mods_depressed,
}
}
-void Keyboard::updateModifierState(uint code, uint32_t state)
+void QWaylandKeyboardPrivate::updateModifierState(uint code, uint32_t state)
{
#ifndef QT_NO_WAYLAND_XKB
if (!m_context)
@@ -273,14 +266,14 @@ void Keyboard::updateModifierState(uint code, uint32_t state)
m_modsLocked = modsLocked;
m_group = group;
- m_grab->modifiers(wl_display_next_serial(m_compositor->wl_display()), m_modsDepressed, m_modsLatched, m_modsLocked, m_group);
+ m_grab->modifiers(wl_display_next_serial(compositor()->waylandDisplay()), m_modsDepressed, m_modsLatched, m_modsLocked, m_group);
#else
Q_UNUSED(code);
Q_UNUSED(state);
#endif
}
-void Keyboard::updateKeymap()
+void QWaylandKeyboardPrivate::updateKeymap()
{
// There must be no keys pressed when changing the keymap,
// see http://lists.freedesktop.org/archives/wayland-devel/2013-October/011395.html
@@ -299,7 +292,7 @@ void Keyboard::updateKeymap()
xkb_state_update_mask(m_state, 0, m_modsLatched, m_modsLocked, 0, 0, 0);
if (m_focusResource)
- sendKeyModifiers(m_focusResource, wl_display_next_serial(m_compositor->wl_display()));
+ sendKeyModifiers(m_focusResource, wl_display_next_serial(compositor()->waylandDisplay()));
#endif
}
@@ -334,7 +327,7 @@ static int createAnonymousFile(size_t size)
return fd;
}
-void Keyboard::initXKB()
+void QWaylandKeyboardPrivate::initXKB()
{
m_context = xkb_context_new(static_cast<xkb_context_flags>(0));
if (!m_context) {
@@ -345,7 +338,7 @@ void Keyboard::initXKB()
createXKBKeymap();
}
-void Keyboard::createXKBKeymap()
+void QWaylandKeyboardPrivate::createXKBKeymap()
{
if (!m_context)
return;
@@ -390,6 +383,4 @@ void Keyboard::createXKBKeymap()
}
#endif
-} // namespace QtWayland
-
QT_END_NAMESPACE
diff --git a/src/compositor/wayland_wrapper/qwlkeyboard_p.h b/src/compositor/wayland_wrapper/qwlkeyboard_p.h
index 62fc157a2..2579c2da1 100644
--- a/src/compositor/wayland_wrapper/qwlkeyboard_p.h
+++ b/src/compositor/wayland_wrapper/qwlkeyboard_p.h
@@ -40,8 +40,10 @@
#include <QtCompositor/qwaylandexport.h>
#include <QtCompositor/qwaylandinput.h>
+#include <QtCompositor/qwaylandkeyboard.h>
+#include <QtCompositor/qwaylanddestroylistener.h>
-#include <QObject>
+#include <QtCore/private/qobject_p.h>
#include <QtCompositor/private/qwayland-server-wayland.h>
#include <QtCore/QVector>
@@ -50,7 +52,6 @@
#include <xkbcommon/xkbcommon.h>
#endif
-#include "qwllistener_p.h"
QT_BEGIN_NAMESPACE
@@ -61,55 +62,39 @@ class InputDevice;
class Surface;
class Keyboard;
-class Q_COMPOSITOR_EXPORT KeyboardGrabber {
- public:
- virtual ~KeyboardGrabber();
- virtual void focused(Surface *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;
+}
- Keyboard *m_keyboard;
-};
-
-class Q_COMPOSITOR_EXPORT Keyboard : public QObject, public QtWaylandServer::wl_keyboard, public KeyboardGrabber
+class Q_COMPOSITOR_EXPORT QWaylandKeyboardPrivate : public QObjectPrivate
+ , public QtWaylandServer::wl_keyboard
+ , public QWaylandKeyboardGrabber
{
- Q_OBJECT
-
public:
- Keyboard(Compositor *compositor, InputDevice *seat);
- ~Keyboard();
+ Q_DECLARE_PUBLIC(QWaylandKeyboard)
+
+ QWaylandKeyboardPrivate(QWaylandInputDevice *seat);
+ ~QWaylandKeyboardPrivate();
- void setFocus(Surface *surface);
+ QWaylandCompositor *compositor() const { return m_seat->compositor(); }
+ void setFocus(QWaylandSurface *surface);
void setKeymap(const QWaylandKeymap &keymap);
void sendKeyModifiers(Resource *resource, uint32_t serial);
void sendKeyPressEvent(uint code);
void sendKeyReleaseEvent(uint code);
- Surface *focus() const;
- Resource *focusResource() const;
+ QWaylandSurface *focus() const;
+ Resource *focusResource() const { return m_focusResource; }
- void focused(Surface* surface);
+ void focused(QWaylandSurface* surface);
void key(uint32_t serial, uint32_t time, uint32_t key, uint32_t state);
void modifiers(uint32_t serial, uint32_t mods_depressed,
- uint32_t mods_latched, uint32_t mods_locked, uint32_t group);
+ uint32_t mods_latched, uint32_t mods_locked, uint32_t group);
- void keyEvent(uint code, uint32_t state);
- void updateModifierState(uint code, uint32_t state);
- void updateKeymap();
+ void startGrab(QWaylandKeyboardGrabber *grab);
+ void endGrab();
+ QWaylandKeyboardGrabber *currentGrab() const;
- void startGrab(KeyboardGrabber *grab);
- void endGrab();
- KeyboardGrabber *currentGrab() const;
-
-#ifndef QT_NO_WAYLAND_XKB
- struct xkb_state *xkbState() const { return m_state; }
- uint32_t xkbModsMask() const { return m_modsDepressed | m_modsLatched | m_modsLocked; }
-#endif
-
-Q_SIGNALS:
- void focusChanged(Surface *surface);
+ static QWaylandKeyboardPrivate *get(QWaylandKeyboard *keyboard);
protected:
void keyboard_bind_resource(Resource *resource);
@@ -118,20 +103,20 @@ protected:
private:
void sendKeyEvent(uint code, uint32_t state);
- void focusDestroyed(void *data);
+ void updateModifierState(uint code, uint32_t state);
+ void updateKeymap();
#ifndef QT_NO_WAYLAND_XKB
void initXKB();
void createXKBKeymap();
#endif
- Compositor *m_compositor;
- InputDevice *m_seat;
+ QWaylandInputDevice *m_seat;
- KeyboardGrabber* m_grab;
- Surface *m_focus;
+ QWaylandKeyboardGrabber* m_grab;
+ QWaylandSurface *m_focus;
Resource *m_focusResource;
- WlListener m_focusDestroyListener;
+ QWaylandDestroyListener m_focusDestroyListener;
QVector<uint32_t> m_keys;
uint32_t m_modsDepressed;
@@ -150,8 +135,6 @@ private:
#endif
};
-} // namespace QtWayland
-
QT_END_NAMESPACE
#endif // QTWAYLAND_QWLKEYBOARD_P_H
diff --git a/src/compositor/wayland_wrapper/qwloutput_p.h b/src/compositor/wayland_wrapper/qwloutput_p.h
index 974f5a789..1a261241b 100644
--- a/src/compositor/wayland_wrapper/qwloutput_p.h
+++ b/src/compositor/wayland_wrapper/qwloutput_p.h
@@ -95,6 +95,7 @@ public:
void setGeometry(const QRect &geometry);
void setWidth(int newWidth);
void setHeight(int newHeight);
+ QPoint topLeft() const { return geometry().topLeft(); }
bool sizeFollowsWindow() const;
void setSizeFollowsWindow(bool follow);
diff --git a/src/compositor/wayland_wrapper/qwlpointer.cpp b/src/compositor/wayland_wrapper/qwlpointer.cpp
index 389964fa2..127003d36 100644
--- a/src/compositor/wayland_wrapper/qwlpointer.cpp
+++ b/src/compositor/wayland_wrapper/qwlpointer.cpp
@@ -46,196 +46,77 @@
QT_BEGIN_NAMESPACE
-namespace QtWayland {
-
-using QtWaylandServer::wl_keyboard;
-
-static uint32_t 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);
- }
-}
-
-Pointer::Pointer(Compositor *compositor, InputDevice *seat)
- : wl_pointer()
- , PointerGrabber()
- , m_compositor(compositor)
+QWaylandPointerPrivate::QWaylandPointerPrivate(QWaylandPointer *pointer, QWaylandInputDevice *seat)
+ : QObjectPrivate()
+ , wl_pointer()
, m_seat(seat)
- , m_grab(this)
+ , m_output()
+ , m_defaultGrab(pointer)
+ , m_grab(&m_defaultGrab)
, m_grabButton()
, m_grabTime()
, m_grabSerial()
- , m_position(100, 100)
- , m_focus()
, m_focusResource()
, m_buttonCount()
{
- connect(&m_focusDestroyListener, &WlListener::fired, this, &Pointer::focusDestroyed);
-}
-
-void Pointer::setFocus(QWaylandSurfaceView *surface, const QPointF &position)
-{
- if (m_focusResource && m_focus != surface) {
- uint32_t serial = wl_display_next_serial(m_compositor->wl_display());
- send_leave(m_focusResource->handle, serial, m_focus->surface()->handle()->resource()->handle);
- m_focusDestroyListener.reset();
- }
-
- Resource *resource = surface ? resourceMap().value(surface->surface()->handle()->resource()->client()) : 0;
-
- if (resource && (m_focus != surface || resource != m_focusResource)) {
- uint32_t serial = wl_display_next_serial(m_compositor->wl_display());
- Keyboard *keyboard = m_seat->keyboardDevice();
- if (keyboard) {
- wl_keyboard::Resource *kr = keyboard->resourceMap().value(surface->surface()->handle()->resource()->client());
- if (kr)
- keyboard->sendKeyModifiers(kr, serial);
- }
- send_enter(resource->handle, serial, surface->surface()->handle()->resource()->handle,
- wl_fixed_from_double(position.x()), wl_fixed_from_double(position.y()));
-
- m_focusDestroyListener.listenForDestruction(surface->surface()->handle()->resource()->handle);
- }
-
- m_focusResource = resource;
- m_focus = surface;
-}
-
-void Pointer::focusDestroyed(void *data)
-{
- Q_UNUSED(data)
- m_focusDestroyListener.reset();
-
- m_focus = 0;
- m_focusResource = 0;
- m_buttonCount = 0;
- setMouseFocus(0, QPointF(), QPointF());
- endGrab();
}
-void Pointer::startGrab(PointerGrabber *grab)
+void QWaylandPointerPrivate::startGrab(QWaylandPointerGrabber *grab)
{
+ Q_Q(QWaylandPointer);
m_grab = grab;
- grab->m_pointer = this;
+ grab->pointer = q;
if (m_currentPosition.view())
grab->focus();
}
-void Pointer::endGrab()
+void QWaylandPointerPrivate::endGrab()
{
- m_grab = this;
+ m_grab = &m_defaultGrab;
m_grab->focus();
}
-void Pointer::setCurrent(QWaylandSurfaceView *surface, const QPointF &point)
-{
- m_currentPosition.setCurrent(surface, point);
-}
-
-bool Pointer::buttonPressed() const
+bool QWaylandPointerPrivate::buttonPressed() const
{
return m_buttonCount > 0;
}
-PointerGrabber *Pointer::currentGrab() const
+QWaylandPointerGrabber *QWaylandPointerPrivate::currentGrab() const
{
return m_grab;
}
-Qt::MouseButton Pointer::grabButton() const
+Qt::MouseButton QWaylandPointerPrivate::grabButton() const
{
return m_grabButton;
}
-uint32_t Pointer::grabTime() const
+uint32_t QWaylandPointerPrivate::grabTime() const
{
return m_grabTime;
}
-uint32_t Pointer::grabSerial() const
+uint32_t QWaylandPointerPrivate::grabSerial() const
{
return m_grabSerial;
}
-QWaylandSurfaceView *Pointer::focusSurface() const
-{
- return m_focus;
-}
-
-QWaylandSurfaceView *Pointer::current() const
-{
- return m_currentPosition.view();
-}
-
-QPointF Pointer::position() const
-{
- return m_position;
-}
-
-QPointF Pointer::currentPosition() const
-{
- return m_currentPosition.position();
-}
-
-QtWaylandServer::wl_pointer::Resource *Pointer::focusResource() const
-{
- return m_focusResource;
-}
-
-void Pointer::pointer_destroy_resource(wl_pointer::Resource *resource)
+void QWaylandPointerPrivate::pointer_destroy_resource(wl_pointer::Resource *resource)
{
if (m_focusResource == resource)
m_focusResource = 0;
}
-void Pointer::pointer_release(wl_pointer::Resource *resource)
+void QWaylandPointerPrivate::pointer_release(wl_pointer::Resource *resource)
{
wl_resource_destroy(resource->handle);
}
-void Pointer::setMouseFocus(QWaylandSurfaceView *surface, const QPointF &localPos, const QPointF &globalPos)
+void QWaylandPointerPrivate::sendMousePressEvent(Qt::MouseButton button)
{
- m_position = globalPos;
-
- m_currentPosition.setCurrent(surface, localPos);
-
- m_grab->focus();
-}
-
-void Pointer::sendButton(uint32_t time, Qt::MouseButton button, uint32_t state)
-{
- uint32_t serial = wl_display_next_serial(m_compositor->wl_display());
- send_button(m_focusResource->handle, serial, time, toWaylandButton(button), state);
-}
-
-void Pointer::sendMousePressEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos)
-{
- sendMouseMoveEvent(localPos, globalPos);
- uint32_t time = m_compositor->currentTimeMsecs();
+ Q_Q(QWaylandPointer);
+ uint32_t time = compositor()->currentTimeMsecs();
if (m_buttonCount == 0) {
m_grabButton = button;
m_grabTime = time;
@@ -243,112 +124,86 @@ void Pointer::sendMousePressEvent(Qt::MouseButton button, const QPointF &localPo
m_buttonCount++;
m_grab->button(time, button, WL_POINTER_BUTTON_STATE_PRESSED);
- if (m_buttonCount == 1)
- m_grabSerial = wl_display_get_serial(m_compositor->wl_display());
+ if (m_buttonCount == 1) {
+ m_grabSerial = wl_display_get_serial(compositor()->waylandDisplay());
+ q->buttonPressedChanged();
+ }
}
-void Pointer::sendMouseReleaseEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos)
+void QWaylandPointerPrivate::sendMouseReleaseEvent(Qt::MouseButton button)
{
- sendMouseMoveEvent(localPos, globalPos);
- uint32_t time = m_compositor->currentTimeMsecs();
+ Q_Q(QWaylandPointer);
+ uint32_t time = compositor()->currentTimeMsecs();
m_buttonCount--;
m_grab->button(time, button, WL_POINTER_BUTTON_STATE_RELEASED);
if (m_buttonCount == 1)
- m_grabSerial = wl_display_get_serial(m_compositor->wl_display());
+ m_grabSerial = wl_display_get_serial(compositor()->waylandDisplay());
+ if (m_buttonCount == 0)
+ q->buttonPressedChanged();
}
-void Pointer::sendMouseMoveEvent(const QPointF &localPos, const QPointF &globalPos)
+void QWaylandPointerPrivate::sendMouseMoveEvent(QWaylandSurfaceView *view, const QPointF &localPos, const QPointF &outputSpacePos)
{
- uint32_t time = m_compositor->currentTimeMsecs();
+ Q_Q(QWaylandPointer);
+ if (m_focusResource && focusView() != view) {
+ uint32_t serial = wl_display_next_serial(compositor()->waylandDisplay());
+ send_leave(m_focusResource->handle, serial, focusView()->surface()->handle()->resource()->handle);
+ m_focusDestroyListener.reset();
+ }
+
+ Resource *resource = view ? resourceMap().value(view->surface()->handle()->resource()->client()) : 0;
+
+ if (resource && (focusView() != view || resource != m_focusResource)) {
+ uint32_t serial = wl_display_next_serial(compositor()->waylandDisplay());
+ QWaylandKeyboard *keyboard = m_seat->keyboard();
+ if (keyboard) {
+ keyboard->sendKeyModifiers(view->surface()->client(), serial);
+ }
+ send_enter(resource->handle, serial, view->surface()->handle()->resource()->handle,
+ wl_fixed_from_double(currentLocalPosition().x()), wl_fixed_from_double(currentLocalPosition().y()));
- m_position = globalPos;
+ m_focusDestroyListener.listenForDestruction(view->surface()->handle()->resource()->handle);
+ }
- m_currentPosition.updatePosition(localPos);
+ m_focusResource = resource;
+ m_currentPosition.updatePosition(view, localPos);
+ m_spacePosition = outputSpacePos;
+ if (view && view->output())
+ q->setOutput(view->output());
- m_grab->motion(time);
+ m_grab->motion(compositor()->currentTimeMsecs());
}
-void Pointer::sendMouseWheelEvent(Qt::Orientation orientation, int delta)
+void QWaylandPointerPrivate::sendMouseWheelEvent(Qt::Orientation orientation, int delta)
{
if (!m_focusResource)
return;
- uint32_t time = m_compositor->currentTimeMsecs();
+ uint32_t time = compositor()->currentTimeMsecs();
uint32_t axis = orientation == Qt::Horizontal ? WL_POINTER_AXIS_HORIZONTAL_SCROLL
: WL_POINTER_AXIS_VERTICAL_SCROLL;
send_axis(m_focusResource->handle, time, axis, wl_fixed_from_int(-delta / 12));
}
-void Pointer::sendMouseEnterEvent(QWaylandSurfaceView *view, const QPointF &localPos)
-{
- if (view == m_currentPosition.view()) {
- qWarning("Possible input state error. Want to send enter event for the current input surface");
- }
-
- setMouseFocus(view, localPos, QPointF());
-}
-
-void Pointer::sendMouseLeaveEvent(QWaylandSurfaceView *view)
-{
- if (view != m_currentPosition.view()) {
- return;
- }
-
- setMouseFocus(Q_NULLPTR, QPointF(), QPointF());
-}
-
-void Pointer::focus()
-{
- if (buttonPressed())
- return;
-
- setFocus(m_currentPosition.view(), m_currentPosition.position());
-}
-
-void Pointer::motion(uint32_t time)
-{
- if (m_focusResource)
- send_motion(m_focusResource->handle, time,
- wl_fixed_from_double(m_currentPosition.x()),
- wl_fixed_from_double(m_currentPosition.y()));
-
-}
-
-void Pointer::button(uint32_t time, Qt::MouseButton button, uint32_t state)
-{
- if (m_focusResource) {
- sendButton(time, button, state);
- }
-
- if (!buttonPressed() && state == WL_POINTER_BUTTON_STATE_RELEASED)
- setFocus(m_currentPosition.view(), m_currentPosition.position());
-}
-
static void requestCursorSurface(QWaylandCompositor *compositor, QWaylandSurface *surface, int32_t hotspot_x, int hotspot_y)
{
compositor->currentCurserSurfaceRequest(surface, hotspot_x, hotspot_y);
}
-void Pointer::pointer_set_cursor(wl_pointer::Resource *resource, uint32_t serial, wl_resource *surface, int32_t hotspot_x, int32_t hotspot_y)
+void QWaylandPointerPrivate::pointer_set_cursor(wl_pointer::Resource *resource, uint32_t serial, wl_resource *surface, int32_t hotspot_x, int32_t hotspot_y)
{
Q_UNUSED(resource);
Q_UNUSED(serial);
if (!surface) {
- requestCursorSurface(m_compositor->waylandCompositor(), Q_NULLPTR, 0, 0);
+ requestCursorSurface(compositor(), Q_NULLPTR, 0, 0);
return;
}
- Surface *s = Surface::fromResource(surface);
- s->setCursorSurface(true);
- requestCursorSurface(m_compositor->waylandCompositor(), s->waylandSurface(), hotspot_x, hotspot_y);
+ QWaylandSurface *s = QWaylandSurface::fromResource(surface);
+ s->markAsCursorSurface(true);
+ requestCursorSurface(compositor(), s, hotspot_x, hotspot_y);
}
-PointerGrabber::~PointerGrabber()
-{
-}
-
-} // namespace QtWayland
-
QT_END_NAMESPACE
diff --git a/src/compositor/wayland_wrapper/qwlpointer_p.h b/src/compositor/wayland_wrapper/qwlpointer_p.h
index 5fe1fc99e..616464318 100644
--- a/src/compositor/wayland_wrapper/qwlpointer_p.h
+++ b/src/compositor/wayland_wrapper/qwlpointer_p.h
@@ -39,19 +39,21 @@
#define QTWAYLAND_QWLPOINTER_P_H
#include <QtCompositor/qwaylandexport.h>
+#include <QtCompositor/QWaylandDestroyListener>
+#include <QtCompositor/QWaylandPointer>
#include <QtCore/QList>
#include <QtCore/QPoint>
#include <QtCore/QObject>
+#include <QtCore/private/qobject_p.h>
#include <QtCompositor/private/qwayland-server-wayland.h>
#include <QtCompositor/QWaylandSurfaceView>
#include <QtCompositor/QWaylandSurface>
+#include <QtCompositor/QWaylandInputDevice>
#include <stdint.h>
-#include "qwllistener_p.h"
-
QT_BEGIN_NAMESPACE
class QWaylandSurfaceView;
@@ -59,21 +61,8 @@ class QWaylandSurfaceView;
namespace QtWayland {
class Compositor;
-class InputDevice;
-class Pointer;
class Surface;
-class Q_COMPOSITOR_EXPORT PointerGrabber {
-public:
- virtual ~PointerGrabber();
-
- virtual void focus() = 0;
- virtual void motion(uint32_t time) = 0;
- virtual void button(uint32_t time, Qt::MouseButton button, uint32_t state) = 0;
-
- Pointer *m_pointer;
-};
-
class CurrentPosition
{
public:
@@ -81,8 +70,15 @@ public:
: m_view(Q_NULLPTR)
{}
- void updatePosition(const QPointF &position)
+ void reset()
{
+ m_point = QPointF();
+ m_view = Q_NULLPTR;
+ }
+
+ void updatePosition(QWaylandSurfaceView *view, const QPointF &position)
+ {
+ m_view = view;
m_point = position;
//we adjust if the mouse position is on the edge
//to work around Qt's event propogation
@@ -102,59 +98,57 @@ public:
qreal x() const { return m_point.x(); }
qreal y() const { return m_point.y(); }
- void setView(QWaylandSurfaceView *view) { m_view = view; }
QWaylandSurfaceView *view() const { return m_view; }
- void setCurrent(QWaylandSurfaceView *view, const QPointF &position)
- {
- QPointF toSet = view || position.isNull() ? position : QPointF();
- setView(view);
- updatePosition(toSet);
- }
-
private:
QWaylandSurfaceView *m_view;
QPointF m_point;
};
-class Q_COMPOSITOR_EXPORT Pointer : public QObject, public QtWaylandServer::wl_pointer, public PointerGrabber
+
+} // namespace QtWayland
+
+class Q_COMPOSITOR_EXPORT QWaylandPointerPrivate : public QObjectPrivate
+ , public QtWaylandServer::wl_pointer
{
+ Q_DECLARE_PUBLIC(QWaylandPointer)
public:
- Pointer(Compositor *compositor, InputDevice *seat);
+ QWaylandPointerPrivate(QWaylandPointer *pointer, QWaylandInputDevice *seat);
+
+ QWaylandOutput *output() const { return m_output; }
+ void setOutput(QWaylandOutput *output)
+ {
+ if (m_output == output) return;
+ Q_Q(QWaylandPointer);
+ m_output = output;
+ q->outputChanged();
+ }
- void setFocus(QWaylandSurfaceView *surface, const QPointF &position);
- void startGrab(PointerGrabber *currentGrab);
+ void startGrab(QWaylandPointerGrabber *currentGrab);
void endGrab();
- PointerGrabber *currentGrab() const;
+ QWaylandPointerGrabber *currentGrab() const;
Qt::MouseButton grabButton() const;
uint32_t grabTime() const;
uint32_t grabSerial() const;
- void setCurrent(QWaylandSurfaceView *surface, const QPointF &point);
- void setMouseFocus(QWaylandSurfaceView *surface, const QPointF &localPos, const QPointF &globalPos);
-
- void sendButton(uint32_t time, Qt::MouseButton button, uint32_t state);
-
- void sendMousePressEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos);
- void sendMouseReleaseEvent(Qt::MouseButton button, const QPointF &localPos, const QPointF &globalPos);
- void sendMouseMoveEvent(const QPointF &localPos, const QPointF &globalPos);
+ void sendMousePressEvent(Qt::MouseButton button);
+ void sendMouseReleaseEvent(Qt::MouseButton button);
+ void sendMouseMoveEvent(QWaylandSurfaceView *view, const QPointF &localPos, const QPointF &outputSpacePos);
void sendMouseWheelEvent(Qt::Orientation orientation, int delta);
- void sendMouseEnterEvent(QWaylandSurfaceView *view, const QPointF &localPos);
- void sendMouseLeaveEvent(QWaylandSurfaceView *view);
- QWaylandSurfaceView *focusSurface() const;
- QWaylandSurfaceView *current() const;
- QPointF position() const;
- QPointF currentPosition() const;
- Resource *focusResource() const;
+ Resource *focusResource() const { return m_focusResource; }
+ QWaylandSurfaceView *focusView() const { return m_currentPosition.view(); }
bool buttonPressed() const;
- 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;
+ QWaylandInputDevice *seat() const { return m_seat; }
+ QWaylandCompositor *compositor() const { return m_seat->compositor(); }
+ void resetCurrentState() { m_currentPosition.reset(); }
+ QWaylandSurfaceView *currentView() const { return m_currentPosition.view(); }
+ QPointF currentSpacePosition() const { return m_spacePosition; }
+ QPointF currentLocalPosition() const { return m_currentPosition.position(); }
protected:
void pointer_set_cursor(Resource *resource, uint32_t serial, wl_resource *surface, int32_t hotspot_x, int32_t hotspot_y) Q_DECL_OVERRIDE;
void pointer_release(Resource *resource) Q_DECL_OVERRIDE;
@@ -163,28 +157,25 @@ protected:
private:
void focusDestroyed(void *data);
- Compositor *m_compositor;
- InputDevice *m_seat;
+ QWaylandInputDevice *m_seat;
+ QWaylandOutput *m_output;
+ QWaylandDefaultPointerGrabber m_defaultGrab;
+ QtWayland::CurrentPosition m_currentPosition;
+ QPointF m_spacePosition;
- PointerGrabber *m_grab;
+ QWaylandPointerGrabber *m_grab;
Qt::MouseButton m_grabButton;
uint32_t m_grabTime;
uint32_t m_grabSerial;
- QPointF m_position;
-
- QWaylandSurfaceView *m_focus;
Resource *m_focusResource;
- CurrentPosition m_currentPosition;
int m_buttonCount;
- WlListener m_focusDestroyListener;
+ QWaylandDestroyListener m_focusDestroyListener;
};
-} // namespace QtWayland
-
QT_END_NAMESPACE
#endif // QTWAYLAND_QWLPOINTER_P_H
diff --git a/src/compositor/wayland_wrapper/qwlsurface.cpp b/src/compositor/wayland_wrapper/qwlsurface.cpp
index 498d9f23a..d5eed707a 100644
--- a/src/compositor/wayland_wrapper/qwlsurface.cpp
+++ b/src/compositor/wayland_wrapper/qwlsurface.cpp
@@ -292,9 +292,8 @@ void Surface::setBackBuffer(SurfaceBuffer *buffer, const QRegion &damage)
m_damage = m_damage.intersected(QRect(QPoint(), m_size));
emit m_waylandSurface->damaged(m_damage);
- } else {
- m_compositor->resetInputDevice(this);
}
+
m_damage = damage;
QWaylandSurfacePrivate *priv = QWaylandSurfacePrivate::get(waylandSurface());
diff --git a/src/compositor/wayland_wrapper/qwltouch.cpp b/src/compositor/wayland_wrapper/qwltouch.cpp
index b5a17c1a6..98daa20c9 100644
--- a/src/compositor/wayland_wrapper/qwltouch.cpp
+++ b/src/compositor/wayland_wrapper/qwltouch.cpp
@@ -40,44 +40,34 @@
#include "qwlcompositor_p.h"
#include "qwlsurface_p.h"
#include "qwaylandsurfaceview.h"
+#include "qwlqttouch_p.h"
QT_BEGIN_NAMESPACE
-namespace QtWayland {
-
-Touch::Touch(Compositor *compositor)
+QWaylandTouchPrivate::QWaylandTouchPrivate(QWaylandTouch *touch, QWaylandInputDevice *seat)
: wl_touch()
- , m_compositor(compositor)
- , m_focus()
+ , m_seat(seat)
, m_focusResource()
- , m_grab(this)
-{
- m_grab->setTouch(this);
- connect(&m_focusDestroyListener, &WlListener::fired, this, &Touch::focusDestroyed);
-}
-
-void Touch::setFocus(QWaylandSurfaceView *surface)
+ , m_defaultGrab()
+ , m_grab(&m_defaultGrab)
{
- m_focusDestroyListener.reset();
- if (surface)
- m_focusDestroyListener.listenForDestruction(surface->surface()->handle()->resource()->handle);
-
- m_focus = surface;
- m_focusResource = surface ? resourceMap().value(surface->surface()->handle()->resource()->client()) : 0;
+ m_grab->touch = touch;
+ connect(&m_focusDestroyListener, &QWaylandDestroyListener::fired, this, &QWaylandTouchPrivate::focusDestroyed);
}
-void Touch::startGrab(TouchGrabber *grab)
+void QWaylandTouchPrivate::startGrab(QWaylandTouchGrabber *grab)
{
+ Q_Q(QWaylandTouch);
m_grab = grab;
- grab->setTouch(this);
+ grab->touch = q;
}
-void Touch::endGrab()
+void QWaylandTouchPrivate::endGrab()
{
- m_grab = this;
+ m_grab = &m_defaultGrab;
}
-void Touch::focusDestroyed(void *data)
+void QWaylandTouchPrivate::focusDestroyed(void *data)
{
Q_UNUSED(data)
m_focusDestroyListener.reset();
@@ -86,98 +76,88 @@ void Touch::focusDestroyed(void *data)
m_focusResource = 0;
}
-void Touch::touch_destroy_resource(Resource *resource)
+void QWaylandTouchPrivate::touch_destroy_resource(Resource *resource)
{
if (m_focusResource == resource)
m_focusResource = 0;
}
-void Touch::touch_release(Resource *resource)
+void QWaylandTouchPrivate::touch_release(Resource *resource)
{
wl_resource_destroy(resource->handle);
}
-void Touch::sendCancel()
+void QWaylandTouchPrivate::sendCancel()
{
if (m_focusResource)
send_cancel(m_focusResource->handle);
}
-void Touch::sendFrame()
+void QWaylandTouchPrivate::sendFrame()
{
if (m_focusResource)
send_frame(m_focusResource->handle);
}
-void Touch::sendDown(int touch_id, const QPointF &position)
+void QWaylandTouchPrivate::sendTouchPoint(int id, const QPointF &point, Qt::TouchPointState state)
{
- m_grab->down(m_compositor->currentTimeMsecs(), touch_id, position);
+ 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 Touch::sendMotion(int touch_id, const QPointF &position)
+void QWaylandTouchPrivate::sendDown(int touch_id, const QPointF &position)
{
- m_grab->motion(m_compositor->currentTimeMsecs(), touch_id, position);
+ m_grab->down(compositor()->currentTimeMsecs(), touch_id, position);
}
-void Touch::sendUp(int touch_id)
+void QWaylandTouchPrivate::sendMotion(int touch_id, const QPointF &position)
{
- m_grab->up(m_compositor->currentTimeMsecs(), touch_id);
+ m_grab->motion(compositor()->currentTimeMsecs(), touch_id, position);
}
-void Touch::down(uint32_t time, int touch_id, const QPointF &position)
+void QWaylandTouchPrivate::sendUp(int touch_id)
{
- if (!m_focusResource || !m_focus)
- return;
-
- uint32_t serial = wl_display_next_serial(m_compositor->wl_display());
-
- send_down(m_focusResource->handle, serial, time, m_focus->surface()->handle()->resource()->handle, touch_id,
- wl_fixed_from_double(position.x()), wl_fixed_from_double(position.y()));
+ m_grab->up(compositor()->currentTimeMsecs(), touch_id);
}
-void Touch::up(uint32_t time, int touch_id)
+void QWaylandTouchPrivate::sendFullTouchEvent(QTouchEvent *event)
{
- if (!m_focusResource)
+ if (event->type() == QEvent::TouchCancel) {
+ sendCancel();
return;
+ }
- uint32_t serial = wl_display_next_serial(m_compositor->wl_display());
-
- send_up(m_focusResource->handle, serial, time, touch_id);
-}
-
-void Touch::motion(uint32_t time, int touch_id, const QPointF &position)
-{
- if (!m_focusResource)
+ QtWayland::TouchExtensionGlobal *ext = qobject_cast<QtWayland::TouchExtensionGlobal *>(compositor()->extension(QtWaylandServer::qt_touch_extension::name()));
+ if (ext && ext->postTouchEvent(event, m_seat->mouseFocus()))
return;
- send_motion(m_focusResource->handle, time, touch_id,
- wl_fixed_from_double(position.x()), wl_fixed_from_double(position.y()));
-}
-
-TouchGrabber::TouchGrabber()
- : m_touch(0)
-{
-}
-
-TouchGrabber::~TouchGrabber()
-{
-}
-
-const Touch *TouchGrabber::touch() const
-{
- return m_touch;
-}
-
-Touch *TouchGrabber::touch()
-{
- return m_touch;
-}
+ const QList<QTouchEvent::TouchPoint> points = event->touchPoints();
+ if (points.isEmpty())
+ return;
-void TouchGrabber::setTouch(Touch *touch)
-{
- m_touch = touch;
+ 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();
}
-} // namespace QtWayland
-
QT_END_NAMESPACE
diff --git a/src/compositor/wayland_wrapper/qwltouch_p.h b/src/compositor/wayland_wrapper/qwltouch_p.h
index f3b7d5ee6..0ba8ba921 100644
--- a/src/compositor/wayland_wrapper/qwltouch_p.h
+++ b/src/compositor/wayland_wrapper/qwltouch_p.h
@@ -39,78 +39,57 @@
#define QTWAYLAND_QWLTOUCH_P_H
#include <QtCompositor/qwaylandexport.h>
+#include <QtCompositor/QWaylandDestroyListener>
+#include <QtCompositor/QWaylandTouch>
+#include <QtCompositor/QWaylandInputDevice>
#include <QtCore/QPoint>
-#include <QtCore/QObject>
+#include <QtCore/private/qobject_p.h>
#include <QtCompositor/private/qwayland-server-wayland.h>
-#include "qwllistener_p.h"
-
QT_BEGIN_NAMESPACE
class QWaylandSurfaceView;
+class QWaylandCompositor;
-namespace QtWayland {
-
-class Compositor;
-class Surface;
-class Touch;
-
-class Q_COMPOSITOR_EXPORT TouchGrabber {
-public:
- TouchGrabber();
- virtual ~TouchGrabber();
-
- virtual void down(uint32_t time, int touch_id, const QPointF &position) = 0;
- virtual void up(uint32_t time, int touch_id) = 0;
- virtual void motion(uint32_t time, int touch_id, const QPointF &position) = 0;
-
- const Touch *touch() const;
- Touch *touch();
- void setTouch(Touch *touch);
-
-private:
- Touch *m_touch;
-};
-
-class Q_COMPOSITOR_EXPORT Touch : public QObject, public QtWaylandServer::wl_touch, public TouchGrabber
+class Q_COMPOSITOR_EXPORT QWaylandTouchPrivate : public QObjectPrivate, public QtWaylandServer::wl_touch
{
+ Q_DECLARE_PUBLIC(QWaylandTouch)
public:
- explicit Touch(Compositor *compositor);
+ explicit QWaylandTouchPrivate(QWaylandTouch *touch, QWaylandInputDevice *seat);
- void setFocus(QWaylandSurfaceView *surface);
+ QWaylandCompositor *compositor() const { return m_seat->compositor(); }
- void startGrab(TouchGrabber *grab);
+ 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 down(uint32_t time, int touch_id, const QPointF &position);
- void up(uint32_t time, int touch_id);
- void motion(uint32_t time, int touch_id, const QPointF &position);
+ void sendFullTouchEvent(QTouchEvent *event);
+ Resource *focusResource() const { return m_focusResource; }
private:
void focusDestroyed(void *data);
void touch_destroy_resource(Resource *resource) Q_DECL_OVERRIDE;
void touch_release(Resource *resource) Q_DECL_OVERRIDE;
- Compositor *m_compositor;
+ QWaylandInputDevice *m_seat;
QWaylandSurfaceView *m_focus;
Resource *m_focusResource;
- WlListener m_focusDestroyListener;
+ QWaylandDestroyListener m_focusDestroyListener;
- TouchGrabber *m_grab;
+ QWaylandDefaultTouchGrabber m_defaultGrab;
+ QWaylandTouchGrabber *m_grab;
};
-} // namespace QtWayland
-
QT_END_NAMESPACE
#endif // QTWAYLAND_QWLTOUCH_P_H
diff --git a/src/compositor/wayland_wrapper/wayland_wrapper.pri b/src/compositor/wayland_wrapper/wayland_wrapper.pri
index f7a630bd4..2bc732565 100644
--- a/src/compositor/wayland_wrapper/wayland_wrapper.pri
+++ b/src/compositor/wayland_wrapper/wayland_wrapper.pri
@@ -21,7 +21,6 @@ HEADERS += \
wayland_wrapper/qwlsurface_p.h \
wayland_wrapper/qwlsurfacebuffer_p.h \
wayland_wrapper/qwltouch_p.h \
- wayland_wrapper/qwllistener_p.h \
../shared/qwaylandxkb.h \
SOURCES += \
@@ -41,7 +40,6 @@ SOURCES += \
wayland_wrapper/qwlsurface.cpp \
wayland_wrapper/qwlsurfacebuffer.cpp \
wayland_wrapper/qwltouch.cpp \
- wayland_wrapper/qwllistener.cpp \
../shared/qwaylandxkb.cpp \
INCLUDEPATH += wayland_wrapper