Skip to content

fix(windows): let an activating titlebar click drag the window when a terminal had focus - #44380

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/Windows-issue
Nov 19, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/Windows-issue

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

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 as terminalFocused && !awaitingInputAfterWindowBlur.
    • A window blur starts the hold.
    • The first capture-phase pointerdown or keydown in the page ends it. Presses on drag regions never reach the page, so the activating titlebar drag keeps the hold.
    • The hold also starts at boot when the document has no focus.
  • 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, when document.hasFocus() is already true.

Terminal focus ownership, ui:setTerminalInputFocused shortcut 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/focusin to the still-active xterm helper textarea when the window activates. use-regular-terminal-input-focus then re-asserts the attribute, and Electron's draggable region flips from HTCAPTION to HTCLIENT under 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_NCHITTEST result 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).

Before (main) After (this PR)
titlebar-drag-before.png titlebar-drag-after.png

Probe at an empty tab-strip point (700,20), with window focus driven via CDP:

step before fix after fix
window unfocused, xterm is activeElement 2 = HTCAPTION 2 = HTCAPTION
window activates (xterm re-focused) 1 = HTCLIENT (press selects text) 2 = HTCAPTION (press drags)
click into terminal 1 = HTCLIENT 1 = HTCLIENT (#6301 preserved)
window blur 2 = HTCAPTION 2 = HTCAPTION

Testing

  • I manually tested these changes locally (Windows 11; hit-test probe above, before and after, on a background dev build)
  • Automated tests added/updated, or explained why not below
  • Every added test fails without this change and avoids the test anti-patterns

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 except localization catalogs, which fails locally only because of CRLF on this Windows checkout (core.autocrlf=true); regenerating protected-copy-keys.json produces 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.

… 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.
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The renderer now tracks window activation and page input for regular-terminal focus ownership. After a window blur, the focus attribute remains off until the first captured pointer or keyboard input. The focus-attribute setter initializes this tracking and applies the attribute only when terminal input is focused and no post-blur hold remains. Startup initializes the tracker after terminal IME focus-loss tracking.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 2aa44

This change keeps the titlebar draggable on the first press after the window is reactivated, even when a terminal had focus. No concrete defect was found and the added listeners are lightweight. Merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix and its trigger: an activating titlebar click should drag the window when a terminal had focus. The raw summary confirms the change adds window activation tracking that keeps t…
Linked Issues check Passed Issue #11319 requires a single press-and-drag on an empty title bar drag region to move the window after Orca was unfocused. At head, setRegularTerminalInputFocusAttribute applies `data-regular-term…
Out of Scope Changes check Passed Changes from merge base to head are limited to regular-terminal-focus-ownership.ts (new trackWindowActivationForTerminalDragRegions, hold flag, and attribute gating) and main.tsx (one import and…
Description check Passed The description is thorough and covers the template's core sections: ELI5, What Changed, Why, Linked Issue (Fixes #11319), Visual Proof (before/after hit-test images and a probe table), Testing with c…
Full details: Title check

Explanation

The title names the fix and its trigger: an activating titlebar click should drag the window when a terminal had focus. The raw summary confirms the change adds window activation tracking that keeps the titlebar draggable after blur until page input occurs. The title is specific and matches the main change. It uses the conventional fix(windows) prefix and fits within a typical length.

Full details: Linked Issues check

Explanation

Issue #11319 requires a single press-and-drag on an empty title bar drag region to move the window after Orca was unfocused. At head, setRegularTerminalInputFocusAttribute applies data-regular-terminal-input-focused only when regularTerminalInputFocused && !awaitingInputAfterWindowBlur. A window blur sets the hold. The first capture-phase pointerdown or keydown clears it. Because the attribute drives the -webkit-app-region: no-drag rule on the titlebar, the activating drag keeps the drag region active. The hold also starts at boot when document.hasFocus() is false. main.tsx installs the tracker at startup. The fix covers the case where a terminal had focus before the window lost focus. The issue also describes the non-terminal case, where the attribute is never set, so this PR does not change that path. The author's Windows 11 WM_NCHITTEST results (HTCAPTION after activation) support the behavior, but they come from a hidden background window and were not independently re-run here. No automated test covers the behavior. This is a reasonable coding basis for the issue. No coding requirement is unmet in the evidence.

Full details: Out of Scope Changes check

Explanation

Changes from merge base to head are limited to regular-terminal-focus-ownership.ts (new trackWindowActivationForTerminalDragRegions, hold flag, and attribute gating) and main.tsx (one import and one startup call next to trackPageFocusLossForTerminalIme). The new logic directly implements the #11319 drag fix. The existing focus-ownership, IME, and zoom functions are unchanged in the reviewed code, and the PR description states they do not read the attribute. No unrelated change was found.

Full details: Description check

Explanation

The description is thorough and covers the template's core sections: ELI5, What Changed, Why, Linked Issue (Fixes #11319), Visual Proof (before/after hit-test images and a probe table), Testing with checkboxes and reasons for no automated test, and Risk with level Low and a back-out plan. Gaps: the AI Disclosure section is absent (it is optional for maintainers, and the author appears to be a team member, so this is minor). The Review and Agent skill upstream boundary sections are not filled in, and the Checklist is not ticked. Also, the Visual Proof uses a hidden background window and the author states physical drag was not tested, which is disclosed. Overall the description is mostly complete.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d5e84f69-4afa-41c2-b6c5-af77e491cc5c
Commits

Reviewing files that changed from the base of the PR and between 73169dd and 2aa44db.

Files selected for processing: 2

  • src/renderer/src/components/terminal-pane/input/focus/regular-terminal-focus-ownership.ts
  • src/renderer/src/main.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

@OrcaWin
OrcaWin merged commit 7f268df into main Nov 19, 2026
39 checks passed
@OrcaWin
OrcaWin deleted the OrcaWin/Windows-issue branch November 19, 2026 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Usability]: Title bar drag requires an extra click before the window moves (Windows always; macOS intermittent)

1 participant