-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix engine size not being changed on DPI changes #12713
Conversation
// Don't actually resize if viewport dimensions didn't change | ||
if (vp.Height() == currentVP.Height() && vp.Width() == currentVP.Width()) | ||
{ | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the bug fix. The rest are "performance-restoration-refactorizations" to limit calls to _refreshSizeUnderLock
.
_actualFont = { fontFace, 0, fontWeight.Weight, { 0, fontHeight }, CP_UTF8, false }; | ||
_actualFontFaceName = { fontFace }; | ||
_desiredFont = { _actualFont }; | ||
const auto sizeChanged = _setFontSizeUnderLock(_settings->FontSize()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous code was a carbon copy of _setFontSize
and I've deduplicated the code.
The new _setFontSizeUnderLock
returns true
if _refreshSizeUnderLock
needs to be called. The old _setFontSize
was missing that check, so this is a fix to limit calls to _refreshSizeUnderLock
.
cx = std::max(cx, _actualFont.GetSize().X); | ||
cy = std::max(cy, _actualFont.GetSize().Y); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous code would just return early if the size was too small, but then we wouldn't call SetWindowSize
... So I turned it into a std::max
.
@DHowett A minimal change for 1.12: release-1.12...dev/lhecker/11317-dpi-change-fix-1.12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rewrite in C for Linux
void ControlCore::_setFontSize(int fontSize) | ||
// Return Value: | ||
// - Returns true if you need to call _refreshSizeUnderLock(). | ||
bool ControlCore::_setFontSizeUnderLock(int fontSize) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. So it's not doing it "under lock". It's saying that you should call this only if you're under a lock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, there's another function with a similar name pattern.
Hello @DHowett! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
Previously we would only call `SetWindowSize` and `TriggerRedrawAll` if the viewport size in characters changed. This commit removes the limitation. Since the if-condition limiting full redraws is now gone, this commit moves the responsibility of limiting the calls up the call chain. With `_refreshSizeUnderLock` now being a heavier function call than before, some surrounding code was thus refactored. ## PR Checklist * [x] Closes #11317 * [x] I work here * [x] Tests added/passed ## Validation Steps Performed Test relevant for #11317: * Print text, filling the entire window * Move the window from a 150% scale to a 300% scale monitor * The application works as expected ✅ Regression tests: * Text zoom with Ctrl+Plus/Minus/0 works as before ✅ * Resizing a window works as before ✅ * No deadlocks, etc. during settings updates ✅ (cherry picked from commit 9fa4169)
🎉 Handy links: |
🎉 Handy links: |
Previously we would only call
SetWindowSize
andTriggerRedrawAll
if theviewport size in characters changed. This commit removes the limitation.
Since the if-condition limiting full redraws is now gone, this commit
moves the responsibility of limiting the calls up the call chain.
With
_refreshSizeUnderLock
now being a heavier function callthan before, some surrounding code was thus refactored.
PR Checklist
Validation Steps Performed
Test relevant for #11317:
Regression tests: