Skip to content

Commit 222bf10

Browse files
committed
uiconfiguration: fix DPI for bad screen metadata
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 #16002.
1 parent 15d6c8b commit 222bf10

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/framework/ui/internal/uiconfiguration.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,9 +648,16 @@ double UiConfiguration::physicalDpi() const
648648
return m_customDPI.value();
649649
}
650650

651+
constexpr double DEFAULT_DPI = 96;
651652
const QScreen* screen = mainWindow() ? mainWindow()->screen() : nullptr;
652653
if (!screen) {
653-
constexpr double DEFAULT_DPI = 96;
654+
return DEFAULT_DPI;
655+
}
656+
657+
auto physicalSize = screen->physicalSize();
658+
// Work around xrandr reporting a 1x1mm size if
659+
// the screen doesn't have a valid physical size
660+
if (physicalSize.height() <= 1 and physicalSize.width() <= 1) {
654661
return DEFAULT_DPI;
655662
}
656663

0 commit comments

Comments
 (0)