Set main display power for virtual display
Change the display power of the main display when mirroring a virtual display, to make it possible to turn off the screen. Fixes #5522 <https://github.com/Genymobile/scrcpy/issues/5522>
This commit is contained in:
parent
74aecc00b5
commit
a9ed7df7ff
@ -207,13 +207,15 @@ public final class CleanUp {
|
||||
}
|
||||
}
|
||||
|
||||
if (displayId != Device.DISPLAY_ID_NONE && Device.isScreenOn(displayId)) {
|
||||
// Change the display power of the main display when mirroring a virtual display
|
||||
int targetDisplayId = displayId != Device.DISPLAY_ID_NONE ? displayId : 0;
|
||||
if (Device.isScreenOn(targetDisplayId)) {
|
||||
if (powerOffScreen) {
|
||||
Ln.i("Power off screen");
|
||||
Device.powerOffScreen(displayId);
|
||||
Device.powerOffScreen(targetDisplayId);
|
||||
} else if (restoreDisplayPower) {
|
||||
Ln.i("Restoring display power");
|
||||
Device.setDisplayPower(displayId, true);
|
||||
Device.setDisplayPower(targetDisplayId, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -281,7 +281,7 @@ public class Controller implements AsyncProcessor, VirtualDisplayListener {
|
||||
setClipboard(msg.getText(), msg.getPaste(), msg.getSequence());
|
||||
break;
|
||||
case ControlMessage.TYPE_SET_DISPLAY_POWER:
|
||||
if (supportsInputEvents && displayId != Device.DISPLAY_ID_NONE) {
|
||||
if (supportsInputEvents) {
|
||||
setDisplayPower(msg.getOn());
|
||||
}
|
||||
break;
|
||||
@ -691,7 +691,9 @@ public class Controller implements AsyncProcessor, VirtualDisplayListener {
|
||||
}
|
||||
|
||||
private void setDisplayPower(boolean on) {
|
||||
boolean setDisplayPowerOk = Device.setDisplayPower(displayId, on);
|
||||
// Change the display power of the main display when mirroring a virtual display
|
||||
int targetDisplayId = displayId != Device.DISPLAY_ID_NONE ? displayId : 0;
|
||||
boolean setDisplayPowerOk = Device.setDisplayPower(targetDisplayId, on);
|
||||
if (setDisplayPowerOk) {
|
||||
keepDisplayPowerOff = !on;
|
||||
Ln.i("Device display turned " + (on ? "on" : "off"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user