fix: show input method on mouse release when terminal has focus#548
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideEnsures the terminal widget explicitly shows the input method editor (IME) panel on mouse release when the terminal has focus by invoking QInputMethod, improving IME behavior after mouse interactions. Sequence diagram for showing IME on mouse release in terminal widgetsequenceDiagram
actor User
participant TerminalDisplay
participant QApplication as qApp
participant QInputMethod
User->>TerminalDisplay: mouseReleaseEvent(ev)
TerminalDisplay->>TerminalDisplay: mouseReleaseEvent(ev)
alt hasFocus()
TerminalDisplay->>qApp: inputMethod()
qApp-->>TerminalDisplay: QInputMethod*
TerminalDisplay->>QInputMethod: show()
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider guarding the
qApp->inputMethod()->show();call with a null check onqAppandinputMethod()to avoid potential crashes in edge cases where no input method is available. - If the IME should only be shown for text-related interactions, you may want to restrict the
inputMethod()->show()call to specific mouse buttons (e.g., left-click) rather than all mouse release events while focused.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider guarding the `qApp->inputMethod()->show();` call with a null check on `qApp` and `inputMethod()` to avoid potential crashes in edge cases where no input method is available.
- If the IME should only be shown for text-related interactions, you may want to restrict the `inputMethod()->show()` call to specific mouse buttons (e.g., left-click) rather than all mouse release events while focused.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Explicitly call inputMethod()->show() after mouse release to ensure the IME panel appears for text entry in the terminal widget. 在终端窗口拥有焦点时,鼠标释放后显式调用 inputMethod()->show(), 确保输入法面板能够正常弹出。 Log: 鼠标释放后显示输入法 Influence: 终端在获得焦点并点击鼠标后能正常唤起输入法,改善中文等输入法的使用体验。
deepin pr auto review★ 总体评分:85分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 diff --git a/3rdparty/terminalwidget/lib/TerminalDisplay.cpp b/3rdparty/terminalwidget/lib/TerminalDisplay.cpp
index f90950b3..194a66d0 100644
--- a/3rdparty/terminalwidget/lib/TerminalDisplay.cpp
+++ b/3rdparty/terminalwidget/lib/TerminalDisplay.cpp
@@ -2593,6 +2593,10 @@ void TerminalDisplay::mouseReleaseEvent(QMouseEvent* ev)
charLine + 1 +_scrollBar->value() -_scrollBar->maximum() , 2);
}
dragInfo.state = diNone;
+ // fix: 鼠标释放且获取焦点时,主动唤起虚拟输入法,解决点击终端后输入法不弹出的问题
+ if (hasFocus()) {
+ qApp->inputMethod()->show();
+ }
}
bool midClick = (ev->button() == MID_BTN); |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, wyu71 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Explicitly call inputMethod()->show() after mouse release to ensure the IME panel appears for text entry in the terminal widget.
在终端窗口拥有焦点时,鼠标释放后显式调用 inputMethod()->show(),
确保输入法面板能够正常弹出。
Log: 鼠标释放后显示输入法
Influence: 终端在获得焦点并点击鼠标后能正常唤起输入法,改善中文等输入法的使用体验。
Summary by Sourcery
Bug Fixes: