Repository navigation
test(ui): the title-bar focus-loss drag test moves the pointer only once the focus loss has ended the drag (#2901) - #2940
Merged
Conversation
…nce the focus loss has ended the drag (#2901) The driver pushed the press and the focus loss together with the pointer already held at the drag's target. Application's event drain stops at DRAIN_BUDGET_MS (8 ms), so under ctest's parallel load the press could be handled in one frame and the focus loss in the next. TitleBarLayer's onUpdate stepped the drag in between, moved the window, and the driver never needed the press it retries: pressRetries stayed 0. The driver now holds the pointer still at the press point and watches its own onSDLEvent (it runs after TitleBarLayer's) for the press and then the focus loss. Only once both are handled does the pointer move on, so the window can move only through a press made again, however the frames split the events. The test also asserts the focus loss was delivered. With a zero drain budget forcing the split, the old test failed 5/5 with the CI message; the new one passes, and still fails when TitleBarLayer ignores the focus loss. Fixes #2901 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
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.
Description
UiLayersOnDisplayTest.TitleBarDragStepSurvivesAFocusLossRightAfterThePresssometimes sawpressRetries == 0under ctest's parallel load on windows-2025 debug.Root cause (test timing, not a product bug): on the first press, the driver pushed
SDL_EVENT_MOUSE_BUTTON_DOWNand thenSDL_EVENT_WINDOW_FOCUS_LOST, with the test pointer already held at the drag's target (+40, +30).Core::Application's event drain stops once it has usedDRAIN_BUDGET_MS(8 ms) and checks that after every event. Under load the drain could stop right after the press, soTitleBarLayer::onUpdatestepped the drag that frame and moved the window. The focus loss then ended a drag that had already done its job, the window counted as moved, and the retry never ran. #2925/#2935 aren't involved: this driver never moves the OS cursor and never warps.Fix (harness only): with
loseFocusAfterFirstPress, the driveronSDLEvent, which runs afterTitleBarLayer's, for the press and then the focus loss;RETRY_EVERYwait from there.After that, only a press made again can move the window, however the frames split the events. The test still asserts
movedByDragandpressRetries >= 1. It now also assertsfocusLossDeliveredand recordspressRetriesas a property.The test proves as much as before. With
TitleBarLayertemporarily changed to ignoreSDL_EVENT_WINDOW_FOCUS_LOST, the new test fails (pressRetries0), because the surviving drag moves the window with no retry.Fixes #2901
PR Size
Small: 1 file, +65/-4 (test only).
Type of Change
Checklist
clang-tidyand addressed any warnings (nothing on the changed lines; the local LLVM reports only untouched lines and MSVC STL headers)clang-formaton my changespre-commit run --all-filesor installed pre-commit hooks (pre-commit run --fileson the touched file, plus the commit hook)Testing
Windows 11,
win-debug,TASKSMACK_REQUIRE_DISPLAY=1:DRAIN_BUDGET_MStemporarily set to 0 (one event per frame, so the press and the focus loss always land in different frames), the old test failed 5/5 with CI's exact message (Expected: (observed.pressRetries) >= (1), actual: 0 vs 1). The new test passed 5/5 with the other two drag tests.TitleBarLayer's focus-loss handling turned off, the new test fails 3/3.ctest --preset win-debug -R "^UiLayersOnDisplayTest$" --repeat until-fail:30passed, 30/30 runs of the whole suite.UiLayersOnDisplayTestandUiScenarioTestonce each: both passed.Additional Notes
The drain budget itself is right: it caps how long a stalled poll can hold a frame (#1410). A real focus loss between the press and the first step ends the drag either way, so the product's behaviour doesn't change. Only the test's assumption that the two pushed events share a frame was wrong.
🤖 Generated with Claude Code