Skip to content

Commit 2f0cc6f

Browse files
Merge pull request #17759 from laarmen/default-dpi-broken-screens
uiconfiguration: fix DPI for bad screen metadata
2 parents 9bc47d3 + 886ca9e commit 2f0cc6f

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 && physicalSize.width() <= 1) {
654661
return DEFAULT_DPI;
655662
}
656663

0 commit comments

Comments
 (0)