File indexing completed on 2024-12-08 10:55:53

0001 /*
0002     SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
0003     SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006 */
0007 #pragma once
0008 
0009 #include "kwin_export.h"
0010 
0011 #include <QMatrix4x4>
0012 #include <QObject>
0013 #include <QPoint>
0014 
0015 struct wl_client;
0016 struct wl_resource;
0017 
0018 namespace KWaylandServer
0019 {
0020 class AbstractDataSource;
0021 class AbstractDropHandler;
0022 class DragAndDropIcon;
0023 class DataDeviceInterface;
0024 class Display;
0025 class KeyboardInterface;
0026 class PointerInterface;
0027 class SeatInterfacePrivate;
0028 class SurfaceInterface;
0029 class TextInputV1Interface;
0030 class TextInputV2Interface;
0031 class TextInputV3Interface;
0032 class TouchInterface;
0033 
0034 /**
0035  * Describes the source types for axis events. This indicates to the
0036  * client how an axis event was physically generated; a client may
0037  * adjust the user interface accordingly. For example, scroll events
0038  * from a "finger" source may be in a smooth coordinate space with
0039  * kinetic scrolling whereas a "wheel" source may be in discrete steps
0040  * of a number of lines.
0041  *
0042  * The "continuous" axis source is a device generating events in a
0043  * continuous coordinate space, but using something other than a
0044  * finger. One example for this source is button-based scrolling where
0045  * the vertical motion of a device is converted to scroll events while
0046  * a button is held down.
0047  *
0048  * The "wheel tilt" axis source indicates that the actual device is a
0049  * wheel but the scroll event is not caused by a rotation but a
0050  * (usually sideways) tilt of the wheel.
0051  */
0052 enum class PointerAxisSource {
0053     Unknown,
0054     Wheel,
0055     Finger,
0056     Continuous,
0057     WheelTilt,
0058 };
0059 
0060 /**
0061  * This enum type is used to describe the state of a pointer button. It
0062  * is equivalent to the @c wl_pointer.button_state enum.
0063  */
0064 enum class PointerButtonState : quint32 {
0065     Released = 0,
0066     Pressed = 1,
0067 };
0068 
0069 /**
0070  * This enum type is used to describe the state of a keyboard key. It is
0071  * equivalent to the @c wl_keyboard.key_state enum.
0072  */
0073 enum class KeyboardKeyState : quint32 {
0074     Released = 0,
0075     Pressed = 1,
0076 };
0077 
0078 /**
0079  * @brief Represents a Seat on the Wayland Display.
0080  *
0081  * A Seat is a set of input devices (e.g. Keyboard, Pointer and Touch) the client can connect
0082  * to. The server needs to announce which input devices are supported and passes dedicated input
0083  * focus to a SurfaceInterface. Only the focused surface receives input events.
0084  *
0085  * The SeatInterface internally handles enter and release events when setting a focused surface.
0086  * Also it handles input translation from global to the local coordination, removing the need from
0087  * the user of the API to track the focused surfaces and can just interact with this class.
0088  *
0089  * To create a SeatInterface use @link Display::createSeat @endlink. Then one can set up what is
0090  * supported. Last but not least create needs to be called.
0091  *
0092  * @code
0093  * SeatInterface *seat = display->createSeat();
0094  * // set up
0095  * seat->setName(QStringLiteral("seat0"));
0096  * seat->setHasPointer(true);
0097  * seat->setHasKeyboard(true);
0098  * seat->setHasTouch(false);
0099  * // now fully create
0100  * seat->create();
0101  * @endcode
0102  *
0103  * To forward input events one needs to set the focused surface, update time stamp and then
0104  * forward the actual events:
0105  *
0106  * @code
0107  * // example for pointer
0108  * seat->setTimestamp(100);
0109  * seat->notifyPointerEnter(surface, QPointF(350, 210), QPointF(100, 200)); // surface at it's global position
0110  * seat->notifyPointerFrame();
0111  * seat->setTimestamp(110);
0112  * seat->notifyPointerButton(Qt::LeftButton, PointerButtonState::Pressed);
0113  * seat->notifyPointerFrame();
0114  * seat->setTimestamp(120);
0115  * seat->notifyPointerButton(Qt::LeftButton, PointerButtonState::Released);
0116  * seat->notifyPointerFrame();
0117  * @endcode
0118  *
0119  * @see KeyboardInterface
0120  * @see PointerInterface
0121  * @see TouchInterface
0122  * @see SurfaceInterface
0123  */
0124 class KWIN_EXPORT SeatInterface : public QObject
0125 {
0126     Q_OBJECT
0127 public:
0128     explicit SeatInterface(Display *display, QObject *parent = nullptr);
0129     virtual ~SeatInterface();
0130 
0131     Display *display() const;
0132     QString name() const;
0133     bool hasPointer() const;
0134     bool hasKeyboard() const;
0135     bool hasTouch() const;
0136 
0137     void setName(const QString &name);
0138     void setHasPointer(bool has);
0139     void setHasKeyboard(bool has);
0140     void setHasTouch(bool has);
0141 
0142     void setTimestamp(std::chrono::microseconds time);
0143     std::chrono::milliseconds timestamp() const;
0144 
0145     /**
0146      * @name Drag'n'Drop related methods
0147      */
0148     ///@{
0149     /**
0150      * @returns whether there is currently a drag'n'drop going on.
0151      * @see isDragPointer
0152      * @see isDragTouch
0153      * @see dragStarted
0154      * @see dragEnded
0155      */
0156     bool isDrag() const;
0157     /**
0158      * @returns whether the drag'n'drop is operated through the pointer device
0159      * @see isDrag
0160      * @see isDragTouch
0161      */
0162     bool isDragPointer() const;
0163     /**
0164      * @returns whether the drag'n'drop is operated through the touch device
0165      * @see isDrag
0166      * @see isDragPointer
0167      */
0168     bool isDragTouch() const;
0169     /**
0170      * @returns The transformation applied to go from global to local coordinates for drag motion events.
0171      * @see dragSurfaceTransformation
0172      */
0173     QMatrix4x4 dragSurfaceTransformation() const;
0174     /**
0175      * @returns The currently focused Surface for drag motion events.
0176      * @see dragSurfaceTransformation
0177      * @see dragSurfaceChanged
0178      */
0179     SurfaceInterface *dragSurface() const;
0180     /**
0181      * @returns The DataDeviceInterface which started the drag and drop operation.
0182      * @see isDrag
0183      */
0184     KWaylandServer::AbstractDataSource *dragSource() const;
0185     /**
0186      * Sets the current drag target to @p surface.
0187      *
0188      * Sends a drag leave event to the current target and an enter event to @p surface.
0189      * The enter position is derived from @p globalPosition and transformed by @p inputTransformation.
0190      */
0191     void setDragTarget(AbstractDropHandler *dropTarget, SurfaceInterface *surface, const QPointF &globalPosition, const QMatrix4x4 &inputTransformation);
0192     /**
0193      * Sets the current drag target to @p surface.
0194      *
0195      * Sends a drag leave event to the current target and an enter event to @p surface.
0196      * The enter position is derived from current global position and transformed by @p inputTransformation.
0197      */
0198     void setDragTarget(AbstractDropHandler *dropTarget, SurfaceInterface *surface, const QMatrix4x4 &inputTransformation = QMatrix4x4());
0199     ///@}
0200 
0201     AbstractDropHandler *dropHandlerForSurface(SurfaceInterface *surface) const;
0202 
0203     /**
0204      * If there is a current drag in progress, force it to cancel
0205      */
0206     void cancelDrag();
0207 
0208     /**
0209      * @name Pointer related methods
0210      */
0211     ///@{
0212     /**
0213      * Updates the global pointer @p pos.
0214      *
0215      * Sends a pointer motion event to the focused pointer surface.
0216      */
0217     void notifyPointerMotion(const QPointF &pos);
0218     /**
0219      * @returns the global pointer position
0220      */
0221     QPointF pointerPos() const;
0222     /**
0223      * Sets the focused pointer @p surface.
0224      * All pointer events will be sent to the @p surface till a new focused pointer surface gets
0225      * installed. When the focus pointer surface changes a leave event is sent to the previous
0226      * focused surface.
0227      *
0228      * To unset the focused pointer surface pass @c nullptr as @p surface.
0229      *
0230      * Pointer motion events are adjusted to the local position based on the @p surfacePosition.
0231      * If the surface changes it's position in the global coordinate system
0232      * use setFocusedPointerSurfacePosition to update.
0233      * The surface position is used to create the base transformation matrix to go from global
0234      * to surface local coordinates. The default generated matrix is a translation with
0235      * negative @p surfacePosition.
0236      *
0237      * @param surface The surface which should become the new focused pointer surface.
0238      * @param surfacePosition The position of the surface in the global coordinate system
0239      *
0240      * @see setPointerPos
0241      * @see focucedPointerSurface
0242      * @see focusedPointer
0243      * @see setFocusedPointerSurfacePosition
0244      * @see focusedPointerSurfacePosition
0245      * @see setFocusedPointerSurfaceTransformation
0246      * @see focusedPointerSurfaceTransformation
0247      */
0248     void notifyPointerEnter(SurfaceInterface *surface, const QPointF &position, const QPointF &surfacePosition = QPointF());
0249     /**
0250      * Sets the focused pointer @p surface.
0251      * All pointer events will be sent to the @p surface till a new focused pointer surface gets
0252      * installed. When the focus pointer surface changes a leave event is sent to the previous
0253      * focused surface.
0254      *
0255      * To unset the focused pointer surface pass @c nullptr as @p surface.
0256      *
0257      * Pointer motion events are adjusted to the local position based on the @p transformation.
0258      * If the surface changes it's position in the global coordinate system
0259      * use setFocusedPointerSurfaceTransformation to update.
0260      *
0261      * @param surface The surface which should become the new focused pointer surface.
0262      * @param transformation The transformation to transform global into local coordinates
0263      *
0264      * @see setPointerPos
0265      * @see focucedPointerSurface
0266      * @see focusedPointer
0267      * @see setFocusedPointerSurfacePosition
0268      * @see focusedPointerSurfacePosition
0269      * @see setFocusedPointerSurfaceTransformation
0270      * @see focusedPointerSurfaceTransformation
0271      */
0272     void notifyPointerEnter(SurfaceInterface *surface, const QPointF &position, const QMatrix4x4 &transformation);
0273     void notifyPointerLeave();
0274     /**
0275      * @returns The currently focused pointer surface, that is the surface receiving pointer events.
0276      * @see notifyPointerEnter
0277      * @see notifyPointerLeave
0278      */
0279     SurfaceInterface *focusedPointerSurface() const;
0280     PointerInterface *pointer() const;
0281     /**
0282      * Updates the global position of the currently focused pointer surface.
0283      *
0284      * Updating the focused surface position also generates a new transformation matrix.
0285      * The default generated matrix is a translation with negative @p surfacePosition.
0286      * If a different transformation is required a dedicated call to
0287      * @link setFocusedPointerSurfaceTransformation is required.
0288      *
0289      * @param surfacePosition The new global position of the focused pointer surface
0290      * @see focusedPointerSurface
0291      * @see focusedPointerSurfaceTransformation
0292      * @see setFocusedPointerSurfaceTransformation
0293      */
0294     void setFocusedPointerSurfacePosition(const QPointF &surfacePosition);
0295     /**
0296      * @returns The position of the focused pointer surface in global coordinates.
0297      * @see setFocusedPointerSurfacePosition
0298      * @see focusedPointerSurfaceTransformation
0299      */
0300     QPointF focusedPointerSurfacePosition() const;
0301     /**
0302      * Sets the @p transformation for going from global to local coordinates.
0303      *
0304      * The default transformation gets generated from the surface position and reset whenever
0305      * the surface position changes.
0306      *
0307      * @see focusedPointerSurfaceTransformation
0308      * @see focusedPointerSurfacePosition
0309      * @see setFocusedPointerSurfacePosition
0310      */
0311     void setFocusedPointerSurfaceTransformation(const QMatrix4x4 &transformation);
0312     /**
0313      * @returns The transformation applied to pointer position to go from global to local coordinates.
0314      * @see setFocusedPointerSurfaceTransformation
0315      */
0316     QMatrix4x4 focusedPointerSurfaceTransformation() const;
0317     /**
0318      * Marks the specified @a button as pressed or released based on @a state.
0319      */
0320     void notifyPointerButton(quint32 button, PointerButtonState state);
0321     /**
0322      * @overload
0323      */
0324     void notifyPointerButton(Qt::MouseButton button, PointerButtonState state);
0325     void notifyPointerFrame();
0326     /**
0327      * @returns whether the @p button is pressed
0328      */
0329     bool isPointerButtonPressed(quint32 button) const;
0330     /**
0331      * @returns whether the @p button is pressed
0332      */
0333     bool isPointerButtonPressed(Qt::MouseButton button) const;
0334     /**
0335      * @returns the last serial for @p button.
0336      */
0337     quint32 pointerButtonSerial(quint32 button) const;
0338     /**
0339      * @returns the last serial for @p button.
0340      */
0341     quint32 pointerButtonSerial(Qt::MouseButton button) const;
0342     /**
0343      * Sends axis events to the currently focused pointer surface.
0344      *
0345      * @param orientation The scroll axis.
0346      * @param delta The length of a vector along the specified axis @p orientation.
0347      * @param deltaV120 The high-resolution scrolling axis value.
0348      * @param source Describes how the axis event was physically generated.
0349      */
0350     void notifyPointerAxis(Qt::Orientation orientation, qreal delta, qint32 deltaV120, PointerAxisSource source);
0351     /**
0352      * @returns true if there is a pressed button with the given @p serial
0353      */
0354     bool hasImplicitPointerGrab(quint32 serial) const;
0355 
0356     /**
0357      * A relative motion is in the same dimension as regular motion events,
0358      * except they do not represent an absolute position. For example,
0359      * moving a pointer from (x, y) to (x', y') would have the equivalent
0360      * relative motion (x' - x, y' - y). If a pointer motion caused the
0361      * absolute pointer position to be clipped by for example the edge of the
0362      * monitor, the relative motion is unaffected by the clipping and will
0363      * represent the unclipped motion.
0364      *
0365      * This method also contains non-accelerated motion deltas (@p deltaNonAccelerated).
0366      * The non-accelerated delta is, when applicable, the regular pointer motion
0367      * delta as it was before having applied motion acceleration and other
0368      * transformations such as normalization.
0369      *
0370      * Note that the non-accelerated delta does not represent 'raw' events as
0371      * they were read from some device. Pointer motion acceleration is device-
0372      * and configuration-specific and non-accelerated deltas and accelerated
0373      * deltas may have the same value on some devices.
0374      *
0375      * Relative motions are not coupled to wl_pointer.motion events (see {@link setPointerPos},
0376      * and can be sent in combination with such events, but also independently. There may
0377      * also be scenarios where wl_pointer.motion is sent, but there is no
0378      * relative motion. The order of an absolute and relative motion event
0379      * originating from the same physical motion is not guaranteed.
0380      *
0381      * Sending relative pointer events only makes sense if the RelativePointerManagerInterface
0382      * is created on the Display.
0383      *
0384      * @param delta Motion vector
0385      * @param deltaNonAccelerated non-accelerated motion vector
0386      * @param microseconds timestamp with microseconds granularity
0387      * @see setPointerPos
0388      */
0389     void relativePointerMotion(const QPointF &delta, const QPointF &deltaNonAccelerated, std::chrono::microseconds timestamp);
0390 
0391     /**
0392      * Starts a multi-finger swipe gesture for the currently focused pointer surface.
0393      *
0394      * Such gestures are normally reported through dedicated input devices such as touchpads.
0395      *
0396      * The gesture is usually initiated by multiple fingers moving in the
0397      * same direction but once initiated the direction may change.
0398      * The precise conditions of when such a gesture is detected are
0399      * implementation-dependent.
0400      *
0401      * Only one gesture (either swipe or pinch or hold) can be active at a given time.
0402      *
0403      * @param fingerCount The number of fingers involved in this multi-finger touchpad gesture
0404      *
0405      * @see PointerGesturesInterface
0406      * @see focusedPointerSurface
0407      * @see updatePointerSwipeGesture
0408      * @see endPointerSwipeGesture
0409      * @see cancelPointerSwipeGesture
0410      * @see startPointerPinchGesture
0411      */
0412     void startPointerSwipeGesture(quint32 fingerCount);
0413 
0414     /**
0415      * The position of the logical center of the currently active multi-finger swipe gesture changes.
0416      *
0417      * @param delta coordinates are relative coordinates of the logical center of the gesture compared to the previous event.
0418      * @see startPointerSwipeGesture
0419      * @see endPointerSwipeGesture
0420      * @see cancelPointerSwipeGesture
0421      */
0422     void updatePointerSwipeGesture(const QPointF &delta);
0423 
0424     /**
0425      * The multi-finger swipe gesture ended. This may happen when one or more fingers are lifted.
0426      * @see startPointerSwipeGesture
0427      * @see updatePointerSwipeGesture
0428      * @see cancelPointerSwipeGesture
0429      * @see 5.29
0430      */
0431     void endPointerSwipeGesture();
0432 
0433     /**
0434      * The multi-finger swipe gestures ended and got cancelled by the Wayland compositor.
0435      * @see startPointerSwipeGesture
0436      * @see updatePointerSwipeGesture
0437      * @see endPointerSwipeGesture
0438      */
0439     void cancelPointerSwipeGesture();
0440 
0441     /**
0442      * Starts a multi-finch pinch gesture for the currently focused pointer surface.
0443      *
0444      * Such gestures are normally reported through dedicated input devices such as touchpads.
0445      *
0446      * The gesture is usually initiated by multiple fingers moving towards
0447      * each other or away from each other, or by two or more fingers rotating
0448      * around a logical center of gravity. The precise conditions of when
0449      * such a gesture is detected are implementation-dependent.
0450      *
0451      * Only one gesture (either swipe or pinch or hold) can be active at a given time.
0452      *
0453      * @param fingerCount The number of fingers involved in this multi-touch touchpad gesture
0454      *
0455      * @see PointerGesturesInterface
0456      * @see focusedPointerSurface
0457      * @see updatePointerPinchGesture
0458      * @see endPointerPinchGesture
0459      * @see cancelPointerPinchGesture
0460      * @see startPointerSwipeGesture
0461      */
0462     void startPointerPinchGesture(quint32 fingerCount);
0463 
0464     /**
0465      * The position of the logical center, the rotation or the relative scale of this
0466      * multi-finger pinch gesture changes.
0467      *
0468      * @param delta coordinates are relative coordinates of the logical center of the gesture compared to the previous event.
0469      * @param scale an absolute scale compared to the gesture start
0470      * @param rotation relative angle in degrees clockwise compared to the previous start of update
0471      * @see startPointerPinchGesture
0472      * @see endPointerPinchGesture
0473      * @see cancelPointerPinchGesture
0474      */
0475     void updatePointerPinchGesture(const QPointF &delta, qreal scale, qreal rotation);
0476 
0477     /**
0478      *
0479      * @see startPointerPinchGesture
0480      * @see updatePointerPinchGesture
0481      * @see cancelPointerPinchGesture
0482      */
0483     void endPointerPinchGesture();
0484 
0485     /**
0486      *
0487      * @see startPointerPinchGesture
0488      * @see updatePointerPinchGesture
0489      * @see endPointerPinchGesture
0490      */
0491     void cancelPointerPinchGesture();
0492 
0493     /**
0494      * Starts a multi-finger hold gesture for the currently focused pointer surface.
0495      *
0496      * Such gestures are normally reported through dedicated input devices such as touchpads.
0497      *
0498      * The gesture is usually initiated by multiple fingers being held down on the touchpad.
0499      * The precise conditions of when such a gesture is detected are
0500      * implementation-dependent.
0501      *
0502      * Only one gesture (either swipe or pinch or hold) can be active at a given time.
0503      *
0504      * @param fingerCount The number of fingers involved in this multi-finger touchpad gesture
0505      *
0506      * @see PointerGesturesInterface
0507      * @see focusedPointerSurface
0508      * @see endPointerHoldeGesture
0509      * @see cancelPointerHoldGesture
0510      */
0511     void startPointerHoldGesture(quint32 fingerCount);
0512 
0513     /**
0514      * The multi-finger hold gesture ended. This may happen when one or more fingers are lifted.
0515      * @see startPointerHoldGesture
0516      * @see cancelPointerHoldGesture
0517      */
0518     void endPointerHoldGesture();
0519 
0520     /**
0521      * The multi-finger swipe gestures ended and got cancelled by the Wayland compositor.
0522      * @see startPointerHoldGesture
0523      * @see endPointerHoldGesture
0524      */
0525     void cancelPointerHoldGesture();
0526     ///@}
0527 
0528     /**
0529      * Passes keyboard focus to @p surface.
0530      *
0531      * If the SeatInterface has the keyboard capability, also the focused
0532      * text input surface will be set to @p surface.
0533      *
0534      * @see focusedKeyboardSurface
0535      * @see hasKeyboard
0536      * @see setFocusedTextInputSurface
0537      */
0538     void setFocusedKeyboardSurface(SurfaceInterface *surface);
0539     SurfaceInterface *focusedKeyboardSurface() const;
0540     KeyboardInterface *keyboard() const;
0541     void notifyKeyboardKey(quint32 keyCode, KeyboardKeyState state);
0542     void notifyKeyboardModifiers(quint32 depressed, quint32 latched, quint32 locked, quint32 group);
0543     ///@}
0544 
0545     /**
0546      * @name  touch related methods
0547      */
0548     ///@{
0549     void setFocusedTouchSurface(SurfaceInterface *surface, const QPointF &surfacePosition = QPointF());
0550     SurfaceInterface *focusedTouchSurface() const;
0551     TouchInterface *touch() const;
0552     void setFocusedTouchSurfacePosition(const QPointF &surfacePosition);
0553     QPointF focusedTouchSurfacePosition() const;
0554     void notifyTouchDown(qint32 id, const QPointF &globalPosition);
0555     void notifyTouchUp(qint32 id);
0556     void notifyTouchMotion(qint32 id, const QPointF &globalPosition);
0557     void notifyTouchFrame();
0558     void notifyTouchCancel();
0559     bool isTouchSequence() const;
0560     QPointF firstTouchPointPosition() const;
0561     /**
0562      * @returns true if there is a touch sequence going on associated with a touch
0563      * down of the given @p serial.
0564      */
0565     bool hasImplicitTouchGrab(quint32 serial) const;
0566     ///@}
0567 
0568     /**
0569      * @name Text input related methods.
0570      */
0571     ///@{
0572     /**
0573      * Passes text input focus to @p surface.
0574      *
0575      * If the SeatInterface has the keyboard capability this method will
0576      * be invoked automatically when setting the focused keyboard surface.
0577      *
0578      * In case there is a TextInputV2Interface for the @p surface, the enter
0579      * event will be triggered on the TextInputV2Interface for @p surface.
0580      * The focusedTextInput will be set to that TextInputV2Interface. If there
0581      * is no TextInputV2Interface for that @p surface, it might get updated later on.
0582      * In both cases the signal focusedTextInputChanged will be emitted.
0583      *
0584      * @see focusedTextInputSurface
0585      * @see focusedTextInput
0586      * @see focusedTextInputChanged
0587      * @see setFocusedKeyboardSurface
0588      */
0589     void setFocusedTextInputSurface(SurfaceInterface *surface);
0590     /**
0591      * @returns The SurfaceInterface which is currently focused for text input.
0592      * @see setFocusedTextInputSurface
0593      */
0594     SurfaceInterface *focusedTextInputSurface() const;
0595 
0596     TextInputV1Interface *textInputV1() const;
0597 
0598     /**
0599      * The currently focused text input, may be @c null even if there is a
0600      * focused text input surface set.
0601      *
0602      * The focused text input might not be enabled for the {@link focusedTextInputSurface}.
0603      * It is recommended to check the enabled state before interacting with the
0604      * TextInputV2Interface.
0605      *
0606      * @see focusedTextInputChanged
0607      * @see focusedTextInputSurface
0608      */
0609     TextInputV2Interface *textInputV2() const;
0610 
0611     TextInputV3Interface *textInputV3() const;
0612     ///@}
0613 
0614     /**
0615      * @returns The DataDeviceInterface holding the current clipboard selection.
0616      * @see selectionChanged
0617      * @see setSelection
0618      * This may be null
0619      */
0620     KWaylandServer::AbstractDataSource *selection() const;
0621 
0622     /**
0623      * This method allows to manually set the @p dataDevice for the current clipboard selection.
0624      * The clipboard selection is handled automatically in SeatInterface.
0625      * If a DataDeviceInterface belonging to the current focused KeyboardInterface
0626      * sets a selection, the current clipboard selection will be updated automatically.
0627      * With this method it's possible to override the automatic clipboard update for
0628      * e.g. the case of a clipboard manager.
0629      *
0630      * @param dataDevice Sets the current clipboard selection.
0631      * @see selection
0632      * @see selectionChanged
0633      */
0634     void setSelection(AbstractDataSource *selection);
0635 
0636     KWaylandServer::AbstractDataSource *primarySelection() const;
0637     void setPrimarySelection(AbstractDataSource *selection);
0638 
0639     void startDrag(AbstractDataSource *source, SurfaceInterface *sourceSurface, int dragSerial = -1, DragAndDropIcon *dragIcon = nullptr);
0640 
0641     /**
0642      * Returns the additional icon attached to the cursor during a drag-and-drop operation.
0643      * This function returns @c null if no drag-and-drop is active or no icon has been attached.
0644      */
0645     DragAndDropIcon *dragIcon() const;
0646 
0647     static SeatInterface *get(wl_resource *native);
0648 
0649 Q_SIGNALS:
0650     void nameChanged(const QString &);
0651     void hasPointerChanged(bool);
0652     void hasKeyboardChanged(bool);
0653     void hasTouchChanged(bool);
0654     void pointerPosChanged(const QPointF &pos);
0655     void touchMoved(qint32 id, quint32 serial, const QPointF &globalPosition);
0656     void timestampChanged();
0657 
0658     /**
0659      * Emitted whenever the selection changes
0660      * @see selection
0661      * @see setSelection
0662      */
0663     void selectionChanged(KWaylandServer::AbstractDataSource *);
0664 
0665     /**
0666      * Emitted whenever the primary selection changes
0667      * @see primarySelection
0668      */
0669     void primarySelectionChanged(KWaylandServer::AbstractDataSource *);
0670 
0671     /**
0672      * Emitted when a drag'n'drop operation is started
0673      * @see dragEnded
0674      */
0675     void dragStarted();
0676     /**
0677      * Emitted when a drag'n'drop operation ended, either by dropping or canceling.
0678      * @see dragStarted
0679      */
0680     void dragEnded();
0681     /**
0682      * Emitted whenever the drag surface for motion events changed.
0683      * @see dragSurface
0684      */
0685     void dragSurfaceChanged();
0686 
0687     /** Emitted when a drop ocurrs in a drag'n'drop operation. This is emitted
0688      * before dragEnded
0689      */
0690     void dragDropped();
0691     /**
0692      * Emitted whenever the focused text input changed.
0693      * @see focusedTextInput
0694      */
0695     void focusedTextInputSurfaceChanged();
0696     /**
0697      * Emitted whenever the focused keyboard is about to change.
0698      * @see focusedKeyboardSurface
0699      */
0700     void focusedKeyboardSurfaceAboutToChange(SurfaceInterface *nextSurface);
0701 
0702 private:
0703     std::unique_ptr<SeatInterfacePrivate> d;
0704     friend class SeatInterfacePrivate;
0705 };
0706 
0707 }
0708 
0709 Q_DECLARE_METATYPE(KWaylandServer::SeatInterface *)