File indexing completed on 2024-05-19 05:32:35

0001 /*
0002     SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 #pragma once
0007 
0008 #include "kwin_export.h"
0009 
0010 #include <QObject>
0011 
0012 namespace KWin
0013 {
0014 class ClientConnection;
0015 class SeatInterface;
0016 class SurfaceInterface;
0017 class KeyboardInterfacePrivate;
0018 
0019 enum class KeyboardKeyState : quint32;
0020 
0021 /**
0022  * @brief Resource for the wl_keyboard interface.
0023  */
0024 class KWIN_EXPORT KeyboardInterface : public QObject
0025 {
0026     Q_OBJECT
0027 public:
0028     ~KeyboardInterface() override;
0029 
0030     /**
0031      * @returns the focused SurfaceInterface on this keyboard resource, if any.
0032      */
0033     SurfaceInterface *focusedSurface() const;
0034 
0035     /**
0036      * @returns The key repeat in character per second
0037      */
0038     qint32 keyRepeatRate() const;
0039     /**
0040      * @returns The delay on key press before starting repeating keys
0041      */
0042     qint32 keyRepeatDelay() const;
0043     void setKeymap(const QByteArray &content);
0044 
0045     /**
0046      * Sets the key repeat information to be forwarded to all bound keyboards.
0047      *
0048      * To disable key repeat set a @p charactersPerSecond of @c 0.
0049      *
0050      * Requires wl_seat version 4.
0051      *
0052      * @param charactersPerSecond The characters per second rate, value of @c 0 disables key repeating
0053      * @param delay The delay on key press before starting repeating keys
0054      */
0055     void setRepeatInfo(qint32 charactersPerSecond, qint32 delay);
0056 
0057     void sendKey(quint32 key, KeyboardKeyState state);
0058     void sendKey(quint32 key, KeyboardKeyState state, ClientConnection *client);
0059     void sendModifiers(quint32 depressed, quint32 latched, quint32 locked, quint32 group);
0060 
0061 private:
0062     void setFocusedSurface(SurfaceInterface *surface, quint32 serial);
0063     void setModifierFocusSurface(SurfaceInterface *surface);
0064     friend class SeatInterface;
0065     friend class SeatInterfacePrivate;
0066     friend class KeyboardInterfacePrivate;
0067     explicit KeyboardInterface(SeatInterface *seat);
0068 
0069     std::unique_ptr<KeyboardInterfacePrivate> d;
0070 };
0071 
0072 }
0073 
0074 Q_DECLARE_METATYPE(KWin::KeyboardInterface *)