Repository navigation
fix(gui): the Windows title bar answers as the caption, so Snap works again (#6825) - #6830
Open
nigelfenton wants to merge 1 commit into
Open
nigelfenton wants to merge 1 commit into
nigelfenton wants to merge 1 commit into
Conversation
… again (#6825). Principle VIII. Fixes #6825. ## What On Windows with the expanded client area, `MainWindow::nativeEvent` answered `WM_NCHITTEST` with the resize band at the edges and `HTCLIENT` everywhere else, so the 52 px title bar never reported `HTCAPTION`. Windows keys drag-to-edge Snap and the Snap Assist picker off that answer, so neither was offered: dragging the window to a screen edge did nothing. `expandedFrameHit()` gains a `Caption` hit and an opt-in `captionHeight`. `nativeEvent` passes the bar's height, scaled to the physical pixels `WM_NCHITTEST` works in, but only when `TitleBar::isSystemMoveAreaAt()` says the cursor is over the bar's empty background — the same test the bar's own drag already uses, so a point either starts a system move or stays client, never both. Answering `HTCAPTION` over the tabs, menus and caption buttons is what closed menus as they opened (#6272), and those keep reporting `HTCLIENT`. `captionHeight` defaults to 0, so every other caller is unchanged. `isSystemMoveAreaAt()` has been public and uncalled since #6198 removed the custom frame; this restores the `HTCAPTION` clause that #3069 added and #6198 dropped. ## Measured on Windows 11 (26300), AetherSDR 26.10.4, Qt 6.12 Hit test down the centre of the title bar, before and after: | offset from window top | before | after | Notepad (control) | |---|---|---|---| | +0..+7 px | HTTOP | HTTOP | HTTOP | | +8..+43 px | HTCLIENT | **HTCAPTION** | HTCAPTION | | +44 px and below | HTCLIENT | HTCLIENT | HTCLIENT | Scanning across the bar after the fix, the ☰ menu, the tab strip's controls and the caption buttons all still report `HTCLIENT`; only the empty background between them reports `HTCAPTION`. `WS_MAXIMIZEBOX` was already set (`applyWindowsCaptionStyles`), which is why Win+Left/Right always worked while the mouse drag did not — keyboard snap bypasses hit-testing. ## Tests `unified_title_bar_test` gains 10 assertions: the caption strip, its lower boundary, the resize band and corners still winning over it, the maximized case (the caption must answer or a maximized window cannot be dragged free), and that a 0 `captionHeight` leaves the old answer untouched. Verified they fail when the caption clause is disabled (3 fail, the rest pass). The suite's pre-existing "four radios fit whole in an 1800 px bar" failure on this machine is a font-metrics issue, confirmed identical on unmodified main. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6825.
What
On Windows with the expanded client area,
MainWindow::nativeEventansweredWM_NCHITTESTwith the resize band at the edges andHTCLIENTeverywhere else, so the 52 px title bar never reportedHTCAPTION. Windows keys drag-to-edge Snap and the Snap Assist picker off that answer, so neither was offered: dragging the window to a screen edge did nothing.expandedFrameHit()gains aCaptionhit and an opt-incaptionHeight.nativeEventpasses the bar's height, scaled to the physical pixelsWM_NCHITTESTworks in, but only whenTitleBar::isSystemMoveAreaAt()says the cursor is over the bar's empty background — the same test the bar's own drag already uses, so a point either starts a system move or stays client, never both. AnsweringHTCAPTIONover the tabs, menus and caption buttons is what closed menus as they opened (#6272), and those keep reportingHTCLIENT.captionHeightdefaults to 0, so every other caller is unchanged.isSystemMoveAreaAt()has been public and uncalled since #6198 removed the custom frame; this restores theHTCAPTIONclause that #3069 added and #6198 dropped.Measured on Windows 11 (26300), AetherSDR 26.10.4, Qt 6.12
Hit test down the centre of the title bar, before and after:
Scanning across the bar after the fix, the ☰ menu, the tab strip's controls and the caption buttons all still report
HTCLIENT; only the empty background between them reportsHTCAPTION. The caption ends at ~+43 rather than +52 becauseisSystemMoveAreaAt()reports the lower strip as occupied by widgets — the two mechanisms agreeing.WS_MAXIMIZEBOXwas already set (applyWindowsCaptionStyles), which is why Win+Left/Right always worked while the mouse drag did not — keyboard snap bypasses hit-testing. That asymmetry is what isolated the fault to hit-testing rather than window styles, and Win+Arrow is a usable workaround for anyone on a release before this lands.Relationship to existing issues
Same root cause as #6224 item W1 ("Snap Layouts hover (Windows 11). This is a known regression."), but W1 covers only the hover flyout over the maximize button. #6825 adds drag-to-edge and the Snap Assist picker. This PR fixes the drag and the picker; the
HTMAXBUTTONhalf of W1 is untouched and still open.The chrome landed in v26.10.2 (
5f09371e, PR #6198), not 26.10.4 as the issue title suggests — 26.10.4's onlyTitleBar.cppchange is the update badge, and the drag path is byte-identical to 26.10.3. Worth confirming with the reporter which version was last good.Tests
unified_title_bar_testgains 10 assertions: the caption strip, its lower boundary, the resize band and corners still winning over it, the maximized case (the caption must answer or a maximized window cannot be dragged free of the top of the screen), and that a 0captionHeightleaves the old answer untouched.Verified the tests bite: with the caption clause disabled, exactly 3 fail and the rest pass.
The suite has a pre-existing failure on this machine at "four radios fit whole in an 1800 px bar" — font metrics, confirmed identical on unmodified
mainby stashing this change and rebuilding. Because that masks the new assertions in the full binary, they were also run in a standalone harness that includes the realWindowChrome.h: 21/21 pass.Not verified
That the ☰ menu still opens and stays open under a real mouse click (the #6272 symptom). The hit-test scan covers the mechanism — the menu reports
HTCLIENT, so Qt handles the press — but a human click is the real proof. A reviewer on Windows 11 clicking the hamburger menu and dragging the bar to a screen edge would close that gap.🤖 Generated with Claude Code