-
Notifications
You must be signed in to change notification settings - Fork 60
wayland: input method protocol #195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
wayland: input method protocol #195
Conversation
f07a697 to
d92ced5
Compare
|
|
|
I still need to do a couple things - especially documentation. I'll add the popup screen and exposing virtual keyboard in future prs since this one is already quite large. |
b265756 to
7054e2d
Compare
a92879d to
9bb2c04
Compare
|
Sorry I haven't updated in a while. I have a separate branch that I have been working on the adding the popup surface functionality however it looks like I need to use the private qt headers, which I have not yet been able to work out. |
|
Looks like CI is broken here, can you rebase on master? For private qt headers you should just be able to import them if you add a dependency on the private qt module. |
44f8232 to
c7ed0c2
Compare
outfoxxed
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed most of it that didn't seem likely to greatly change. It would also be useful if you included a couple tests. They dont have to be complex or automatic, just some QML files we can run to make sure its still working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this protocol included directly instead of from w-p?
| /// The @@Keyboard$ that will handle the grabbed keyboard. | ||
| /// Use @@KeyboardTextEdit$ for most cases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can drop the $ if there's a space, period, or comma after the reference
| Q_INVOKABLE void | ||
| sendPreeditString(const QString& text, int32_t cursorBegin = -1, int32_t cursorEnd = -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation generator doesn't properly support default args, so probably make two forms of this: sendPreeditString(text, begin, end), sendPreeditString(text)
| /// @@hasKeyboard$ | ||
| Q_INVOKABLE [[nodiscard]] bool hasKeyboard() const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Property getters dont need to be invokable
|
|
||
| key += WAYLAND_KEY_OFFSET; | ||
|
|
||
| #if INPUT_METHOD_PRINT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am glad you added logs but instead of ifdefing them, use logging categories (grep for QS_LOGGING_CATEGORY and qCDebug)
| InputMethodManager* InputMethodManager::instance() { | ||
| // The OS should free this memory when we exit | ||
| static auto* instance = new InputMethodManager(); | ||
| return instance; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment is unnnecessary.
Return nullptr when not initialized.
| void InputMethod::sendString(const QString& text) { | ||
| if (!this->isActive()) return; | ||
|
|
||
| this->handle->commitString(text); | ||
| this->handle->commit(); | ||
| } | ||
|
|
||
| void InputMethod::sendPreeditString(const QString& text, int32_t cursorBegin, int32_t cursorEnd) { | ||
| if (!this->isActive()) return; | ||
|
|
||
| this->handle->sendPreeditString(text, cursorBegin, cursorEnd); | ||
| this->handle->commit(); | ||
| } | ||
|
|
||
| void InputMethod::deleteText(int before, int after) { | ||
| if (!this->isActive()) return; | ||
|
|
||
| this->handle->deleteText(before, after); | ||
| this->handle->commit(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer commit to be separated for this one. The pre-edit string and cursor region may be better exposed as properties instead of a function as well.
| QQmlComponent* InputMethod::keyboardComponent() const { return this->mKeyboardComponent; } | ||
| void InputMethod::setKeyboardComponent(QQmlComponent* keyboardComponent) { | ||
| if (this->mKeyboardComponent == keyboardComponent) return; | ||
| this->mKeyboardComponent = keyboardComponent; | ||
| emit this->keyboardComponentChanged(); | ||
|
|
||
| if (this->keyboard) { | ||
| this->keyboard->deleteLater(); | ||
| this->keyboard = nullptr; | ||
| } | ||
|
|
||
| this->handleKeyboardActive(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are components even involved in this? Shouldn't we just expose the keyboard as a member of the inputmethod which is null if we haven't grabbed it?
| QString QMLContentHint::toString(Enum contentHint) { | ||
| QString string = ""; | ||
|
|
||
| bool first = true; | ||
|
|
||
| if (contentHint & Completion) { | ||
| if (!first) { | ||
| string += " | "; | ||
| } | ||
| string += "Completion"; | ||
| first = false; | ||
| } | ||
| if (contentHint & Spellcheck) { | ||
| if (!first) { | ||
| string += " | "; | ||
| } | ||
| string += "Spellcheck"; | ||
| first = false; | ||
| } | ||
| if (contentHint & AutoCapitalization) { | ||
| if (!first) { | ||
| string += " | "; | ||
| } | ||
| string += "AutoCapitalization"; | ||
| first = false; | ||
| } | ||
| if (contentHint & Lowercase) { | ||
| if (!first) { | ||
| string += " | "; | ||
| } | ||
| string += "Lowercase"; | ||
| first = false; | ||
| } | ||
| if (contentHint & Uppercase) { | ||
| if (!first) { | ||
| string += " | "; | ||
| } | ||
| string += "Uppercase"; | ||
| first = false; | ||
| } | ||
| if (contentHint & Titlecase) { | ||
| if (!first) { | ||
| string += " | "; | ||
| } | ||
| string += "Titlecase"; | ||
| first = false; | ||
| } | ||
| if (contentHint & HiddenText) { | ||
| if (!first) { | ||
| string += " | "; | ||
| } | ||
| string += "HiddenText"; | ||
| first = false; | ||
| } | ||
| if (contentHint & SensitiveData) { | ||
| if (!first) { | ||
| string += " | "; | ||
| } | ||
| string += "SensitiveData"; | ||
| first = false; | ||
| } | ||
| if (contentHint & Latin) { | ||
| if (!first) { | ||
| string += " | "; | ||
| } | ||
| string += "Latin"; | ||
| first = false; | ||
| } | ||
| if (contentHint & Multiline) { | ||
| if (!first) { | ||
| string += " | "; | ||
| } | ||
| string += "Multiline"; | ||
| first = false; | ||
| } | ||
|
|
||
| if (string == "") string = "None"; | ||
| return string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make a list and join it instead of if (!first)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Might be better to split this
- Include from w-p instead?
Popup surfaceThis PR is already large, will add in future PR.Do we want to also expose the virtual keyboard so people can create their own clients?Popup surface and qml virtual keyboard will be in future PRs.