From e2a1ad7c78641ca4c88d38a73e87fd7c58365e73 Mon Sep 17 00:00:00 2001 From: crschnick Date: Tue, 20 Feb 2024 03:41:50 +0000 Subject: [PATCH] Move dock icon initialization --- app/src/main/java/io/xpipe/app/core/App.java | 16 ---------------- .../io/xpipe/app/core/mode/OperationMode.java | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/core/App.java b/app/src/main/java/io/xpipe/app/core/App.java index c25dd8055..de3a64000 100644 --- a/app/src/main/java/io/xpipe/app/core/App.java +++ b/app/src/main/java/io/xpipe/app/core/App.java @@ -1,6 +1,5 @@ package io.xpipe.app.core; -import io.xpipe.app.Main; import io.xpipe.app.comp.AppLayoutComp; import io.xpipe.app.fxcomps.util.PlatformThread; import io.xpipe.app.issue.ErrorEvent; @@ -14,7 +13,6 @@ import javafx.stage.Stage; import lombok.Getter; import lombok.SneakyThrows; -import javax.imageio.ImageIO; import java.awt.*; @Getter @@ -35,20 +33,6 @@ public class App extends Application { stage = primaryStage; stage.opacityProperty().bind(AppPrefs.get().windowOpacity()); - // Set dock icon explicitly on mac - // This is necessary in case XPipe was started through a script as it will have no icon otherwise - if (OsType.getLocal().equals(OsType.MACOS) && AppProperties.get().isDeveloperMode() && AppLogs.get().isWriteToSysout()) { - try { - var iconUrl = Main.class.getResourceAsStream("resources/img/logo/logo_macos_128x128.png"); - if (iconUrl != null) { - var awtIcon = ImageIO.read(iconUrl); - Taskbar.getTaskbar().setIconImage(awtIcon); - } - } catch (Exception ex) { - ErrorEvent.fromThrowable(ex).omitted(true).build().handle(); - } - } - if (OsType.getLocal().equals(OsType.MACOS)) { Desktop.getDesktop().setPreferencesHandler(e -> { AppLayoutModel.get().selectSettings(); diff --git a/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java b/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java index 9e1b028c9..f08cfb588 100644 --- a/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java +++ b/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java @@ -1,5 +1,6 @@ package io.xpipe.app.core.mode; +import io.xpipe.app.Main; import io.xpipe.app.core.*; import io.xpipe.app.core.check.AppTempCheck; import io.xpipe.app.core.check.AppUserDirectoryCheck; @@ -18,6 +19,7 @@ import io.xpipe.core.util.XPipeInstallation; import javafx.application.Platform; import lombok.Getter; +import javax.imageio.ImageIO; import java.awt.*; import java.awt.desktop.AppReopenedEvent; import java.awt.desktop.AppReopenedListener; @@ -144,6 +146,20 @@ public abstract class OperationMode { OperationMode.switchToAsync(OperationMode.GUI); } }); + + // Set dock icon explicitly on mac + // This is necessary in case XPipe was started through a script as it will have no icon otherwise + if (AppProperties.get().isDeveloperMode() && AppLogs.get().isWriteToSysout()) { + try { + var iconUrl = Main.class.getResourceAsStream("resources/img/logo/logo_macos_128x128.png"); + if (iconUrl != null) { + var awtIcon = ImageIO.read(iconUrl); + Taskbar.getTaskbar().setIconImage(awtIcon); + } + } catch (Exception ex) { + ErrorEvent.fromThrowable(ex).omitted(true).build().handle(); + } + } } DataStoreProviders.postInit(AppExtensionManager.getInstance().getExtendedLayer());