mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 17:10:27 +00:00
Remove unnecessary platform initialization code
This commit is contained in:
parent
b146b9bb27
commit
df9594ae86
1 changed files with 0 additions and 17 deletions
|
@ -21,9 +21,6 @@ public enum PlatformState {
|
|||
@Setter
|
||||
private static PlatformState current = PlatformState.NOT_INITIALIZED;
|
||||
|
||||
public static boolean HAS_GRAPHICS;
|
||||
public static boolean PLATFORM_LOADED;
|
||||
|
||||
public static void teardown() {
|
||||
PlatformThread.runLaterIfNeededBlocking(() -> {
|
||||
// Fix to preserve clipboard contents after shutdown
|
||||
|
@ -55,23 +52,12 @@ public enum PlatformState {
|
|||
return Optional.empty();
|
||||
}
|
||||
|
||||
try {
|
||||
GraphicsDevice[] screenDevices =
|
||||
GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
|
||||
HAS_GRAPHICS = screenDevices != null && screenDevices.length > 0;
|
||||
} catch (HeadlessException e) {
|
||||
TrackEvent.warn(e.getMessage());
|
||||
HAS_GRAPHICS = false;
|
||||
return Optional.of(e);
|
||||
}
|
||||
|
||||
try {
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
Platform.setImplicitExit(false);
|
||||
Platform.startup(latch::countDown);
|
||||
try {
|
||||
latch.await();
|
||||
PLATFORM_LOADED = true;
|
||||
PlatformState.setCurrent(PlatformState.RUNNING);
|
||||
return Optional.empty();
|
||||
} catch (InterruptedException e) {
|
||||
|
@ -80,16 +66,13 @@ public enum PlatformState {
|
|||
} catch (Throwable t) {
|
||||
// Check if we already exited
|
||||
if ("Platform.exit has been called".equals(t.getMessage())) {
|
||||
PLATFORM_LOADED = true;
|
||||
PlatformState.setCurrent(PlatformState.EXITED);
|
||||
return Optional.of(t);
|
||||
} else if ("Toolkit already initialized".equals(t.getMessage())) {
|
||||
PLATFORM_LOADED = true;
|
||||
PlatformState.setCurrent(PlatformState.RUNNING);
|
||||
return Optional.empty();
|
||||
} else {
|
||||
// Platform initialization has failed in this case
|
||||
PLATFORM_LOADED = false;
|
||||
PlatformState.setCurrent(PlatformState.EXITED);
|
||||
TrackEvent.error(t.getMessage());
|
||||
return Optional.of(t);
|
||||
|
|
Loading…
Reference in a new issue