Repository navigation
fix(windows): let an activating titlebar click drag the window when a terminal had focus - #44380
Conversation
… terminal had focus xterm regains DOM focus when the window activates, which set data-regular-terminal-input-focused and turned the titlebar no-drag under the activating click, so Windows delivered it as a client press and the drag selected tab-strip text. Hold the drag-suppression attribute after a window blur until the user presses or types inside the page.
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
ELI5
When a terminal is focused, Orca turns the titlebar into a normal clickable area. That way a click on the chrome can take focus back from the terminal and hand zoom back to the app. When you switch back to Orca, the terminal gets focus again before your click lands, so the titlebar has already stopped being draggable. Your press-and-drag then selects text ("Command") instead of moving the window. This PR keeps the titlebar draggable after Orca regains focus until you actually click or type inside the window.
What Changed
regular-terminal-focus-ownership.ts:data-regular-terminal-input-focused(CSS-only; it flips the titlebar, tab strip, and right-sidebar header to-webkit-app-region: no-drag) is now written asterminalFocused && !awaitingInputAfterWindowBlur.blurstarts the hold.pointerdownorkeydownin the page ends it. Presses on drag regions never reach the page, so the activating titlebar drag keeps the hold.main.tsx: installs the tracker at startup, next to the existing IME focus-loss tracker. If it were installed lazily, the first write could happen during the activation focus event itself, whendocument.hasFocus()is already true.Terminal focus ownership,
ui:setTerminalInputFocusedshortcut routing, and zoom targeting are unchanged; they don't read the attribute.Before: switch away from Orca (with a terminal focused) → press-and-drag the empty tab strip → text selection, the window doesn't move. A second press drags.
After: the first press-and-drag moves the window. Clicking into the terminal restores the #6301 behavior: a chrome click releases terminal focus.
Why
Root cause, reproduced on Windows 11 (see Testing): Chromium re-dispatches
focus/focusinto the still-active xterm helper textarea when the window activates.use-regular-terminal-input-focusthen re-asserts the attribute, and Electron's draggable region flips fromHTCAPTIONtoHTCLIENTunder the activating click.Alternatives considered:
Waiting for real page input keeps both behaviors.
Linked Issue
Fixes #11319
Related: #17425 covers the first press on the tab strip while Orca is already focused. That is the deliberate #6301 trade-off and this PR does not change it.
Visual Proof
Windows 11, background dev build. The overlay paints the native
WM_NCHITTESTresult for every titlebar point, sampled right after the Orca window re-activates with a terminal focused. Green =HTCAPTION(a press drags the window); red =HTCLIENT(the press goes to the page).HTCLIENT. Because the page owns the press, the screenshot replays the user's press-and-drag through the page from the empty tab strip, which selects "Command", the exact symptom reported in [Usability]: Title bar drag requires an extra click before the window moves (Windows always; macOS intermittent) #11319.HTCAPTION, so the activating press drags the window. Tabs, buttons and window controls stay clickable (red), as intended.Probe at an empty tab-strip point (700,20), with window focus driven via CDP:
activeElementTesting
No automated test added: the behavior depends on native window activation plus Electron drag-region hit-testing. A jsdom test would only assert DOM event wiring.
Not exercised: a physical mouse press-and-drag on a visible window. Validation stayed on a hidden background window so the desktop wasn't taken over. Worth a quick manual check on Windows: focus a terminal, alt-tab away, then press-and-drag the empty tab strip.
pnpm tc:web, oxlint, oxfmt: clean.pnpm check:changed: everything passes exceptlocalization catalogs, which fails locally only because of CRLF on this Windows checkout (core.autocrlf=true); regeneratingprotected-copy-keys.jsonproduces no content diff.Risk
Level: Low
CSS attribute timing only; it's cross-platform but behaves the same on macOS/Linux. Worst case: right after re-activation, before any click or keypress in the page, a press on the titlebar drags the window instead of releasing terminal focus for zoom. That is the pre-#6301 behavior for one gesture. Back out with a plain revert.