mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-22 07:30:24 +00:00
Rework macos tray and dock handling
This commit is contained in:
parent
51631f8278
commit
7bf5ef8afa
4 changed files with 26 additions and 7 deletions
|
@ -64,12 +64,6 @@ dependencies {
|
|||
|
||||
apply from: "$rootDir/gradle/gradle_scripts/local_junit_suite.gradle"
|
||||
|
||||
import org.gradle.internal.os.OperatingSystem
|
||||
|
||||
if (OperatingSystem.current() == OperatingSystem.LINUX) {
|
||||
jvmRunArgs.addAll("--add-opens", "java.desktop/sun.awt.X11=io.xpipe.app")
|
||||
}
|
||||
|
||||
def extensionJarDepList = project.allExtensions.stream().map(p -> p.getTasksByName('jar', true)).toList();
|
||||
jar {
|
||||
finalizedBy(extensionJarDepList)
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.xpipe.app.core;
|
|||
|
||||
import io.xpipe.app.Main;
|
||||
import io.xpipe.app.comp.AppLayoutComp;
|
||||
import io.xpipe.app.core.mode.OperationMode;
|
||||
import io.xpipe.app.fxcomps.util.PlatformThread;
|
||||
import io.xpipe.app.issue.ErrorEvent;
|
||||
import io.xpipe.app.issue.TrackEvent;
|
||||
|
@ -12,9 +13,13 @@ import javafx.application.Application;
|
|||
import javafx.beans.binding.Bindings;
|
||||
import javafx.stage.Stage;
|
||||
import lombok.Getter;
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.desktop.AppReopenedEvent;
|
||||
import java.awt.desktop.AppReopenedListener;
|
||||
import java.awt.desktop.SystemEventListener;
|
||||
|
||||
@Getter
|
||||
public class App extends Application {
|
||||
|
@ -27,6 +32,7 @@ public class App extends Application {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public void start(Stage primaryStage) {
|
||||
TrackEvent.info("Application launched");
|
||||
APP = this;
|
||||
|
@ -51,6 +57,17 @@ public class App extends Application {
|
|||
Desktop.getDesktop().setPreferencesHandler(e -> {
|
||||
AppLayoutModel.get().selectSettings();
|
||||
});
|
||||
|
||||
// Do it this way to prevent IDE inspections from complaining
|
||||
var c = Class.forName(ModuleLayer.boot().findModule("java.desktop").orElseThrow(),
|
||||
"com.apple.eawt.Application");
|
||||
var m = c.getDeclaredMethod("addAppEventListener", SystemEventListener.class);
|
||||
m.invoke(c.getMethod("getApplication").invoke(null), new AppReopenedListener() {
|
||||
@Override
|
||||
public void appReopened(AppReopenedEvent e) {
|
||||
OperationMode.switchToAsync(OperationMode.GUI);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (OsType.getLocal().equals(OsType.LINUX)) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package io.xpipe.app.core.mode;
|
|||
import io.xpipe.app.core.AppTray;
|
||||
import io.xpipe.app.fxcomps.util.PlatformThread;
|
||||
import io.xpipe.app.issue.*;
|
||||
import io.xpipe.core.process.OsType;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
|
@ -10,7 +11,7 @@ public class TrayMode extends PlatformMode {
|
|||
|
||||
@Override
|
||||
public boolean isSupported() {
|
||||
return super.isSupported() && Desktop.isDesktopSupported() && SystemTray.isSupported();
|
||||
return !OsType.getLocal().equals(OsType.MACOS) && super.isSupported() && Desktop.isDesktopSupported() && SystemTray.isSupported();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -93,6 +93,13 @@ project.ext {
|
|||
useBundledJavaFx = fullVersion && !(platformName == 'linux' && arch == 'arm64')
|
||||
}
|
||||
|
||||
if (org.gradle.internal.os.OperatingSystem.current() == org.gradle.internal.os.OperatingSystem.LINUX) {
|
||||
jvmRunArgs.addAll("--add-opens", "java.desktop/sun.awt.X11=io.xpipe.app")
|
||||
}
|
||||
if (org.gradle.internal.os.OperatingSystem.current() == org.gradle.internal.os.OperatingSystem.MAC_OS) {
|
||||
jvmRunArgs.addAll("--add-exports", "java.desktop/com.apple.eawt=io.xpipe.app")
|
||||
}
|
||||
|
||||
if (isFullRelease && rawVersion.contains("-")) {
|
||||
throw new IllegalArgumentException("Releases must have canonical versions")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue