Skip to content

Commit

Permalink
The input method mode should be set physical keyboard when necessary (#…
Browse files Browse the repository at this point in the history
…1087)

If the virtual keyboard should not show automatically, then the input
method mode should be set physical keyboard when the user closes
the virtual  keyboard by interacting with the virtual keyboard itself.
For example, if the user clicks a close button in the virtual keyboard
or clicks an icon in the task bar or a float button on the desktop which
can close the virtual keyboard, then the virtual keyboard will be closed
and the input method mode should be set physical keyboard.
  • Loading branch information
kingysu authored Dec 4, 2024
1 parent 552f7d1 commit 389f3d7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/ui/virtualkeyboard/virtualkeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class VirtualKeyboardService

void showVirtualKeyboard() { parent_->showVirtualKeyboardForcibly(); }

void hideVirtualKeyboard() { parent_->hideVirtualKeyboard(); }
void hideVirtualKeyboard() { parent_->hideVirtualKeyboardForcibly(); }

void toggleVirtualKeyboard() { parent_->toggleVirtualKeyboard(); }

Expand Down Expand Up @@ -325,13 +325,25 @@ void VirtualKeyboard::showVirtualKeyboardForcibly() {
showVirtualKeyboard();
}

void VirtualKeyboard::hideVirtualKeyboardForcibly() {
if (!available_) {
return;
}

hideVirtualKeyboard();

if (!instance_->virtualKeyboardAutoShow()) {
instance_->setInputMethodMode(InputMethodMode::PhysicalKeyboard);
}
}

void VirtualKeyboard::toggleVirtualKeyboard() {
if (!available_) {
return;
}

if (visible_) {
hideVirtualKeyboard();
hideVirtualKeyboardForcibly();
} else {
showVirtualKeyboardForcibly();
}
Expand Down
1 change: 1 addition & 0 deletions src/ui/virtualkeyboard/virtualkeyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class VirtualKeyboard : public VirtualKeyboardUserInterface {
void hideVirtualKeyboard() override;

void showVirtualKeyboardForcibly();
void hideVirtualKeyboardForcibly();
void toggleVirtualKeyboard();

void updateInputPanel(InputContext *inputContext);
Expand Down

0 comments on commit 389f3d7

Please sign in to comment.