diff options
author | Jørgen Lind <jorgen.lind@theqtcompany.com> | 2015-08-14 15:18:20 +0200 |
---|---|---|
committer | Jørgen Lind <jorgen.lind@theqtcompany.com> | 2015-08-28 13:10:33 +0200 |
commit | eae177e743d1f538e530b969363c236ae1326ed8 (patch) | |
tree | da380d4555148b5a98e3fedacc157326cc491422 /src/compositor/wayland_wrapper | |
parent | 463b9137b1b78def03fca6fc987df9bf249cb2f6 (diff) |
Move QWaylandPointerPrivate into a _p file and remove the api
and make sure all other classes uses the public QWaylandPointer type
Change-Id: Ie7ff24160c253ff700eb27eb46788fe021386dd7
Diffstat (limited to 'src/compositor/wayland_wrapper')
-rw-r--r-- | src/compositor/wayland_wrapper/qwldatadevice.cpp | 2 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/qwldatadevice_p.h | 2 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/qwlpointer.cpp | 217 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/qwlpointer_p.h | 137 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/wayland_wrapper.pri | 2 |
5 files changed, 2 insertions, 358 deletions
diff --git a/src/compositor/wayland_wrapper/qwldatadevice.cpp b/src/compositor/wayland_wrapper/qwldatadevice.cpp index 83d0b9dd3..7a375b628 100644 --- a/src/compositor/wayland_wrapper/qwldatadevice.cpp +++ b/src/compositor/wayland_wrapper/qwldatadevice.cpp @@ -39,7 +39,6 @@ #include "qwldatasource_p.h" #include "qwldataoffer_p.h" #include "qwlkeyboard_p.h" -#include "qwlpointer_p.h" #include "qwaylandsurface_p.h" #include "qwltouch_p.h" #include "qwldatadevicemanager_p.h" @@ -49,6 +48,7 @@ #include <QtCompositor/QWaylandClient> #include <QtCompositor/private/qwaylandcompositor_p.h> #include <QtCompositor/private/qwaylandinput_p.h> +#include <QtCompositor/private/qwaylandpointer_p.h> #include <QtCore/QPointF> #include <QDebug> diff --git a/src/compositor/wayland_wrapper/qwldatadevice_p.h b/src/compositor/wayland_wrapper/qwldatadevice_p.h index 6d4f4f1b5..dc8c3be20 100644 --- a/src/compositor/wayland_wrapper/qwldatadevice_p.h +++ b/src/compositor/wayland_wrapper/qwldatadevice_p.h @@ -39,7 +39,7 @@ #include <QtCompositor/private/qwayland-server-wayland.h> #include <QtCompositor/QWaylandPointerGrabber> -#include <qwlpointer_p.h> +#include <QtCompositor/QWaylandInputDevice> #include <QtCompositor/QWaylandOutputSpace> QT_BEGIN_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwlpointer.cpp b/src/compositor/wayland_wrapper/qwlpointer.cpp deleted file mode 100644 index 5f5068f5c..000000000 --- a/src/compositor/wayland_wrapper/qwlpointer.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB). -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwlpointer_p.h" - -#include "qwlkeyboard_p.h" -#include "qwaylandcompositor.h" -#include "qwaylandview.h" - -QT_BEGIN_NAMESPACE - -QWaylandPointerPrivate::QWaylandPointerPrivate(QWaylandPointer *pointer, QWaylandInputDevice *seat) - : QObjectPrivate() - , wl_pointer() - , m_seat(seat) - , m_output() - , m_defaultGrab(pointer) - , m_grab(&m_defaultGrab) - , m_grabButton() - , m_grabTime() - , m_grabSerial() - , m_focusResource() - , m_hasSentEnter(false) - , m_buttonCount() -{ -} - -void QWaylandPointerPrivate::startGrab(QWaylandPointerGrabber *grab) -{ - Q_Q(QWaylandPointer); - m_grab = grab; - grab->pointer = q; - - if (mouseFocus()) - grab->focus(); -} - -void QWaylandPointerPrivate::endGrab() -{ - m_grab = &m_defaultGrab; - m_grab->focus(); -} - -bool QWaylandPointerPrivate::buttonPressed() const -{ - return m_buttonCount > 0; -} - -QWaylandPointerGrabber *QWaylandPointerPrivate::currentGrab() const -{ - return m_grab; -} - -Qt::MouseButton QWaylandPointerPrivate::grabButton() const -{ - return m_grabButton; -} - -uint32_t QWaylandPointerPrivate::grabTime() const -{ - return m_grabTime; -} - -uint32_t QWaylandPointerPrivate::grabSerial() const -{ - return m_grabSerial; -} - -void QWaylandPointerPrivate::pointer_destroy_resource(wl_pointer::Resource *resource) -{ - if (m_focusResource == resource) - m_focusResource = 0; -} - -void QWaylandPointerPrivate::pointer_release(wl_pointer::Resource *resource) -{ - wl_resource_destroy(resource->handle); -} - -void QWaylandPointerPrivate::sendMousePressEvent(Qt::MouseButton button) -{ - Q_Q(QWaylandPointer); - uint32_t time = compositor()->currentTimeMsecs(); - if (m_buttonCount == 0) { - m_grabButton = button; - m_grabTime = time; - } - m_buttonCount++; - m_grab->button(time, button, WL_POINTER_BUTTON_STATE_PRESSED); - - if (m_buttonCount == 1) { - m_grabSerial = compositor()->nextSerial(); - q->buttonPressedChanged(); - } -} - -void QWaylandPointerPrivate::sendMouseReleaseEvent(Qt::MouseButton button) -{ - 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 = compositor()->nextSerial(); - if (m_buttonCount == 0) - q->buttonPressedChanged(); -} - -void QWaylandPointerPrivate::sendMouseMoveEvent(QWaylandView *view, const QPointF &localPos, const QPointF &outputSpacePos) -{ - Q_Q(QWaylandPointer); - if (view && (!view->surface() || view->surface()->isCursorSurface())) - view = Q_NULLPTR; - m_seat->setMouseFocus(view); - m_localPosition = localPos; - m_spacePosition = outputSpacePos; - - //we adjust if the mouse position is on the edge - //to work around Qt's event propogation - if (view && view->surface()) { - QSizeF size(view->surface()->size()); - if (m_localPosition.x() == size.width()) - m_localPosition.rx() -= 0.01; - - if (m_localPosition.y() == size.height()) - m_localPosition.ry() -= 0.01; - } - - Resource *resource = view ? resourceMap().value(view->surface()->waylandClient()) : 0; - if (resource && !m_hasSentEnter) { - uint32_t serial = compositor()->nextSerial(); - QWaylandKeyboard *keyboard = m_seat->keyboard(); - if (keyboard) { - keyboard->sendKeyModifiers(view->surface()->client(), serial); - } - send_enter(resource->handle, serial, view->surface()->resource(), - wl_fixed_from_double(m_localPosition.x()), wl_fixed_from_double(m_localPosition.y())); - - m_focusDestroyListener.listenForDestruction(view->surface()->resource()); - m_hasSentEnter = true; - } - - m_focusResource = resource; - - if (view && view->output()) - q->setOutput(view->output()); - - m_grab->motion(compositor()->currentTimeMsecs()); -} - -void QWaylandPointerPrivate::sendMouseWheelEvent(Qt::Orientation orientation, int delta) -{ - if (!m_focusResource) - return; - - 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)); -} - -static void requestCursorSurface(QWaylandCompositor *compositor, QWaylandSurface *surface, int32_t hotspot_x, int hotspot_y) -{ - compositor->currentCurserSurfaceRequest(surface, hotspot_x, 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(compositor(), Q_NULLPTR, 0, 0); - return; - } - - QWaylandSurface *s = QWaylandSurface::fromResource(surface); - s->markAsCursorSurface(true); - requestCursorSurface(compositor(), s, hotspot_x, hotspot_y); -} - -QT_END_NAMESPACE diff --git a/src/compositor/wayland_wrapper/qwlpointer_p.h b/src/compositor/wayland_wrapper/qwlpointer_p.h deleted file mode 100644 index 1feeb1933..000000000 --- a/src/compositor/wayland_wrapper/qwlpointer_p.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2013 Klarälvdalens Datakonsult AB (KDAB). -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWaylandCompositor module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTWAYLAND_QWLPOINTER_P_H -#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/QWaylandView> -#include <QtCompositor/QWaylandSurface> -#include <QtCompositor/QWaylandInputDevice> - -#include <stdint.h> - -QT_BEGIN_NAMESPACE - -class QWaylandView; - -namespace QtWayland { - -class Compositor; -class Surface; - -} // namespace QtWayland - -class Q_COMPOSITOR_EXPORT QWaylandPointerPrivate : public QObjectPrivate - , public QtWaylandServer::wl_pointer -{ - Q_DECLARE_PUBLIC(QWaylandPointer) -public: - 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 startGrab(QWaylandPointerGrabber *currentGrab); - void endGrab(); - QWaylandPointerGrabber *currentGrab() const; - Qt::MouseButton grabButton() const; - uint32_t grabTime() const; - uint32_t grabSerial() const; - - void sendMousePressEvent(Qt::MouseButton button); - void sendMouseReleaseEvent(Qt::MouseButton button); - void sendMouseMoveEvent(QWaylandView *view, const QPointF &localPos, const QPointF &outputSpacePos); - void sendMouseWheelEvent(Qt::Orientation orientation, int delta); - - Resource *focusResource() const { return m_focusResource; } - QWaylandView *mouseFocus() const { return m_seat->mouseFocus(); } - - bool buttonPressed() const; - - QWaylandInputDevice *seat() const { return m_seat; } - QWaylandCompositor *compositor() const { return m_seat->compositor(); } - - QPointF currentSpacePosition() const { return m_spacePosition; } - QPointF currentLocalPosition() const { return m_localPosition; } -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; - void pointer_destroy_resource(Resource *resource) Q_DECL_OVERRIDE; - -private: - void focusDestroyed(void *data); - - QWaylandInputDevice *m_seat; - QWaylandOutput *m_output; - QWaylandDefaultPointerGrabber m_defaultGrab; - - QPointF m_localPosition; - QPointF m_spacePosition; - - QWaylandPointerGrabber *m_grab; - Qt::MouseButton m_grabButton; - uint32_t m_grabTime; - uint32_t m_grabSerial; - - Resource *m_focusResource; - bool m_hasSentEnter; - - int m_buttonCount; - - QWaylandDestroyListener m_focusDestroyListener; -}; - -QT_END_NAMESPACE - -#endif // QTWAYLAND_QWLPOINTER_P_H diff --git a/src/compositor/wayland_wrapper/wayland_wrapper.pri b/src/compositor/wayland_wrapper/wayland_wrapper.pri index 96d05116e..3ffc7148e 100644 --- a/src/compositor/wayland_wrapper/wayland_wrapper.pri +++ b/src/compositor/wayland_wrapper/wayland_wrapper.pri @@ -12,7 +12,6 @@ HEADERS += \ wayland_wrapper/qwlinputmethod_p.h \ wayland_wrapper/qwlinputmethodcontext_p.h \ wayland_wrapper/qwlkeyboard_p.h \ - wayland_wrapper/qwlpointer_p.h \ wayland_wrapper/qwlregion_p.h \ wayland_wrapper/qwlsurfacebuffer_p.h \ wayland_wrapper/qwltouch_p.h \ @@ -26,7 +25,6 @@ SOURCES += \ wayland_wrapper/qwlinputmethod.cpp \ wayland_wrapper/qwlinputmethodcontext.cpp \ wayland_wrapper/qwlkeyboard.cpp \ - wayland_wrapper/qwlpointer.cpp \ wayland_wrapper/qwlregion.cpp \ wayland_wrapper/qwlsurfacebuffer.cpp \ wayland_wrapper/qwltouch.cpp \ |