2020-03-15 15:19:28 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
|
|
|
*/
|
2021-03-10 16:08:30 +00:00
|
|
|
#pragma once
|
|
|
|
|
2016-04-06 09:35:31 +00:00
|
|
|
#include "keyboard_interface.h"
|
2020-10-02 14:22:59 +00:00
|
|
|
|
|
|
|
#include <qwayland-server-wayland.h>
|
2016-04-06 09:35:31 +00:00
|
|
|
|
2016-04-06 11:50:19 +00:00
|
|
|
#include <QPointer>
|
2020-10-02 14:22:59 +00:00
|
|
|
#include <QHash>
|
2016-04-06 11:50:19 +00:00
|
|
|
|
2020-03-19 13:58:52 +00:00
|
|
|
class QTemporaryFile;
|
|
|
|
|
2020-04-29 14:56:38 +00:00
|
|
|
namespace KWaylandServer
|
2016-04-06 09:35:31 +00:00
|
|
|
{
|
|
|
|
|
2020-10-02 14:22:59 +00:00
|
|
|
class ClientConnection;
|
|
|
|
|
|
|
|
class KeyboardInterfacePrivate : public QtWaylandServer::wl_keyboard
|
2016-04-06 09:35:31 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-10-02 14:22:59 +00:00
|
|
|
KeyboardInterfacePrivate(SeatInterface *s);
|
|
|
|
|
|
|
|
|
2016-04-06 09:35:31 +00:00
|
|
|
void sendKeymap(int fd, quint32 size);
|
|
|
|
void sendModifiers();
|
|
|
|
void sendModifiers(quint32 depressed, quint32 latched, quint32 locked, quint32 group, quint32 serial);
|
|
|
|
|
2020-10-02 14:22:59 +00:00
|
|
|
QList<Resource *> keyboardsForClient(ClientConnection *client) const;
|
2016-04-06 11:50:19 +00:00
|
|
|
void sendLeave(SurfaceInterface *surface, quint32 serial);
|
|
|
|
void sendEnter(SurfaceInterface *surface, quint32 serial);
|
|
|
|
|
2020-10-02 14:22:59 +00:00
|
|
|
static KeyboardInterfacePrivate *get(KeyboardInterface *keyboard) { return keyboard->d.data(); }
|
|
|
|
|
2016-04-06 09:35:31 +00:00
|
|
|
SeatInterface *seat;
|
|
|
|
SurfaceInterface *focusedSurface = nullptr;
|
|
|
|
QMetaObject::Connection destroyConnection;
|
2020-03-19 13:58:52 +00:00
|
|
|
QScopedPointer<QTemporaryFile> keymap;
|
2016-04-06 09:35:31 +00:00
|
|
|
|
2020-10-02 14:22:59 +00:00
|
|
|
struct {
|
|
|
|
qint32 charactersPerSecond = 0;
|
|
|
|
qint32 delay = 0;
|
|
|
|
} keyRepeat;
|
|
|
|
|
|
|
|
struct Modifiers {
|
|
|
|
quint32 depressed = 0;
|
|
|
|
quint32 latched = 0;
|
|
|
|
quint32 locked = 0;
|
|
|
|
quint32 group = 0;
|
|
|
|
quint32 serial = 0;
|
|
|
|
};
|
|
|
|
Modifiers modifiers;
|
|
|
|
|
|
|
|
enum class State {
|
|
|
|
Released,
|
|
|
|
Pressed
|
|
|
|
};
|
|
|
|
QHash<quint32, State> states;
|
|
|
|
bool updateKey(quint32 key, State state);
|
|
|
|
QVector<quint32> pressedKeys() const;
|
|
|
|
|
|
|
|
protected:
|
2021-03-15 10:34:35 +00:00
|
|
|
void keyboard_release(Resource *resource) override;
|
2020-10-02 14:22:59 +00:00
|
|
|
void keyboard_bind_resource(Resource *resource) override;
|
2016-04-06 09:35:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|