From 513edf87bee9ca4ec9b528297b48bd4258988b45 Mon Sep 17 00:00:00 2001 From: liulinsong Date: Sat, 6 Jul 2024 16:25:11 +0800 Subject: [PATCH] The input method mode should be set physical keyboard when necessary 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. --- src/ui/virtualkeyboard/virtualkeyboard.cpp | 16 ++++++++++++++-- src/ui/virtualkeyboard/virtualkeyboard.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/ui/virtualkeyboard/virtualkeyboard.cpp b/src/ui/virtualkeyboard/virtualkeyboard.cpp index 01f72b2f1..6f3c05830 100644 --- a/src/ui/virtualkeyboard/virtualkeyboard.cpp +++ b/src/ui/virtualkeyboard/virtualkeyboard.cpp @@ -34,7 +34,7 @@ class VirtualKeyboardService void showVirtualKeyboard() { parent_->showVirtualKeyboardForcibly(); } - void hideVirtualKeyboard() { parent_->hideVirtualKeyboard(); } + void hideVirtualKeyboard() { parent_->hideVirtualKeyboardForcibly(); } void toggleVirtualKeyboard() { parent_->toggleVirtualKeyboard(); } @@ -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(); } diff --git a/src/ui/virtualkeyboard/virtualkeyboard.h b/src/ui/virtualkeyboard/virtualkeyboard.h index 92bff2f07..a94e096ac 100644 --- a/src/ui/virtualkeyboard/virtualkeyboard.h +++ b/src/ui/virtualkeyboard/virtualkeyboard.h @@ -40,6 +40,7 @@ class VirtualKeyboard : public VirtualKeyboardUserInterface { void hideVirtualKeyboard() override; void showVirtualKeyboardForcibly(); + void hideVirtualKeyboardForcibly(); void toggleVirtualKeyboard(); void updateInputPanel(InputContext *inputContext);