/******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2014 Martin Gräßlin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ #ifndef KWIN_WAYLAND_POINTER_H #define KWIN_WAYLAND_POINTER_H #include #include namespace KWin { namespace Wayland { class Pointer : public QObject { Q_OBJECT public: enum class ButtonState { Released, Pressed }; enum class Axis { Vertical, Horizontal }; explicit Pointer(QObject *parent = nullptr); virtual ~Pointer(); bool isValid() const { return m_pointer; } void setup(wl_pointer *pointer); void release(); operator wl_pointer*() { return m_pointer; } operator wl_pointer*() const { return m_pointer; } static void enterCallback(void *data, wl_pointer *pointer, uint32_t serial, wl_surface *surface, wl_fixed_t sx, wl_fixed_t sy); static void leaveCallback(void *data, wl_pointer *pointer, uint32_t serial, wl_surface *surface); static void motionCallback(void *data, wl_pointer *pointer, uint32_t time, wl_fixed_t sx, wl_fixed_t sy); static void buttonCallback(void *data, wl_pointer *pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t state); static void axisCallback(void *data, wl_pointer *pointer, uint32_t time, uint32_t axis, wl_fixed_t value); Q_SIGNALS: void entered(quint32 serial, const QPointF &relativeToSurface); void left(quint32 serial); void motion(const QPointF &relativeToSurface, quint32 time); void buttonStateChanged(quint32 serial, quint32 time, quint32 button, ButtonState state); void axisChanged(quint32 time, Axis axis, qreal delta); private: wl_pointer *m_pointer; static const wl_pointer_listener s_listener; }; } } Q_DECLARE_METATYPE(KWin::Wayland::Pointer::ButtonState) #endif