2020-03-15 15:19:28 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
2021-02-12 22:29:45 +00:00
|
|
|
SPDX-FileCopyrightText: 2020 Adrien Faveraux <ad1rie3@hotmail.fr>
|
|
|
|
SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
2020-03-15 15:19:28 +00:00
|
|
|
|
|
|
|
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
|
|
|
*/
|
2014-11-25 12:52:40 +00:00
|
|
|
#ifndef WAYLAND_SERVER_POINTER_INTERFACE_H
|
|
|
|
#define WAYLAND_SERVER_POINTER_INTERFACE_H
|
|
|
|
|
2020-04-29 14:56:38 +00:00
|
|
|
#include <KWaylandServer/kwaylandserver_export.h>
|
2014-11-25 12:52:40 +00:00
|
|
|
|
2021-02-12 22:29:45 +00:00
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
struct wl_resource;
|
2014-11-25 12:52:40 +00:00
|
|
|
|
2020-04-29 14:56:38 +00:00
|
|
|
namespace KWaylandServer
|
2014-11-25 12:52:40 +00:00
|
|
|
{
|
|
|
|
|
2021-02-12 22:29:45 +00:00
|
|
|
class CursorPrivate;
|
2015-02-27 16:36:43 +00:00
|
|
|
class Cursor;
|
2021-02-12 22:29:45 +00:00
|
|
|
class PointerInterfacePrivate;
|
2014-11-25 12:52:40 +00:00
|
|
|
class SeatInterface;
|
|
|
|
class SurfaceInterface;
|
|
|
|
|
2019-02-11 16:35:23 +00:00
|
|
|
enum class PointerAxisSource;
|
|
|
|
|
2015-09-09 11:49:58 +00:00
|
|
|
/**
|
2021-02-12 22:29:45 +00:00
|
|
|
* The PointerInterface class represents one or more input devices such as mice, which control
|
|
|
|
* the pointer location. It corresponds to the Wayland interface @c wl_pointer.
|
|
|
|
*/
|
|
|
|
class KWAYLANDSERVER_EXPORT PointerInterface : public QObject
|
2014-11-25 12:52:40 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2021-02-12 22:29:45 +00:00
|
|
|
|
2014-11-25 12:52:40 +00:00
|
|
|
public:
|
2021-02-12 22:29:45 +00:00
|
|
|
~PointerInterface() override;
|
2015-09-09 11:49:58 +00:00
|
|
|
|
|
|
|
/**
|
2021-02-12 22:29:45 +00:00
|
|
|
* Returns the focused pointer surface. Note that the returned value may be different
|
|
|
|
* from SurfaceInterface::focusedSurfacePointerSurface() because this function returns
|
|
|
|
* the effective focused surface.
|
|
|
|
*/
|
2014-11-26 10:55:35 +00:00
|
|
|
SurfaceInterface *focusedSurface() const;
|
2015-02-27 16:36:43 +00:00
|
|
|
/**
|
2021-02-12 22:29:45 +00:00
|
|
|
* Sets the effective focused pointer surface to @a surface. The @a position indicates
|
|
|
|
* where the pointer has entered the surface.
|
|
|
|
*/
|
|
|
|
void setFocusedSurface(SurfaceInterface *surface, const QPointF &position, quint32 serial);
|
|
|
|
|
2015-02-27 16:36:43 +00:00
|
|
|
Cursor *cursor() const;
|
|
|
|
|
2021-02-12 22:29:45 +00:00
|
|
|
/**
|
|
|
|
* Returns the seat to which this pointer belongs to.
|
|
|
|
*/
|
|
|
|
SeatInterface *seat() const;
|
|
|
|
|
2016-10-07 07:07:34 +00:00
|
|
|
/**
|
|
|
|
* @returns The PointerInterface for the @p native resource.
|
2021-02-12 22:29:45 +00:00
|
|
|
*/
|
2016-10-07 07:07:34 +00:00
|
|
|
static PointerInterface *get(wl_resource *native);
|
|
|
|
|
2021-02-12 22:29:45 +00:00
|
|
|
void sendPressed(quint32 button, quint32 serial);
|
|
|
|
void sendReleased(quint32 button, quint32 serial);
|
|
|
|
void sendAxis(Qt::Orientation orientation, qreal delta, qint32 discreteDelta, PointerAxisSource source);
|
|
|
|
void sendMotion(const QPointF &position);
|
|
|
|
void sendFrame();
|
|
|
|
|
2015-02-27 16:36:43 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
/**
|
2021-02-12 22:29:45 +00:00
|
|
|
* This signal is emitted whenever the cursor surface changes. As long as there is no
|
|
|
|
* any focused surface, the cursor cannot be changed.
|
|
|
|
*/
|
2015-02-27 16:36:43 +00:00
|
|
|
void cursorChanged();
|
2021-02-12 22:29:45 +00:00
|
|
|
/**
|
|
|
|
* This signal is emitted whenever the focused pointer surface changes.
|
|
|
|
*/
|
|
|
|
void focusedSurfaceChanged();
|
2015-02-27 16:36:43 +00:00
|
|
|
|
2014-11-25 12:52:40 +00:00
|
|
|
private:
|
2021-02-12 22:29:45 +00:00
|
|
|
explicit PointerInterface(SeatInterface *seat);
|
|
|
|
QScopedPointer<PointerInterfacePrivate> d;
|
|
|
|
|
2014-11-25 12:52:40 +00:00
|
|
|
friend class SeatInterface;
|
2021-02-12 22:29:45 +00:00
|
|
|
friend class PointerInterfacePrivate;
|
2014-11-25 12:52:40 +00:00
|
|
|
};
|
|
|
|
|
2015-02-27 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* @brief Class encapsulating a Cursor image.
|
2021-02-12 22:29:45 +00:00
|
|
|
*/
|
2015-02-27 16:36:43 +00:00
|
|
|
class KWAYLANDSERVER_EXPORT Cursor : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2021-02-12 22:29:45 +00:00
|
|
|
|
2015-02-27 16:36:43 +00:00
|
|
|
public:
|
|
|
|
virtual ~Cursor();
|
|
|
|
/**
|
|
|
|
* The hotspot of the cursor image in surface-relative coordinates.
|
2021-02-12 22:29:45 +00:00
|
|
|
*/
|
2015-02-27 16:36:43 +00:00
|
|
|
QPoint hotspot() const;
|
|
|
|
/**
|
|
|
|
* The entered serial when the Cursor got set.
|
2021-02-12 22:29:45 +00:00
|
|
|
*/
|
2015-02-27 16:36:43 +00:00
|
|
|
quint32 enteredSerial() const;
|
|
|
|
/**
|
|
|
|
* The PointerInterface this Cursor belongs to.
|
2021-02-12 22:29:45 +00:00
|
|
|
*/
|
2015-02-27 16:36:43 +00:00
|
|
|
PointerInterface *pointer() const;
|
|
|
|
/**
|
|
|
|
* The SurfaceInterface for the image content of the Cursor.
|
2021-02-12 22:29:45 +00:00
|
|
|
*/
|
|
|
|
SurfaceInterface *surface() const;
|
2015-02-27 16:36:43 +00:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void hotspotChanged();
|
|
|
|
void enteredSerialChanged();
|
|
|
|
void surfaceChanged();
|
|
|
|
void changed();
|
|
|
|
|
|
|
|
private:
|
2021-02-12 22:29:45 +00:00
|
|
|
QScopedPointer<CursorPrivate> d;
|
|
|
|
friend class PointerInterfacePrivate;
|
|
|
|
explicit Cursor(PointerInterface *parent);
|
2015-02-27 16:36:43 +00:00
|
|
|
};
|
|
|
|
|
2014-11-25 12:52:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|