Skip to content

Commit

Permalink
Fix incorrect capture when using DisplayManager API
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiming.hu committed Aug 5, 2024
1 parent 44b3fd8 commit d645823
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d645823

Please sign in to comment.