Skip to content

win32: confirm tab-strip closes and support middle-click - #20

Open
alihandroid wants to merge 1 commit into
shiweis:mainfrom
alihandroid:feat/windows-tab-middle-click
Open

alihandroid wants to merge 1 commit into
shiweis:mainfrom
alihandroid:feat/windows-tab-middle-click

Conversation

@alihandroid

Copy link
Copy Markdown

Summary

Add middle-click tab closing to Windows, matching the interaction already available in Ghostty's native macOS tabs and GTK tab bar. This lets users close a tab without selecting it or targeting its smaller X button.

The new gesture and the existing X button use the same split-aware confirmation path as Tab Overview. Previously, the strip's X button called closeTabByIndex directly and bypassed that protection. This PR adds the missing gesture and makes both strip close actions honor confirm-close-surface.

Behavior

  • Middle-click a tab to close it and all its splits, without selecting an inactive tab first.
  • Both middle-click and the X button follow confirm-close-surface. If any split requires confirmation, show one dialog for the whole tab; Cancel preserves all its sessions.
  • Ignore middle-clicks on the new-tab button or outside the visible tab strip.
  • Keep middle-click behavior inside terminal content unchanged.

Implementation

Ghostty's macOS and GTK frontends get the gesture from their native tab widgets; the custom Win32 strip needs an explicit mouse handler. The overview and both strip gestures now share requestCloseTab, renamed from requestCloseOverviewTab. After confirmation, it re-resolves the target by surface ID so a process exit during the dialog cannot close a different tab.

Middle-click closes on button-down; release and double-click messages do not close another tab. Tab removal and active-tab selection retain their existing behavior.

Verification

  • Windows x64 GNU build passed.
  • test_tab_bar.ps1 -Case all: 67 checks passed across 29 app runs, covering the existing opaque, transparent, and light cases plus the new closing scenarios.
  • test_tab_overview.ps1: 12 checks passed.
  • Targeted Zig tests for tab overview passed; Zig formatting passed.

Regression coverage includes an idle focused split with a running non-focused split, process exits during confirmation, final-tab shutdown, and double-click sequencing. Tests use PID-validated HWNDs without desktop-global input.

Close tabs from the strip with a middle-button press without selecting
an inactive tab first. Route both middle-click and the existing X
button through the split-aware confirmation path used by the overview.

Rename the shared request method to reflect its wider use, preserving
stable surface identity across modal confirmation. Cover confirmation,
split processes, inactive-tab identity, and modal-time exits with native
HWND-scoped integration checks.
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.

1 participant