Set displayId to NONE in Options on new display
If a new display is set, force options.getDisplayId() to return Device.DISPLAY_ID_NONE, to avoid any confusion between a local displayId and options.getDisplayId().
This commit is contained in:
parent
5e10c37f02
commit
794595e3f0
@ -25,13 +25,13 @@ public final class CleanUp {
|
|||||||
|
|
||||||
private Thread thread;
|
private Thread thread;
|
||||||
|
|
||||||
private CleanUp(int displayId, Options options) {
|
private CleanUp(Options options) {
|
||||||
thread = new Thread(() -> runCleanUp(displayId, options), "cleanup");
|
thread = new Thread(() -> runCleanUp(options), "cleanup");
|
||||||
thread.start();
|
thread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CleanUp start(int displayId, Options options) {
|
public static CleanUp start(Options options) {
|
||||||
return new CleanUp(displayId, options);
|
return new CleanUp(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void interrupt() {
|
public void interrupt() {
|
||||||
@ -42,7 +42,7 @@ public final class CleanUp {
|
|||||||
thread.join();
|
thread.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runCleanUp(int displayId, Options options) {
|
private void runCleanUp(Options options) {
|
||||||
boolean disableShowTouches = false;
|
boolean disableShowTouches = false;
|
||||||
if (options.getShowTouches()) {
|
if (options.getShowTouches()) {
|
||||||
try {
|
try {
|
||||||
@ -93,6 +93,7 @@ public final class CleanUp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean powerOffScreen = options.getPowerOffScreenOnClose();
|
boolean powerOffScreen = options.getPowerOffScreenOnClose();
|
||||||
|
int displayId = options.getDisplayId();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
run(displayId, restoreStayOn, disableShowTouches, powerOffScreen, restoreScreenOffTimeout);
|
run(displayId, restoreStayOn, disableShowTouches, powerOffScreen, restoreScreenOffTimeout);
|
||||||
|
@ -479,6 +479,11 @@ public class Options {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.newDisplay != null) {
|
||||||
|
assert options.displayId == 0 : "Must not set both displayId and newDisplay";
|
||||||
|
options.displayId = Device.DISPLAY_ID_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,11 +103,8 @@ public final class Server {
|
|||||||
|
|
||||||
CleanUp cleanUp = null;
|
CleanUp cleanUp = null;
|
||||||
|
|
||||||
NewDisplay newDisplay = options.getNewDisplay();
|
|
||||||
int displayId = newDisplay == null ? options.getDisplayId() : Device.DISPLAY_ID_NONE;
|
|
||||||
|
|
||||||
if (options.getCleanup()) {
|
if (options.getCleanup()) {
|
||||||
cleanUp = CleanUp.start(displayId, options);
|
cleanUp = CleanUp.start(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
int scid = options.getScid();
|
int scid = options.getScid();
|
||||||
@ -131,7 +128,7 @@ public final class Server {
|
|||||||
|
|
||||||
if (control) {
|
if (control) {
|
||||||
ControlChannel controlChannel = connection.getControlChannel();
|
ControlChannel controlChannel = connection.getControlChannel();
|
||||||
controller = new Controller(displayId, controlChannel, cleanUp, options.getClipboardAutosync(), options.getPowerOn());
|
controller = new Controller(options.getDisplayId(), controlChannel, cleanUp, options.getClipboardAutosync(), options.getPowerOn());
|
||||||
asyncProcessors.add(controller);
|
asyncProcessors.add(controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,11 +158,12 @@ public final class Server {
|
|||||||
options.getSendFrameMeta());
|
options.getSendFrameMeta());
|
||||||
SurfaceCapture surfaceCapture;
|
SurfaceCapture surfaceCapture;
|
||||||
if (options.getVideoSource() == VideoSource.DISPLAY) {
|
if (options.getVideoSource() == VideoSource.DISPLAY) {
|
||||||
|
NewDisplay newDisplay = options.getNewDisplay();
|
||||||
if (newDisplay != null) {
|
if (newDisplay != null) {
|
||||||
surfaceCapture = new NewDisplayCapture(controller, newDisplay, options.getMaxSize());
|
surfaceCapture = new NewDisplayCapture(controller, newDisplay, options.getMaxSize());
|
||||||
} else {
|
} else {
|
||||||
assert displayId != Device.DISPLAY_ID_NONE;
|
assert options.getDisplayId() != Device.DISPLAY_ID_NONE;
|
||||||
surfaceCapture = new ScreenCapture(controller, displayId, options.getMaxSize(), options.getCrop(),
|
surfaceCapture = new ScreenCapture(controller, options.getDisplayId(), options.getMaxSize(), options.getCrop(),
|
||||||
options.getLockVideoOrientation());
|
options.getLockVideoOrientation());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user