mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-10-01 09:40:35 +13:00
Probably return error on cli open command
This commit is contained in:
parent
68b4cb2fcc
commit
45d3d40c6f
3 changed files with 12 additions and 6 deletions
|
@ -138,22 +138,23 @@ public abstract class OperationMode {
|
||||||
|
|
||||||
set(newMode);
|
set(newMode);
|
||||||
}
|
}
|
||||||
public static void switchToSyncIfPossible(OperationMode newMode) {
|
public static boolean switchToSyncIfPossible(OperationMode newMode) {
|
||||||
TrackEvent.info("Attempting to switch mode to " + newMode.getId());
|
TrackEvent.info("Attempting to switch mode to " + newMode.getId());
|
||||||
|
|
||||||
if (newMode.equals(TRAY) && !TRAY.isSupported()) {
|
if (newMode.equals(TRAY) && !TRAY.isSupported()) {
|
||||||
TrackEvent.info("Tray is not available, using base instead");
|
TrackEvent.info("Tray is not available, using base instead");
|
||||||
set(BACKGROUND);
|
set(BACKGROUND);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newMode.equals(GUI) && !GUI.isSupported()) {
|
if (newMode.equals(GUI) && !GUI.isSupported()) {
|
||||||
TrackEvent.info("Gui is not available, using base instead");
|
TrackEvent.info("Gui is not available, using base instead");
|
||||||
set(BACKGROUND);
|
set(BACKGROUND);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
set(newMode);
|
set(newMode);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,20 @@ package io.xpipe.app.exchange;
|
||||||
|
|
||||||
import io.xpipe.app.core.mode.OperationMode;
|
import io.xpipe.app.core.mode.OperationMode;
|
||||||
import io.xpipe.app.launcher.LauncherInput;
|
import io.xpipe.app.launcher.LauncherInput;
|
||||||
|
import io.xpipe.app.util.PlatformState;
|
||||||
import io.xpipe.beacon.BeaconHandler;
|
import io.xpipe.beacon.BeaconHandler;
|
||||||
|
import io.xpipe.beacon.ServerException;
|
||||||
import io.xpipe.beacon.exchange.OpenExchange;
|
import io.xpipe.beacon.exchange.OpenExchange;
|
||||||
|
|
||||||
public class OpenExchangeImpl extends OpenExchange
|
public class OpenExchangeImpl extends OpenExchange
|
||||||
implements MessageExchangeImpl<OpenExchange.Request, OpenExchange.Response> {
|
implements MessageExchangeImpl<OpenExchange.Request, OpenExchange.Response> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response handleRequest(BeaconHandler handler, Request msg) {
|
public Response handleRequest(BeaconHandler handler, Request msg) throws ServerException {
|
||||||
if (msg.getArguments().isEmpty()) {
|
if (msg.getArguments().isEmpty()) {
|
||||||
OperationMode.switchToAsync(OperationMode.GUI);
|
if (!OperationMode.switchToSyncIfPossible(OperationMode.GUI)) {
|
||||||
|
throw new ServerException(PlatformState.getLastError());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LauncherInput.handle(msg.getArguments());
|
LauncherInput.handle(msg.getArguments());
|
||||||
|
|
|
@ -69,10 +69,11 @@ public enum PlatformState {
|
||||||
try {
|
try {
|
||||||
// Weird fix to ensure that macOS quit operation works while in tray.
|
// Weird fix to ensure that macOS quit operation works while in tray.
|
||||||
// Maybe related to https://bugs.openjdk.org/browse/JDK-8318129 as it prints the same error if not called
|
// Maybe related to https://bugs.openjdk.org/browse/JDK-8318129 as it prints the same error if not called
|
||||||
// The headless is not needed though but still done
|
// The headless check is not needed though but still done
|
||||||
GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
|
GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
|
||||||
} catch (HeadlessException e) {
|
} catch (HeadlessException e) {
|
||||||
TrackEvent.warn(e.getMessage());
|
TrackEvent.warn(e.getMessage());
|
||||||
|
PlatformState.setCurrent(PlatformState.EXITED);
|
||||||
return Optional.of(e);
|
return Optional.of(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue