Skip to content

Commit cd02df7

Browse files
committed
format
1 parent bf4be88 commit cd02df7

File tree

10 files changed

+96
-48
lines changed

10 files changed

+96
-48
lines changed

src/wayland/input_method/input_method.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ void InputMethodHandle::zwp_input_method_v2_unavailable() {
6060
if (!this->mAvailable) return;
6161
this->mAvailable = false;
6262
deleteLater();
63-
qDebug(
64-
) << "Compositor denied input method request, likely due to one already existing elsewhere";
63+
qDebug()
64+
<< "Compositor denied input method request, likely due to one already existing elsewhere";
6565
}
6666

6767
} // namespace qs::wayland::input_method::impl

src/wayland/input_method/key_map_state.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ uniqueCString KeyMapState::keyMapAsString() const {
4343
bool KeyMapState::operator==(const KeyMapState& other) const {
4444
return this->xkbKeymap == other.xkbKeymap && this->xkbState == other.xkbState;
4545
}
46-
KeyMapState::operator bool() const { return this->xkbKeymap != nullptr && this->xkbState != nullptr; }
46+
KeyMapState::operator bool() const {
47+
return this->xkbKeymap != nullptr && this->xkbState != nullptr;
48+
}
4749

4850
namespace {
4951
const char* getName(char key);
@@ -85,12 +87,12 @@ void KeyMapState::setModifiers(ModifierState modifierState) {
8587

8688
KeyMapState::ModifierState KeyMapState::serialiseMods() const {
8789
return {
88-
xkb_state_serialize_mods(this->xkbState, XKB_STATE_MODS_DEPRESSED),
89-
xkb_state_serialize_mods(this->xkbState, XKB_STATE_MODS_LATCHED),
90-
xkb_state_serialize_mods(this->xkbState, XKB_STATE_MODS_LOCKED),
91-
xkb_state_serialize_mods(this->xkbState, XKB_STATE_LAYOUT_DEPRESSED),
92-
xkb_state_serialize_mods(this->xkbState, XKB_STATE_LAYOUT_LATCHED),
93-
xkb_state_serialize_mods(this->xkbState, XKB_STATE_LAYOUT_LOCKED),
90+
xkb_state_serialize_mods(this->xkbState, XKB_STATE_MODS_DEPRESSED),
91+
xkb_state_serialize_mods(this->xkbState, XKB_STATE_MODS_LATCHED),
92+
xkb_state_serialize_mods(this->xkbState, XKB_STATE_MODS_LOCKED),
93+
xkb_state_serialize_mods(this->xkbState, XKB_STATE_LAYOUT_DEPRESSED),
94+
xkb_state_serialize_mods(this->xkbState, XKB_STATE_LAYOUT_LATCHED),
95+
xkb_state_serialize_mods(this->xkbState, XKB_STATE_LAYOUT_LOCKED),
9496
};
9597
}
9698

src/wayland/input_method/key_map_state.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class KeyMapState {
4444
xkb_layout_index_t lockedLayout;
4545
};
4646
// This is the server version
47-
// if we want to expand virtual keyboard support
47+
// if we want to expand virtual keyboard support
4848
void setModifiers(ModifierState modifierState);
4949
[[nodiscard]] ModifierState serialiseMods() const;
5050

src/wayland/input_method/keyboard_grab.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ InputMethodKeyboardGrab::~InputMethodKeyboardGrab() {
2323
// Release forward the pressed keys to the text input
2424
for (xkb_keycode_t key = 0; key < this->mKeyState.size(); ++key) {
2525
if (this->mKeyState[key] == KeyState::PRESSED) {
26-
this->mVirturalKeyboard->sendKey(key + this->mKeyMapState.minKeycode(), WL_KEYBOARD_KEY_STATE_PRESSED);
26+
this->mVirturalKeyboard->sendKey(
27+
key + this->mKeyMapState.minKeycode(),
28+
WL_KEYBOARD_KEY_STATE_PRESSED
29+
);
2730
}
2831
}
2932
}
@@ -44,12 +47,19 @@ void InputMethodKeyboardGrab::zwp_input_method_keyboard_grab_v2_keymap(
4447
munmap(mapShm, size);
4548
close(fd);
4649

47-
this->mVirturalKeyboard = VirtualKeyboardManager::instance()->createVirtualKeyboard(this->mKeyMapState);
48-
this->mKeyState = std::vector<KeyState>(this->mKeyMapState.maxKeycode() - this->mKeyMapState.minKeycode() - 8, KeyState::RELEASED);
50+
this->mVirturalKeyboard =
51+
VirtualKeyboardManager::instance()->createVirtualKeyboard(this->mKeyMapState);
52+
this->mKeyState = std::vector<KeyState>(
53+
this->mKeyMapState.maxKeycode() - this->mKeyMapState.minKeycode() - 8,
54+
KeyState::RELEASED
55+
);
4956

5057
// Tell the text input to release all the keys
5158
for (xkb_keycode_t key = 0; key < this->mKeyState.size(); ++key) {
52-
this->mVirturalKeyboard->sendKey(key + this->mKeyMapState.minKeycode(), WL_KEYBOARD_KEY_STATE_RELEASED);
59+
this->mVirturalKeyboard->sendKey(
60+
key + this->mKeyMapState.minKeycode(),
61+
WL_KEYBOARD_KEY_STATE_RELEASED
62+
);
5363
}
5464
}
5565

@@ -65,14 +75,16 @@ void InputMethodKeyboardGrab::zwp_input_method_keyboard_grab_v2_key(
6575
key += 8;
6676

6777
qInfo() << KeyMapState::keyStateName(static_cast<wl_keyboard_key_state>(state))
68-
<< this->mKeyMapState.keyName(key) << "[" << key << "]"
69-
<< this->mKeyMapState.getChar(key);
78+
<< this->mKeyMapState.keyName(key) << "[" << key << "]"
79+
<< this->mKeyMapState.getChar(key);
7080

71-
if (state == WL_KEYBOARD_KEY_STATE_PRESSED
81+
if (
82+
state == WL_KEYBOARD_KEY_STATE_PRESSED
7283
#ifndef WL_KEYBOARD_KEY_STATE_REPEATED_SINCE_VERSION
73-
|| state == WL_KEYBOARD_KEY_STATE_REPEATED
84+
|| state == WL_KEYBOARD_KEY_STATE_REPEATED
7485
#endif
75-
) {
86+
)
87+
{
7688
this->mKeyState[key - this->mKeyMapState.minKeycode()] = KeyState::PRESSED;
7789
} else if (state == WL_KEYBOARD_KEY_STATE_RELEASED) {
7890
this->mKeyState[key - this->mKeyMapState.minKeycode()] = KeyState::RELEASED;

src/wayland/input_method/keyboard_grab.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#include <qtclasshelpermacros.h>
55
#include <qwayland-input-method-unstable-v2.h>
66

7-
#include "types.hpp"
87
#include "key_map_state.hpp"
8+
#include "types.hpp"
99

1010
namespace qs::wayland::input_method::impl {
1111

src/wayland/input_method/manager.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,31 @@ InputMethodManager* InputMethodManager::instance() {
1818

1919
namespace {
2020
wl_seat* getSeat() {
21-
return dynamic_cast<QGuiApplication*>(QGuiApplication::instance())
22-
->nativeInterface<QNativeInterface::QWaylandApplication>()
23-
->seat();
24-
}
21+
return dynamic_cast<QGuiApplication*>(QGuiApplication::instance())
22+
->nativeInterface<QNativeInterface::QWaylandApplication>()
23+
->seat();
2524
}
25+
} // namespace
2626

2727
QPointer<InputMethodHandle> InputMethodManager::acquireInput() {
2828
if (inputMethod && inputMethod->isAvailable()) return inputMethod;
2929

30-
inputMethod = new InputMethodHandle(
31-
this,
32-
get_input_method(getSeat())
33-
);
30+
inputMethod = new InputMethodHandle(this, get_input_method(getSeat()));
3431

3532
return inputMethod;
3633
}
3734

38-
39-
VirtualKeyboardManager::VirtualKeyboardManager(): QWaylandClientExtensionTemplate(1) { this->initialize(); }
35+
VirtualKeyboardManager::VirtualKeyboardManager(): QWaylandClientExtensionTemplate(1) {
36+
this->initialize();
37+
}
4038

4139
VirtualKeyboardManager* VirtualKeyboardManager::instance() {
4240
static auto instance = std::unique_ptr<VirtualKeyboardManager>(new VirtualKeyboardManager());
4341
return instance.get();
4442
}
4543

46-
std::unique_ptr<VirtualKeyboardHandle> VirtualKeyboardManager::createVirtualKeyboard(const KeyMapState& keymap) {
44+
std::unique_ptr<VirtualKeyboardHandle>
45+
VirtualKeyboardManager::createVirtualKeyboard(const KeyMapState& keymap) {
4746
return std::make_unique<VirtualKeyboardHandle>(create_virtual_keyboard(getSeat()), keymap);
4847
}
4948

src/wayland/input_method/qml.cpp

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ void InputMethod::sendString(const QString& text) {
1818
this->handle->commit();
1919
}
2020

21-
2221
void InputMethod::sendPreeditString(const QString& text, int32_t cursorBegin, int32_t cursorEnd) {
2322
if (!this->isActive()) return;
2423

@@ -113,7 +112,7 @@ void InputMethod::grabKeyboard() {
113112
}
114113

115114
void InputMethod::releaseKeyboard() {
116-
if(!this->hasKeyboard()) return;
115+
if (!this->hasKeyboard()) return;
117116
this->keyboard->deleteLater();
118117
this->keyboard = nullptr;
119118
this->handle->releaseKeyboard();
@@ -143,11 +142,36 @@ void Keyboard::setKeyboard(QPointer<InputMethodKeyboardGrab> keyboard) {
143142
this->mKeyboard = std::move(keyboard);
144143

145144
QObject::connect(this->mKeyboard, &InputMethodKeyboardGrab::keyPress, this, &Keyboard::keyPress);
146-
QObject::connect(this->mKeyboard, &InputMethodKeyboardGrab::escapePress, this, &Keyboard::escapePress);
147-
QObject::connect(this->mKeyboard, &InputMethodKeyboardGrab::returnPress, this, &Keyboard::returnPress);
148-
QObject::connect(this->mKeyboard, &InputMethodKeyboardGrab::directionPress, this, &Keyboard::directionPress);
149-
QObject::connect(this->mKeyboard, &InputMethodKeyboardGrab::backspacePress, this, &Keyboard::backspacePress);
150-
QObject::connect(this->mKeyboard, &InputMethodKeyboardGrab::deletePress, this, &Keyboard::deletePress);
145+
QObject::connect(
146+
this->mKeyboard,
147+
&InputMethodKeyboardGrab::escapePress,
148+
this,
149+
&Keyboard::escapePress
150+
);
151+
QObject::connect(
152+
this->mKeyboard,
153+
&InputMethodKeyboardGrab::returnPress,
154+
this,
155+
&Keyboard::returnPress
156+
);
157+
QObject::connect(
158+
this->mKeyboard,
159+
&InputMethodKeyboardGrab::directionPress,
160+
this,
161+
&Keyboard::directionPress
162+
);
163+
QObject::connect(
164+
this->mKeyboard,
165+
&InputMethodKeyboardGrab::backspacePress,
166+
this,
167+
&Keyboard::backspacePress
168+
);
169+
QObject::connect(
170+
this->mKeyboard,
171+
&InputMethodKeyboardGrab::deletePress,
172+
this,
173+
&Keyboard::deletePress
174+
);
151175
}
152176

153177
} // namespace qs::wayland::input_method

src/wayland/input_method/qml.hpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <qobject.h>
44
#include <qqmlintegration.h>
55
#include <qtmetamacros.h>
6+
67
#include "types.hpp"
78

89
namespace qs::wayland::input_method {
@@ -43,18 +44,28 @@ class InputMethod: public QObject {
4344
Q_PROPERTY(bool active READ isActive NOTIFY activeChanged);
4445
Q_PROPERTY(bool hasInput READ hasInput NOTIFY hasInputChanged);
4546
Q_PROPERTY(bool hasKeyboard READ hasKeyboard NOTIFY hasKeyboardChanged);
46-
Q_PROPERTY(bool keyboardOnActive MEMBER mKeyboardOnActive READ keyboardOnActive WRITE setKeyboardOnActive NOTIFY keyboardOnActiveChanged);
47-
Q_PROPERTY(bool clearPreeditOnKeyboardRelease MEMBER mClearPreeditOnKeyboardRelease NOTIFY clearPreeditOnKeyboardReleaseChanged);
47+
Q_PROPERTY(
48+
bool keyboardOnActive MEMBER mKeyboardOnActive READ keyboardOnActive WRITE setKeyboardOnActive
49+
NOTIFY keyboardOnActiveChanged
50+
);
51+
Q_PROPERTY(
52+
bool clearPreeditOnKeyboardRelease MEMBER mClearPreeditOnKeyboardRelease NOTIFY
53+
clearPreeditOnKeyboardReleaseChanged
54+
);
4855
// Q_PROPERTY(QString preedit)
49-
Q_PROPERTY(QQmlComponent* keyboard READ keyboardComponent WRITE setKeyboardComponent NOTIFY keyboardComponentChanged);
56+
Q_PROPERTY(
57+
QQmlComponent* keyboard READ keyboardComponent WRITE setKeyboardComponent NOTIFY
58+
keyboardComponentChanged
59+
);
5060
Q_CLASSINFO("DefaultProperty", "keyboard");
5161
QML_NAMED_ELEMENT(InputPicker);
5262

5363
public:
5464
explicit InputMethod(QObject* parent = nullptr);
5565

5666
Q_INVOKABLE void sendString(const QString& text);
57-
Q_INVOKABLE void sendPreeditString(const QString& text, int32_t cursorBegin = -1, int32_t cursorEnd = -1);
67+
Q_INVOKABLE void
68+
sendPreeditString(const QString& text, int32_t cursorBegin = -1, int32_t cursorEnd = -1);
5869
Q_INVOKABLE void deleteText(int before = 1, int after = 0);
5970

6071
Q_INVOKABLE [[nodiscard]] bool isActive() const;

src/wayland/input_method/types.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ namespace qs::wayland::input_method {
77
enum DirectionKey { UP, DOWN, LEFT, RIGHT };
88

99
namespace impl {
10-
struct FreeDeleter{
11-
void operator()(const char *p) const {
12-
std::free(const_cast<std::remove_const_t<char>*>(p)); // NOLINT
13-
}
10+
struct FreeDeleter {
11+
void operator()(const char* p) const {
12+
std::free(const_cast<std::remove_const_t<char>*>(p)); // NOLINT
13+
}
1414
};
1515
// Dont use this for literals, only c strings that were allocated
1616
using uniqueCString = std::unique_ptr<const char, FreeDeleter>;
17-
}
17+
} // namespace impl
1818

1919
} // namespace qs::wayland::input_method

src/wayland/input_method/virtual_keyboard.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
#include <qobject.h>
44
#include <qtclasshelpermacros.h>
55
#include <qwayland-virtual-keyboard-unstable-v1.h>
6+
#include <xkbcommon/xkbcommon.h>
67

78
#include "key_map_state.hpp"
8-
#include <xkbcommon/xkbcommon.h>
99

1010
namespace qs::wayland::input_method::impl {
1111

0 commit comments

Comments
 (0)