Skip to content

Commit

Permalink
fix window resize on DPI changes
Browse files Browse the repository at this point in the history
This commit fixes #7678 and likely fixes #7447 too.  On Windows, when
the screen is changed to one with a different scaling setting the window
is being incorrectly resized.  This can be worked around by storing the
window's size before moving it to a different screen, and then resizing
the window again.

Signed-off-by: Jyrki Gadinger <[email protected]>
  • Loading branch information
nilsding committed Jan 13, 2025
1 parent 9d860d0 commit 953d424
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/gui/systray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,11 +588,18 @@ void Systray::setSyncIsPaused(const bool syncIsPaused)

void Systray::positionWindowAtTray(QQuickWindow *window) const
{
if (!useNormalWindow()) {
window->setScreen(currentScreen());
const auto position = computeWindowPosition(window->width(), window->height());
window->setPosition(position);
if (useNormalWindow()) {
return;
}

// need to store the current window size before moving the window to another screen,
// otherwise it is being incorrectly resized by the OS or Qt when switching to a screen
// with a different DPI setting
const auto initialSize = window->size();
const auto position = computeWindowPosition(initialSize.width(), initialSize.height());
window->setPosition(position);
window->setScreen(currentScreen());
window->resize(initialSize);
}

void Systray::positionWindowAtScreenCenter(QQuickWindow *window) const
Expand Down

0 comments on commit 953d424

Please sign in to comment.