Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
LockKeyboard.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3#pragma once
4
5#include <QObject>
6#include <QString>
7#include <QtQml/qqmlregistration.h>
8
9#include <memory>
10
11struct wl_keyboard;
12struct wl_seat;
13
15
16class KeyboardState;
17
18// The active keyboard layout and Caps Lock, read from this client's own
19// wl_keyboard on the seat: the keymap names the layouts, and the modifiers
20// event carries the active layout (the xkb group) and the locked modifiers.
21// The compositor sends those to the client with keyboard focus, which the
22// lock or prompt surface has while it is up, so Caps Lock already on at lock
23// shows from the first frame that surface has focus. Wayland has no standard
24// request to switch layouts, so this only reports them.
25class LockKeyboard : public QObject
26{
27 Q_OBJECT
28 QML_ELEMENT
29 Q_PROPERTY(QString layoutName READ layoutName NOTIFY layoutChanged)
30 Q_PROPERTY(bool capsLock READ capsLock NOTIFY capsLockChanged)
31
32public:
33 // On the seat of Qt's own Wayland connection. Inert off Wayland or on a
34 // seat without a keyboard.
35 explicit LockKeyboard(QObject* parent = nullptr);
36 // On `seat`, whose connection's default queue someone dispatches.
37 // Null: inert.
38 explicit LockKeyboard(wl_seat* seat, QObject* parent = nullptr);
39 ~LockKeyboard() override;
40
41 // The active layout's name from the keymap, such as "English (US)".
42 // Empty until a keymap arrives.
43 [[nodiscard]] QString layoutName() const;
44 [[nodiscard]] bool capsLock() const;
45
46Q_SIGNALS:
49
50private:
51 struct Listener;
52 friend struct Listener;
53
54 void publish();
55
56 wl_keyboard* m_keyboard = nullptr;
57 std::unique_ptr<KeyboardState> m_state;
58 QString m_layoutName;
59 bool m_capsLock = false;
60};
61}
LockKeyboard(wl_seat *seat, QObject *parent=nullptr)
friend struct Listener
Definition LockKeyboard.h:52
LockKeyboard(QObject *parent=nullptr)
Definition LockKeyboard.h:14