Use natural device orientation for --new-display

If no size is provided with --new-display, the main display size is
used. But the actual size depended on the current device orientation.

To make it deterministic, use the size of the natural device orientation
(portrait for phones, landscape for tablets).
This commit is contained in:
Romain Vimont 2024-11-15 18:46:08 +01:00
parent 7d96684297
commit 21ceff6d45

View File

@ -80,6 +80,9 @@ public class NewDisplayCapture extends SurfaceCapture {
DisplayInfo displayInfo = ServiceManager.getDisplayManager().getDisplayInfo(0); DisplayInfo displayInfo = ServiceManager.getDisplayManager().getDisplayInfo(0);
if (displayInfo != null) { if (displayInfo != null) {
mainDisplaySize = displayInfo.getSize(); mainDisplaySize = displayInfo.getSize();
if ((displayInfo.getRotation() % 2) != 0) {
mainDisplaySize = mainDisplaySize.rotate(); // Use the natural device orientation (at rotation 0), not the current one
}
mainDisplayDpi = displayInfo.getDpi(); mainDisplayDpi = displayInfo.getDpi();
} else { } else {
Ln.w("Main display not found, fallback to 1920x1080 240dpi"); Ln.w("Main display not found, fallback to 1920x1080 240dpi");