Fixes #5274 - Avoid duplicate ScreenChanged from Application.Screen setter#5404
Merged
Conversation
Agent-Logs-Url: https://github.com/gui-cs/Terminal.Gui/sessions/7c2215a2-9496-4b1e-96cd-f025e1298332 Co-authored-by: tig <585482+tig@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix application.Screen setter hanging on headless Windows CI
Fixes #issue. Avoid duplicate ScreenChanged from Application.Screen setter
May 25, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a duplicate ScreenChanged raise when setting IApplication.Screen in fullscreen mode by ensuring the setter follows the same path as IDriver.SetScreenSize(...), relying on the existing driver SizeChanged pipeline to invalidate layout and raise ScreenChanged exactly once.
Changes:
- Updated
ApplicationImpl.Screensetter to avoid explicitly raisingScreenChangedin fullscreen mode and instead rely onDriver_SizeChanged. - Added a regression test ensuring
app.Screen = ...beforeBegin(...)raisesScreenChangedexactly once and updatesapp.Screen. - Updated
IApplication.ScreenXML docs to describe fullscreen behavior and recommended testing approach.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Tests/UnitTestsParallelizable/Application/ScreenTests.cs | Adds regression coverage for single ScreenChanged raise when setting Screen pre-Begin(...). |
| Terminal.Gui/App/IApplication.cs | Documents that fullscreen Screen setter delegates to IDriver.SetScreenSize(...) and suggests using it in tests. |
| Terminal.Gui/App/ApplicationImpl.Screen.cs | Removes the extra explicit ScreenChanged raise in fullscreen mode; relies on Driver_SizeChanged to raise/invalidate once. |
Add a test verifying that ScreenChanged fires correctly when Screen is set before Driver is initialized (Driver is null). Update the XML doc remark on IApplication.Screen to accurately document the Driver != null guard behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
BDisp
approved these changes
May 25, 2026
Collaborator
BDisp
left a comment
There was a problem hiding this comment.
LGTM. Only to remember the XML warnings.
The cref referenced Init(string?,string?) but the actual signature is Init(string?). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced May 28, 2026
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.
Proposed Changes/Todos
The fullscreen
Application.Screensetter took a different path thanDriver.SetScreenSize (...): it resized through the driver, then re-readScreenand raisedScreenChangedagain. That extra work was enough to diverge from the known-safe test path used on CI.Setter/event path
Application.Screennow delegates toDriver.SetScreenSize (...)and relies on the existingDriver_SizeChangedpath to raiseScreenChangedand invalidate layout exactly once.Regression coverage
Begin (...)usage that verifiesapp.Screen = new Rectangle (...)raisesScreenChangedonce and updates the effective screen size.API guidance
IApplication.Screendocs to call out that fullscreenScreendelegates toIDriver.SetScreenSize (...).Driver.SetScreenSize (...), matchingAppTestHelper.ResizeConsole (...).Pull Request checklist:
CTRL-K-Dto automatically reformat your files before committing.dotnet testbefore commit///style comments)