Repository navigation
[Win32] Adapt to a zoom change without exhausting native callbacks - #3897
Draft
HeikoKlare wants to merge 1 commit into
Draft
HeikoKlare wants to merge 1 commit into
HeikoKlare wants to merge 1 commit into
Conversation
When a shell moves to a monitor with another scaling, every control is adapted to the new zoom in a task of its own, scheduled as an OS timer with a native callback of its own. Native callbacks come from a small fixed pool shared by the whole application. A shell with more than about 250 controls, such as the Eclipse IDE, uses all of them up until the zoom change has been processed. Meanwhile, any code that needs a new native callback fails with "No more callbacks", for example creating an editable Combo, opening a MessageBox or ColorDialog, or the font fallback of a TextLayout. A zoom change now queues the adaptation of its controls and processes the queue with a single timer of the Display, which takes no native callback at all. The queue is processed in slices of at most 50 ms, between which the event loop handles other messages, as it did between the per-control timers. The controls are still adapted breadth-first, and the shell is still laid out once all of them have been adapted, also when the timer cannot be started, in which case the queue is processed right away. The time until a shell has settled after a monitor change is unchanged. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
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.
Problem
When a shell moves to a monitor with another scaling, every control is adapted to the new zoom in a task of its own, scheduled as an OS timer with a native callback of its own. Native callbacks come from a small fixed pool shared by the whole application. A shell with more than about 250 controls, such as the Eclipse IDE workbench window, uses all of them up until the zoom change has been processed. Meanwhile, any code that needs a new native callback fails with "No more callbacks", for example creating an editable
Combo, opening aMessageBoxorColorDialog, or the font fallback of aTextLayout.Solution
A zoom change now queues the adaptation of its controls and processes the queue with a single timer of the
Display, which takes no native callback at all. The queue is processed in slices of at most 50 ms, between which the event loop handles other messages, as it did between the per-control timers. The controls are still adapted breadth-first, and the shell is still laid out once all of them have been adapted. If the timer cannot be started, the queue is processed right away, so the zoom change still completes.Users should notice no difference, other than that other code no longer fails while a zoom change is processed. Moving an IDE-like shell with about 850 controls between a 100% and a 150% monitor took as long as before within the run-to-run spread, as the synchronous parts of a monitor change (Windows' own DPI handling, resizing the shell, the final layout) dominate.
The new tests adapt a shell with 1200 controls to a new zoom and create a native callback from the zoom changed listener of the last control, which fails on master with "No more callbacks", and simulate a timer that cannot be started to check that the zoom change still completes.
🤖 Generated with Claude Code