Skip to content

Commit

Permalink
uiconfiguration: fix DPI for bad screen metadata
Browse files Browse the repository at this point in the history
Some screens don't report their physical size in their EDID, for
instance the Samsung Neo G9 in its 5120x1440 configuration. When that
happens, on Linux xrandr reports the physical size as 1mmx1mm, which is
obviously invalid, and results in a computed DPI so high that the
default view is a totally blank screen, and the max zoomed-out level
still only covers a fraction of the score.

While it's possible for users to force the DPI via a command-line
argument, having a sensible default value to begin with is much better,
especially for nontechnical users.

While I only encountered the issue on Linux (due to not having Windows
available in the first place) I deliberately left the check on the
common codepath as I figured that a 1mm*1mm screen must be invalid no
matter the platform.

Fixes musescore#16002.
  • Loading branch information
laarmen committed May 28, 2023
1 parent 15d6c8b commit 886ca9e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/framework/ui/internal/uiconfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,9 +648,16 @@ double UiConfiguration::physicalDpi() const
return m_customDPI.value();
}

constexpr double DEFAULT_DPI = 96;
const QScreen* screen = mainWindow() ? mainWindow()->screen() : nullptr;
if (!screen) {
constexpr double DEFAULT_DPI = 96;
return DEFAULT_DPI;
}

auto physicalSize = screen->physicalSize();
// Work around xrandr reporting a 1x1mm size if
// the screen doesn't have a valid physical size
if (physicalSize.height() <= 1 && physicalSize.width() <= 1) {
return DEFAULT_DPI;
}

Expand Down

0 comments on commit 886ca9e

Please sign in to comment.