Skip to content

Commit fc4b417

Browse files
committed
format
1 parent 8c35f43 commit fc4b417

File tree

8 files changed

+72
-36
lines changed

8 files changed

+72
-36
lines changed

src/wayland/input_method/input_method.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include <cstdint>
4+
45
#include <qobject.h>
56
#include <qtclasshelpermacros.h>
67
#include <qwayland-input-method-unstable-v2.h>
@@ -54,7 +55,11 @@ class InputMethodHandle
5455
private:
5556
void zwp_input_method_v2_activate() override;
5657
void zwp_input_method_v2_deactivate() override;
57-
void zwp_input_method_v2_surrounding_text(const QString& text, uint32_t cursor, uint32_t anchor) override;
58+
void zwp_input_method_v2_surrounding_text(
59+
const QString& text,
60+
uint32_t cursor,
61+
uint32_t anchor
62+
) override;
5863
void zwp_input_method_v2_text_change_cause(uint32_t cause) override;
5964
void zwp_input_method_v2_content_type(uint32_t hint, uint32_t purpose) override;
6065
void zwp_input_method_v2_done() override;

src/wayland/input_method/key_map_state.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ std::string_view KeyMapState::keyStateName(wl_keyboard_key_state state) {
9898
}
9999

100100
bool KeyMapState::keyRepeats(xkb_keycode_t key) const {
101-
return xkb_keymap_key_repeats(this->xkbKeymap, key);
101+
return xkb_keymap_key_repeats(this->xkbKeymap, key);
102102
}
103103

104104
xkb_context* KeyMapState::xkbContext = xkb_context_new(XKB_CONTEXT_NO_FLAGS);

src/wayland/input_method/keyboard_grab.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121
#include "types.hpp"
2222
#include "virtual_keyboard.hpp"
2323

24-
QS_LOGGING_CATEGORY(inputMethodKeyboardKeys, "quickshell.wayland.inputMethod.keyboardKeys", QtWarningMsg);
24+
QS_LOGGING_CATEGORY(
25+
inputMethodKeyboardKeys,
26+
"quickshell.wayland.inputMethod.keyboardKeys",
27+
QtWarningMsg
28+
);
2529

2630
namespace qs::wayland::input_method::impl {
2731

@@ -31,7 +35,7 @@ InputMethodKeyboardGrab::InputMethodKeyboardGrab(
3135
)
3236
: QObject(parent)
3337
, zwp_input_method_keyboard_grab_v2(keyboard) {
34-
this->mRepeatTimer.callOnTimeout(this, [this](){
38+
this->mRepeatTimer.callOnTimeout(this, [this]() {
3539
this->mRepeatTimer.setInterval(1000 / this->mRepeatRate);
3640
this->handleKey(this->mRepeatKey);
3741
});
@@ -94,9 +98,10 @@ void InputMethodKeyboardGrab::zwp_input_method_keyboard_grab_v2_key(
9498

9599
key += WAYLAND_KEY_OFFSET;
96100

97-
qCInfo(inputMethodKeyboardKeys) << KeyMapState::keyStateName(static_cast<wl_keyboard_key_state>(state))
98-
<< this->mKeyMapState.keyName(key) << "[" << key << "]"
99-
<< this->mKeyMapState.getChar(key);
101+
qCInfo(inputMethodKeyboardKeys) << KeyMapState::keyStateName(
102+
static_cast<wl_keyboard_key_state>(state)
103+
) << this->mKeyMapState.keyName(key)
104+
<< "[" << key << "]" << this->mKeyMapState.getChar(key);
100105

101106
const xkb_keysym_t sym = this->mKeyMapState.getOneSym(key);
102107

@@ -118,7 +123,7 @@ void InputMethodKeyboardGrab::zwp_input_method_keyboard_grab_v2_key(
118123

119124
if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
120125
const bool keyHandled = this->handleKey(key);
121-
if (keyHandled){
126+
if (keyHandled) {
122127
if (this->mKeyMapState.keyRepeats(key) && this->mRepeatRate > 0) {
123128
this->mRepeatKey = key;
124129
this->mRepeatTimer.setInterval(this->mRepeatDelay);
@@ -135,7 +140,7 @@ void InputMethodKeyboardGrab::zwp_input_method_keyboard_grab_v2_key(
135140
this->mVirturalKeyboard->sendKey(key, static_cast<wl_keyboard_key_state>(state));
136141
}
137142

138-
bool InputMethodKeyboardGrab::handleKey(xkb_keycode_t key){
143+
bool InputMethodKeyboardGrab::handleKey(xkb_keycode_t key) {
139144
const xkb_keysym_t sym = this->mKeyMapState.getOneSym(key);
140145
if (sym == XKB_KEY_Up) {
141146
emit this->directionPress(DirectionKey::Up);

src/wayland/input_method/keyboard_grab.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
#include <qobject.h>
44
#include <qtclasshelpermacros.h>
5-
#include <qwayland-input-method-unstable-v2.h>
65
#include <qtimer.h>
6+
#include <qwayland-input-method-unstable-v2.h>
77

88
#include "key_map_state.hpp"
99
#include "types.hpp"

src/wayland/input_method/qml.hpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,28 @@ class InputMethod: public QObject {
6464
/// If the input method has grabbed the keyboard
6565
Q_PROPERTY(bool hasKeyboard READ hasKeyboard NOTIFY hasKeyboardChanged);
6666
/// Provides virtual text in the text input so the user can visualise what they write
67-
Q_PROPERTY(QString preeditString READ preeditString WRITE setPreeditString NOTIFY preeditStringChanged);
67+
Q_PROPERTY(
68+
QString preeditString READ preeditString WRITE setPreeditString NOTIFY preeditStringChanged
69+
);
6870
/// If `cursorBegin == cursorEnd == -1` the text input will not show a cursor
6971
/// If `cursorBegin == cursorEnd == n` or `cursorBegin == n && cursorEnd == -1` the text input will show a cursor at n
7072
/// If `cursorBegin == n` and `cursorEnd == m` the text from n to m will be highlighted
7173
Q_PROPERTY(int32_t cursorBegin READ cursorBegin WRITE setCursorBegin NOTIFY cursorBeginChanged);
7274
Q_PROPERTY(int32_t cursorEnd READ cursorEnd WRITE setCursorEnd NOTIFY cursorEndChanged);
7375
/// The text around the where we will insert
7476
Q_PROPERTY(QString surroundingText READ surroundingText NOTIFY surroundingTextChanged);
75-
Q_PROPERTY(uint32_t surroundingTextCurosr READ surroundingTextCursor NOTIFY surroundingTextChanged);
76-
Q_PROPERTY(uint32_t surroundingTextAnchor READ surroundingTextAnchor NOTIFY surroundingTextChanged);
77+
Q_PROPERTY(
78+
uint32_t surroundingTextCurosr READ surroundingTextCursor NOTIFY surroundingTextChanged
79+
);
80+
Q_PROPERTY(
81+
uint32_t surroundingTextAnchor READ surroundingTextAnchor NOTIFY surroundingTextChanged
82+
);
7783
/// The content_hint of the text input see https://wayland.app/protocols/text-input-unstable-v3#zwp_text_input_v3:enum:content_hint
7884
Q_PROPERTY(QMLContentHint::Enum contentHint READ contentHint NOTIFY contentHintChanged);
7985
/// The content_purpose of the text input see https://wayland.app/protocols/text-input-unstable-v3#zwp_text_input_v3:enum:content_purpose
80-
Q_PROPERTY(QMLContentPurpose::Enum contentPurpose READ contentPurpose NOTIFY contentPurposeChanged);
86+
Q_PROPERTY(
87+
QMLContentPurpose::Enum contentPurpose READ contentPurpose NOTIFY contentPurposeChanged
88+
);
8189
/// Clear the preedit text when the keyboard grab is released
8290
Q_PROPERTY(
8391
bool clearPreeditOnKeyboardRelease MEMBER mClearPreeditOnKeyboardRelease NOTIFY

src/wayland/input_method/qml_helpers.cpp

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,49 @@ namespace qs::wayland::input_method {
1313

1414
KeyboardTextEdit::KeyboardTextEdit(QObject* parent): InputMethod(parent) {
1515
QObject::connect(
16-
this,
17-
&InputMethod::hasKeyboardChanged,
18-
this,
19-
&KeyboardTextEdit::onHasKeyboardChanged
16+
this,
17+
&InputMethod::hasKeyboardChanged,
18+
this,
19+
&KeyboardTextEdit::onHasKeyboardChanged
2020
);
2121

2222
QObject::connect(
23-
this,
24-
&InputMethod::surroundingTextChanged,
25-
this,
26-
&KeyboardTextEdit::onSurroundingTextChanged
23+
this,
24+
&InputMethod::surroundingTextChanged,
25+
this,
26+
&KeyboardTextEdit::onSurroundingTextChanged
2727
);
2828
}
2929

3030
void KeyboardTextEdit::onHasKeyboardChanged() {
31-
if(!this->hasKeyboard()) {
31+
if (!this->hasKeyboard()) {
3232
return;
3333
}
3434
QObject::connect(this->keyboard(), &Keyboard::keyPress, this, &KeyboardTextEdit::onKeyPress);
35-
QObject::connect(this->keyboard(), &Keyboard::returnPress, this, &KeyboardTextEdit::onReturnPress);
36-
QObject::connect(this->keyboard(), &Keyboard::directionPress, this, &KeyboardTextEdit::onDirectionPress);
37-
QObject::connect(this->keyboard(), &Keyboard::backspacePress, this, &KeyboardTextEdit::onBackspacePress);
38-
QObject::connect(this->keyboard(), &Keyboard::deletePress, this, &KeyboardTextEdit::onDeletePress);
35+
QObject::connect(
36+
this->keyboard(),
37+
&Keyboard::returnPress,
38+
this,
39+
&KeyboardTextEdit::onReturnPress
40+
);
41+
QObject::connect(
42+
this->keyboard(),
43+
&Keyboard::directionPress,
44+
this,
45+
&KeyboardTextEdit::onDirectionPress
46+
);
47+
QObject::connect(
48+
this->keyboard(),
49+
&Keyboard::backspacePress,
50+
this,
51+
&KeyboardTextEdit::onBackspacePress
52+
);
53+
QObject::connect(
54+
this->keyboard(),
55+
&Keyboard::deletePress,
56+
this,
57+
&KeyboardTextEdit::onDeletePress
58+
);
3959
}
4060

4161
QJSValue KeyboardTextEdit::transform() const { return this->mTransform; }

src/wayland/input_method/qml_helpers.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace qs::wayland::input_method {
1414
/// A cursor enables some control over the composition of the text.
1515
/// When return is pressed the transform function is called and the returned string is sent to the input text
1616
/// and the keyboard is released.
17-
///
17+
///
1818
/// ```
1919
/// KeyboardTextEdit {
2020
/// id: keyboard_text_edit

src/wayland/input_method/types.hpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#pragma once
22

3+
#include <qobject.h>
34
#include <qqmlintegration.h>
45
#include <qtclasshelpermacros.h>
56
#include <qtmetamacros.h>
6-
#include <xkbcommon/xkbcommon.h>
77
#include <wayland-text-input-unstable-v3-client-protocol.h>
8-
#include <qobject.h>
8+
#include <xkbcommon/xkbcommon.h>
99

1010
namespace qs::wayland::input_method {
1111

@@ -15,9 +15,7 @@ class QMLDirectionKey: public QObject {
1515
QML_SINGLETON;
1616

1717
public:
18-
enum Enum : quint8 {
19-
Up, Down, Left, Right
20-
};
18+
enum Enum : quint8 { Up, Down, Left, Right };
2119
Q_ENUM(Enum);
2220

2321
Q_INVOKABLE static QString toString(Enum direction);
@@ -53,7 +51,7 @@ class QMLContentPurpose: public QObject {
5351
QML_SINGLETON;
5452

5553
public:
56-
enum Enum : quint8{
54+
enum Enum : quint8 {
5755
Normal = ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NORMAL,
5856
Alpha = ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_ALPHA,
5957
Digits = ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_DIGITS,
@@ -97,5 +95,5 @@ using ContentPurpose = QMLContentPurpose::Enum;
9795
using TextChangeCause = QMLTextChangeCause::Enum;
9896

9997
inline constexpr xkb_keycode_t WAYLAND_KEY_OFFSET = 8;
100-
}
101-
} // namespace qs::wayland::input_method::impl
98+
} // namespace impl
99+
} // namespace qs::wayland::input_method

0 commit comments

Comments
 (0)