From fc69adfae4ae10ae8e95e8cae7d9e264ed9dd721 Mon Sep 17 00:00:00 2001 From: ETWen Date: Tue, 16 Jun 2026 16:24:37 +0800 Subject: [PATCH] fix(terminal): keep keyboard focus on terminal after activity (v0.3.3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The terminal's DarkScrollBar derives from Control, which is selectable by default. Once enough output accumulated to create scrollback, the scrollbar became enabled and was the only selectable child of the TerminalView (a ContainerControl). On window re-activation (minimize/restore, click away and back) WinForms restored focus down the container chain onto the scrollbar, which has no keyboard handling, so typing/Enter went nowhere until the session was reopened. This affected both Serial and PowerShell tabs (shared TerminalView), and only after output appeared — matching the reported symptom. Make the scrollbar mouse-only: SetStyle(Selectable, false) + TabStop=false, so it never takes keyboard focus and the TerminalView keeps focus itself, exactly as it already did when idle (scrollbar disabled). Bump version to 0.3.3 and add the About changelog entry. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/ETTerms/App/AboutView.cs | 5 +++++ src/ETTerms/ETTerms.csproj | 2 +- src/ETTerms/Terminal/DarkScrollBar.cs | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ETTerms/App/AboutView.cs b/src/ETTerms/App/AboutView.cs index 5ee9ef5..1d33b78 100644 --- a/src/ETTerms/App/AboutView.cs +++ b/src/ETTerms/App/AboutView.cs @@ -183,6 +183,11 @@ public sealed class AboutView : UserControl private static readonly ChangelogEntry[] Changelog = [ + new("0.3.3", new DateOnly(2026, 6, 16), "Bugfix — terminal input no longer dies after activity", + [ + "Fixed: after the terminal had printed output (Serial or PowerShell), switching away and back — minimizing, or clicking another window — left the terminal unable to accept any typing or Enter, forcing you to reopen the session.", + "Cause: once enough output scrolled by, the terminal's scrollbar could steal the keyboard focus when the window regained focus. The scrollbar is now mouse-only and never takes focus, so input keeps working.", + ]), new("0.3.2", new DateOnly(2026, 6, 11), "New Status page — control PDU outlets with buttons", [ "New Status page (the ⚡ icon on the left) with a PDU tab — connect to your PDU by IP and see every outlet at a glance.", diff --git a/src/ETTerms/ETTerms.csproj b/src/ETTerms/ETTerms.csproj index 104b812..ec62a04 100644 --- a/src/ETTerms/ETTerms.csproj +++ b/src/ETTerms/ETTerms.csproj @@ -10,7 +10,7 @@ ETTerms - 0.3.2 + 0.3.3 ETTerms ETTerms Project diff --git a/src/ETTerms/Terminal/DarkScrollBar.cs b/src/ETTerms/Terminal/DarkScrollBar.cs index c72a19d..f35f696 100644 --- a/src/ETTerms/Terminal/DarkScrollBar.cs +++ b/src/ETTerms/Terminal/DarkScrollBar.cs @@ -39,6 +39,11 @@ public sealed class DarkScrollBar : Control { SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true); + // 純滑鼠操作的捲軸,無任何鍵盤邏輯,絕不可吃鍵盤焦點:否則身為唯一可選取子控制項, + // 在 scrollback 出現(Enabled=true)後,視窗切走再切回時 WinForms 會把焦點還原到它身上, + // 導致 TerminalView 收不到鍵盤輸入(打字 / Enter 全失效),需重開 session 才恢復。 + SetStyle(ControlStyles.Selectable, false); + TabStop = false; Width = 12; BackColor = TrackColor; }