Commit 3d5294c 1 parent 1d2f16d commit 3d5294c Copy full SHA for 3d5294c
File tree 2 files changed +11
-6
lines changed
server/src/main/java/com/genymobile/scrcpy
2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -207,13 +207,15 @@ public static void main(String... args) {
207
207
}
208
208
}
209
209
210
- if (displayId != Device .DISPLAY_ID_NONE && Device .isScreenOn (displayId )) {
210
+ // Change the power of the main display when mirroring a virtual display
211
+ int targetDisplayId = displayId != Device .DISPLAY_ID_NONE ? displayId : 0 ;
212
+ if (Device .isScreenOn (targetDisplayId )) {
211
213
if (powerOffScreen ) {
212
214
Ln .i ("Power off screen" );
213
- Device .powerOffScreen (displayId );
215
+ Device .powerOffScreen (targetDisplayId );
214
216
} else if (restoreDisplayPower ) {
215
217
Ln .i ("Restoring display power" );
216
- Device .setDisplayPower (displayId , true );
218
+ Device .setDisplayPower (targetDisplayId , true );
217
219
}
218
220
}
219
221
Original file line number Diff line number Diff line change @@ -281,7 +281,7 @@ private boolean handleEvent() throws IOException {
281
281
setClipboard (msg .getText (), msg .getPaste (), msg .getSequence ());
282
282
break ;
283
283
case ControlMessage .TYPE_SET_DISPLAY_POWER :
284
- if (supportsInputEvents && displayId != Device . DISPLAY_ID_NONE ) {
284
+ if (supportsInputEvents ) {
285
285
setDisplayPower (msg .getOn ());
286
286
}
287
287
break ;
@@ -691,9 +691,12 @@ private DisplayData waitDisplayData(long timeoutMillis) throws InterruptedExcept
691
691
}
692
692
693
693
private void setDisplayPower (boolean on ) {
694
- boolean setDisplayPowerOk = Device .setDisplayPower (displayId , on );
694
+ // Change the power of the main display when mirroring a virtual display
695
+ int targetDisplayId = displayId != Device .DISPLAY_ID_NONE ? displayId : 0 ;
696
+ boolean setDisplayPowerOk = Device .setDisplayPower (targetDisplayId , on );
695
697
if (setDisplayPowerOk ) {
696
- keepDisplayPowerOff = !on ;
698
+ // Do not keep display power off for virtual displays: MOD+p must wake up the physical device
699
+ keepDisplayPowerOff = displayId != Device .DISPLAY_ID_NONE && !on ;
697
700
Ln .i ("Device display turned " + (on ? "on" : "off" ));
698
701
if (cleanUp != null ) {
699
702
boolean mustRestoreOnExit = !on ;
You can’t perform that action at this time.
0 commit comments