2014-09-02 07:34:31 +00:00
|
|
|
/********************************************************************
|
2014-09-17 13:57:56 +00:00
|
|
|
Copyright 2014 Martin Gräßlin <mgraesslin@kde.org>
|
2014-09-02 07:34:31 +00:00
|
|
|
|
2014-09-17 13:57:56 +00:00
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) version 3, or any
|
|
|
|
later version accepted by the membership of KDE e.V. (or its
|
|
|
|
successor approved by the membership of KDE e.V.), which shall
|
|
|
|
act as a proxy defined in Section 6 of version 3 of the license.
|
2014-09-02 07:34:31 +00:00
|
|
|
|
2014-09-17 13:57:56 +00:00
|
|
|
This library is distributed in the hope that it will be useful,
|
2014-09-02 07:34:31 +00:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2014-09-17 13:57:56 +00:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
2014-09-02 07:34:31 +00:00
|
|
|
|
2014-09-17 13:57:56 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2014-09-02 07:34:31 +00:00
|
|
|
*********************************************************************/
|
2014-09-17 14:20:56 +00:00
|
|
|
#ifndef WAYLAND_SERVER_SEAT_INTERFACE_H
|
|
|
|
#define WAYLAND_SERVER_SEAT_INTERFACE_H
|
2014-09-02 07:34:31 +00:00
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QPoint>
|
|
|
|
|
2014-10-14 11:43:24 +00:00
|
|
|
#include <KWayland/Server/kwaylandserver_export.h>
|
2014-11-13 14:07:31 +00:00
|
|
|
#include "global.h"
|
2014-11-26 14:00:44 +00:00
|
|
|
#include "keyboard_interface.h"
|
2014-11-26 09:34:23 +00:00
|
|
|
#include "pointer_interface.h"
|
2015-03-25 12:31:38 +00:00
|
|
|
#include "touch_interface.h"
|
2014-09-17 13:10:43 +00:00
|
|
|
|
2014-09-18 15:14:50 +00:00
|
|
|
struct wl_client;
|
|
|
|
struct wl_resource;
|
|
|
|
|
2014-09-17 14:10:38 +00:00
|
|
|
namespace KWayland
|
2014-09-02 07:34:31 +00:00
|
|
|
{
|
2014-09-17 14:10:38 +00:00
|
|
|
namespace Server
|
2014-09-02 07:34:31 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
class Display;
|
|
|
|
class SurfaceInterface;
|
|
|
|
|
2015-09-09 15:31:13 +00:00
|
|
|
/**
|
|
|
|
* @brief Represents a Seat on the Wayland Display.
|
|
|
|
*
|
|
|
|
* A Seat is a set of input devices (e.g. Keyboard, Pointer and Touch) the client can connect
|
|
|
|
* to. The server needs to announce which input devices are supported and passes dedicated input
|
|
|
|
* focus to a SurfaceInterface. Only the focused surface receives input events.
|
|
|
|
*
|
|
|
|
* The SeatInterface internally handles enter and release events when setting a focused surface.
|
|
|
|
* Also it handles input translation from global to the local coordination, removing the need from
|
|
|
|
* the user of the API to track the focused surfaces and can just interact with this class.
|
|
|
|
*
|
|
|
|
* To create a SeatInterface use @link Display::createSeat @endlink. Then one can set up what is
|
|
|
|
* supported. Last but not least create needs to be called.
|
|
|
|
*
|
|
|
|
* @code
|
|
|
|
* SeatInterface *seat = display->createSeat();
|
|
|
|
* // set up
|
|
|
|
* seat->setName(QStringLiteral("seat0"));
|
|
|
|
* seat->setHasPointer(true);
|
|
|
|
* seat->setHasKeyboard(true);
|
|
|
|
* seat->setHasTouch(false);
|
|
|
|
* // now fully create
|
|
|
|
* seat->create();
|
|
|
|
* @endcode
|
|
|
|
*
|
|
|
|
* To forward input events one needs to set the focused surface, update time stamp and then
|
|
|
|
* forward the actual events:
|
|
|
|
*
|
|
|
|
* @code
|
|
|
|
* // example for pointer
|
|
|
|
* seat->setFocusedPointerSurface(surface, QPointF(100, 200)); // surface at it's global position
|
|
|
|
* seat->setTimestamp(100);
|
|
|
|
* seat->setPointerPos(QPointF(350, 210)); // global pos, local pos in surface: 250,10
|
|
|
|
* seat->setTimestamp(110);
|
|
|
|
* seat->pointerButtonPressed(Qt::LeftButton);
|
|
|
|
* seat->setTimestamp(120);
|
|
|
|
* seat->pointerButtonReleased(Qt::LeftButton);
|
|
|
|
* @endcode
|
|
|
|
*
|
|
|
|
* @see KeyboardInterface
|
|
|
|
* @see PointerInterface
|
|
|
|
* @see TouchInterface
|
|
|
|
* @see SurfaceInterface
|
|
|
|
**/
|
2014-11-13 14:07:31 +00:00
|
|
|
class KWAYLANDSERVER_EXPORT SeatInterface : public Global
|
2014-09-02 07:34:31 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2015-09-09 15:31:13 +00:00
|
|
|
/**
|
|
|
|
* The name of the Seat
|
|
|
|
**/
|
2014-09-02 07:34:31 +00:00
|
|
|
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
2015-09-09 15:31:13 +00:00
|
|
|
/**
|
|
|
|
* Whether the SeatInterface supports a pointer device.
|
|
|
|
**/
|
2014-09-02 07:34:31 +00:00
|
|
|
Q_PROPERTY(bool pointer READ hasPointer WRITE setHasPointer NOTIFY hasPointerChanged)
|
2015-09-09 15:31:13 +00:00
|
|
|
/**
|
|
|
|
* Whether the SeatInterface supports a keyboard device.
|
|
|
|
**/
|
2014-09-02 07:34:31 +00:00
|
|
|
Q_PROPERTY(bool keyboard READ hasKeyboard WRITE setHasKeyboard NOTIFY hasKeyboardChanged)
|
2015-09-09 15:31:13 +00:00
|
|
|
/**
|
|
|
|
* Whether the SeatInterface supports a touch device.
|
|
|
|
* @deprecated use touch
|
|
|
|
**/
|
2014-09-02 07:34:31 +00:00
|
|
|
Q_PROPERTY(bool tourch READ hasTouch WRITE setHasTouch NOTIFY hasTouchChanged)
|
2015-09-09 15:31:13 +00:00
|
|
|
/**
|
|
|
|
* Whether the SeatInterface supports a touch device.
|
|
|
|
**/
|
|
|
|
Q_PROPERTY(bool touch READ hasTouch WRITE setHasTouch NOTIFY hasTouchChanged)
|
|
|
|
/**
|
|
|
|
* The global pointer position.
|
|
|
|
**/
|
2014-11-25 13:24:52 +00:00
|
|
|
Q_PROPERTY(QPointF pointerPos READ pointerPos WRITE setPointerPos NOTIFY pointerPosChanged)
|
2015-09-09 15:31:13 +00:00
|
|
|
/**
|
|
|
|
* The current timestamp passed to the input events.
|
|
|
|
**/
|
2014-11-25 14:29:01 +00:00
|
|
|
Q_PROPERTY(quint32 timestamp READ timestamp WRITE setTimestamp NOTIFY timestampChanged)
|
2014-09-02 07:34:31 +00:00
|
|
|
public:
|
|
|
|
virtual ~SeatInterface();
|
|
|
|
|
2014-09-18 14:35:28 +00:00
|
|
|
QString name() const;
|
|
|
|
bool hasPointer() const;
|
|
|
|
bool hasKeyboard() const;
|
|
|
|
bool hasTouch() const;
|
2014-09-02 07:34:31 +00:00
|
|
|
|
|
|
|
void setName(const QString &name);
|
|
|
|
void setHasPointer(bool has);
|
|
|
|
void setHasKeyboard(bool has);
|
|
|
|
void setHasTouch(bool has);
|
|
|
|
|
2014-11-25 14:29:01 +00:00
|
|
|
void setTimestamp(quint32 time);
|
|
|
|
quint32 timestamp() const;
|
|
|
|
|
2015-09-09 15:31:13 +00:00
|
|
|
/**
|
|
|
|
* @name Pointer related methods
|
|
|
|
**/
|
|
|
|
///@{
|
|
|
|
/**
|
|
|
|
* Updates the global pointer @p pos.
|
|
|
|
*
|
|
|
|
* Sends a pointer motion event to the focused pointer surface.
|
|
|
|
**/
|
2014-11-25 13:24:52 +00:00
|
|
|
void setPointerPos(const QPointF &pos);
|
2015-09-09 15:31:13 +00:00
|
|
|
/**
|
|
|
|
* @returns the global pointer position
|
|
|
|
**/
|
2014-11-25 13:24:52 +00:00
|
|
|
QPointF pointerPos() const;
|
2015-09-09 15:31:13 +00:00
|
|
|
/**
|
|
|
|
* Sets the focused pointer @p surface.
|
|
|
|
* All pointer events will be sent to the @p surface till a new focused pointer surface gets
|
|
|
|
* installed. When the focus pointer surface changes a leave event is sent to the previous
|
|
|
|
* focused surface.
|
|
|
|
*
|
|
|
|
* To unset the focused pointer surface pass @c nullptr as @p surface.
|
|
|
|
*
|
|
|
|
* Pointer motion events are adjusted to the local position based on the @p surfacePosition.
|
|
|
|
* If the surface changes it's position in the global coordinate system
|
|
|
|
* use setFocusedPointerSurfacePosition to update.
|
|
|
|
*
|
|
|
|
* @param surface The surface which should become the new focused pointer surface.
|
|
|
|
* @param surfacePosition The position of the surface in the global coordinate system
|
|
|
|
*
|
|
|
|
* @see setPointerPos
|
|
|
|
* @see focucedPointerSurface
|
|
|
|
* @see focusedPointer
|
|
|
|
* @see setFocusedPointerSurfacePosition
|
|
|
|
* @see focusedPointerSurfacePosition
|
|
|
|
**/
|
2014-11-26 09:34:23 +00:00
|
|
|
void setFocusedPointerSurface(SurfaceInterface *surface, const QPointF &surfacePosition = QPoint());
|
2015-09-09 15:31:13 +00:00
|
|
|
/**
|
|
|
|
* @returns The currently focused pointer surface, that is the surface receiving pointer events.
|
|
|
|
* @see setFocusedPointerSurface
|
|
|
|
**/
|
2014-11-25 14:54:28 +00:00
|
|
|
SurfaceInterface *focusedPointerSurface() const;
|
2015-09-09 15:31:13 +00:00
|
|
|
/**
|
|
|
|
* @returns The PointerInterface belonging to the focused pointer surface, if any.
|
|
|
|
* @see setFocusedPointerSurface
|
|
|
|
**/
|
2014-11-25 15:04:07 +00:00
|
|
|
PointerInterface *focusedPointer() const;
|
2015-09-09 15:31:13 +00:00
|
|
|
/**
|
|
|
|
* Updates the global position of the currently focused pointer surface
|
|
|
|
*
|
|
|
|
* @param surfacePosition The new global position of the focused pointer surface
|
|
|
|
* @see focusedPointerSurface
|
|
|
|
* @see setFocusedPointerSurface
|
|
|
|
**/
|
2014-11-26 09:34:23 +00:00
|
|
|
void setFocusedPointerSurfacePosition(const QPointF &surfacePosition);
|
2015-09-09 15:31:13 +00:00
|
|
|
/**
|
|
|
|
* @returns The position of the focused pointer surface in global coordinates.
|
|
|
|
* @see setFocusedPointerSurfacePosition
|
|
|
|
* @see setFocusedPointerSurface
|
|
|
|
**/
|
2014-11-26 09:34:23 +00:00
|
|
|
QPointF focusedPointerSurfacePosition() const;
|
2015-09-09 15:31:13 +00:00
|
|
|
/**
|
|
|
|
* Marks the @p button as pressed.
|
|
|
|
*
|
|
|
|
* If there is a focused pointer surface a button pressed event is sent to it.
|
|
|
|
*
|
|
|
|
* @param button The Linux button code
|
|
|
|
**/
|
2014-11-26 10:50:52 +00:00
|
|
|
void pointerButtonPressed(quint32 button);
|
2015-09-09 15:31:13 +00:00
|
|
|
/**
|
|
|
|
* @overload
|
|
|
|
**/
|
2014-11-26 10:50:52 +00:00
|
|
|
void pointerButtonPressed(Qt::MouseButton button);
|
2015-09-09 15:31:13 +00:00
|
|
|
/**
|
|
|
|
* Marks the @p button as released.
|
|
|
|
*
|
|
|
|
* If there is a focused pointer surface a button release event is sent to it.
|
|
|
|
*
|
|
|
|
* @param button The Linux button code
|
|
|
|
**/
|
2014-11-26 10:50:52 +00:00
|
|
|
void pointerButtonReleased(quint32 button);
|
2015-09-09 15:31:13 +00:00
|
|
|
/**
|
|
|
|
* @overload
|
|
|
|
**/
|
2014-11-26 10:50:52 +00:00
|
|
|
void pointerButtonReleased(Qt::MouseButton button);
|
2015-09-09 15:31:13 +00:00
|
|
|
/**
|
|
|
|
* @returns whether the @p button is pressed
|
|
|
|
**/
|
2014-11-26 10:50:52 +00:00
|
|
|
bool isPointerButtonPressed(quint32 button) const;
|
2015-09-09 15:31:13 +00:00
|
|
|
/**
|
|
|
|
* @returns whether the @p button is pressed
|
|
|
|
**/
|
2014-11-26 10:50:52 +00:00
|
|
|
bool isPointerButtonPressed(Qt::MouseButton button) const;
|
2015-09-09 15:31:13 +00:00
|
|
|
/**
|
|
|
|
* @returns the last serial for @p button.
|
|
|
|
**/
|
2014-11-26 10:50:52 +00:00
|
|
|
quint32 pointerButtonSerial(quint32 button) const;
|
2015-09-09 15:31:13 +00:00
|
|
|
/**
|
|
|
|
* @returns the last serial for @p button.
|
|
|
|
**/
|
2014-11-26 10:50:52 +00:00
|
|
|
quint32 pointerButtonSerial(Qt::MouseButton button) const;
|
|
|
|
void pointerAxis(Qt::Orientation orientation, quint32 delta);
|
2015-09-09 15:31:13 +00:00
|
|
|
///@}
|
2014-11-25 13:24:52 +00:00
|
|
|
|
2015-09-09 15:31:13 +00:00
|
|
|
/**
|
|
|
|
* @name keyboard related methods
|
|
|
|
**/
|
|
|
|
///@{
|
2014-11-26 14:00:44 +00:00
|
|
|
void setKeymap(int fd, quint32 size);
|
|
|
|
void keyPressed(quint32 key);
|
|
|
|
void keyReleased(quint32 key);
|
|
|
|
void updateKeyboardModifiers(quint32 depressed, quint32 latched, quint32 locked, quint32 group);
|
2015-09-02 14:00:11 +00:00
|
|
|
/**
|
|
|
|
* Sets the key repeat information to be forwarded to all bound keyboards.
|
|
|
|
*
|
|
|
|
* To disable key repeat set a @p charactersPerSecond of @c 0.
|
|
|
|
*
|
|
|
|
* Requires wl_seat version 4.
|
|
|
|
*
|
|
|
|
* @param charactersPerSecond The characters per second rate, value of @c 0 disables key repeating
|
|
|
|
* @param delay The delay on key press before starting repeating keys
|
|
|
|
*
|
|
|
|
* @since 5.5
|
|
|
|
***/
|
|
|
|
void setKeyRepeatInfo(qint32 charactersPerSecond, qint32 delay);
|
2014-11-26 14:00:44 +00:00
|
|
|
quint32 depressedModifiers() const;
|
|
|
|
quint32 latchedModifiers() const;
|
|
|
|
quint32 lockedModifiers() const;
|
|
|
|
quint32 groupModifiers() const;
|
|
|
|
quint32 lastModifiersSerial() const;
|
|
|
|
int keymapFileDescriptor() const;
|
|
|
|
quint32 keymapSize() const;
|
|
|
|
bool isKeymapXkbCompatible() const;
|
|
|
|
QVector<quint32> pressedKeys() const;
|
2015-09-02 14:00:11 +00:00
|
|
|
/**
|
|
|
|
* @returns The key repeat in character per second
|
|
|
|
* @since 5.5
|
|
|
|
* @see setKeyRepeatInfo
|
|
|
|
* @see keyRepeatDelay
|
|
|
|
**/
|
|
|
|
qint32 keyRepeatRate() const;
|
|
|
|
/**
|
|
|
|
* @returns The delay on key press before starting repeating keys
|
|
|
|
* @since 5.5
|
|
|
|
* @see keyRepeatRate
|
|
|
|
* @see setKeyRepeatInfo
|
|
|
|
**/
|
|
|
|
qint32 keyRepeatDelay() const;
|
2014-11-26 14:00:44 +00:00
|
|
|
|
|
|
|
void setFocusedKeyboardSurface(SurfaceInterface *surface);
|
|
|
|
SurfaceInterface *focusedKeyboardSurface() const;
|
|
|
|
KeyboardInterface *focusedKeyboard() const;
|
2015-09-09 15:31:13 +00:00
|
|
|
///@}
|
2014-11-26 14:00:44 +00:00
|
|
|
|
2015-09-09 15:31:13 +00:00
|
|
|
/**
|
|
|
|
* @name touch related methods
|
|
|
|
**/
|
|
|
|
///@{
|
2015-03-25 12:31:38 +00:00
|
|
|
void setFocusedTouchSurface(SurfaceInterface *surface, const QPointF &surfacePosition = QPointF());
|
|
|
|
SurfaceInterface *focusedTouchSurface() const;
|
|
|
|
TouchInterface *focusedTouch() const;
|
|
|
|
void setFocusedTouchSurfacePosition(const QPointF &surfacePosition);
|
|
|
|
QPointF focusedTouchSurfacePosition() const;
|
|
|
|
qint32 touchDown(const QPointF &globalPosition);
|
|
|
|
void touchUp(qint32 id);
|
|
|
|
void touchMove(qint32 id, const QPointF &globalPosition);
|
|
|
|
void touchFrame();
|
|
|
|
void cancelTouchSequence();
|
|
|
|
bool isTouchSequence() const;
|
2015-09-09 15:31:13 +00:00
|
|
|
///@}
|
2015-03-25 12:31:38 +00:00
|
|
|
|
2014-11-05 14:29:18 +00:00
|
|
|
static SeatInterface *get(wl_resource *native);
|
|
|
|
|
2014-09-02 07:34:31 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
void nameChanged(const QString&);
|
|
|
|
void hasPointerChanged(bool);
|
|
|
|
void hasKeyboardChanged(bool);
|
|
|
|
void hasTouchChanged(bool);
|
2014-11-25 13:24:52 +00:00
|
|
|
void pointerPosChanged(const QPointF &pos);
|
2014-11-25 14:29:01 +00:00
|
|
|
void timestampChanged(quint32);
|
2014-09-02 07:34:31 +00:00
|
|
|
|
2014-11-26 09:34:23 +00:00
|
|
|
void pointerCreated(KWayland::Server::PointerInterface*);
|
2014-11-26 14:00:44 +00:00
|
|
|
void keyboardCreated(KWayland::Server::KeyboardInterface*);
|
2015-03-25 12:31:38 +00:00
|
|
|
void touchCreated(KWayland::Server::TouchInterface*);
|
2014-11-26 09:34:23 +00:00
|
|
|
|
2014-09-02 07:34:31 +00:00
|
|
|
private:
|
|
|
|
friend class Display;
|
2014-11-27 12:38:24 +00:00
|
|
|
friend class DataDeviceManagerInterface;
|
2014-09-02 07:34:31 +00:00
|
|
|
explicit SeatInterface(Display *display, QObject *parent);
|
|
|
|
|
2014-09-18 14:35:28 +00:00
|
|
|
class Private;
|
2014-11-13 14:07:31 +00:00
|
|
|
Private *d_func() const;
|
2014-09-02 07:34:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|