From d645823a9cf0575c690d66114cdb3c5960e02417 Mon Sep 17 00:00:00 2001 From: "kaiming.hu" Date: Mon, 5 Aug 2024 11:26:40 +0800 Subject: [PATCH] Fix incorrect capture when using DisplayManager API --- .../main/java/com/genymobile/scrcpy/video/ScreenCapture.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/src/main/java/com/genymobile/scrcpy/video/ScreenCapture.java b/server/src/main/java/com/genymobile/scrcpy/video/ScreenCapture.java index fbeca2af07..f82ff2f70e 100644 --- a/server/src/main/java/com/genymobile/scrcpy/video/ScreenCapture.java +++ b/server/src/main/java/com/genymobile/scrcpy/video/ScreenCapture.java @@ -51,6 +51,11 @@ public void start(Surface surface) { Rect videoRect = screenInfo.getVideoSize().toRect(); virtualDisplay = ServiceManager.getDisplayManager() .createVirtualDisplay("scrcpy", videoRect.width(), videoRect.height(), device.getDisplayId(), surface); + // 'createVirtualDisplay' will copy the configuration of the original display (including the rotation), + // but 'videoRect' is already rotated according to the device rotation, + // so we need to freeze the rotation to 0 to avoid a double rotation + int displayId = virtualDisplay.getDisplay().getDisplayId(); + ServiceManager.getWindowManager().freezeRotation(displayId, 0); Ln.d("Display: using DisplayManager API"); } catch (Exception displayManagerException) { try {