* Add OS X resource forks and other stuff to gitignore * fix #655, try to set Dock icon only if not using app bundle * update CHANGELOG.md * try to set macOS icon only when using jar bundle, as in app bundle macOS sets everything automatically Co-authored-by: Ryan Dowling <ryan@ryandowling.me>
This commit is contained in:
parent
4de829b976
commit
8174e3e64f
3 changed files with 29 additions and 10 deletions
8
.gitignore
vendored
8
.gitignore
vendored
|
@ -17,6 +17,14 @@ testLauncher/
|
||||||
|
|
||||||
# OS X
|
# OS X
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
._*
|
||||||
|
.DocumentRevisions-V100
|
||||||
|
.fseventsd
|
||||||
|
.Spotlight-V100
|
||||||
|
.TemporaryItems
|
||||||
|
.Trashes
|
||||||
|
.VolumeIcon.icns
|
||||||
|
.com.apple.timemachine.donotpresent
|
||||||
|
|
||||||
# ACT
|
# ACT
|
||||||
.actrc
|
.actrc
|
||||||
|
|
|
@ -8,5 +8,6 @@ This changelog only contains the changes that are unreleased. For changes for in
|
||||||
### New Features
|
### New Features
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
|
- Default Java icon in macOS Dock when using Java 9 or later [#655] (@WhiteBear60)
|
||||||
|
|
||||||
### Misc
|
### Misc
|
||||||
|
|
|
@ -135,7 +135,7 @@ public class App {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This allows skipping the system tray integration so that the launcher doesn't
|
* This allows skipping the system tray integration so that the launcher doesn't
|
||||||
* even try to show the icon and menu etc, in the users system tray. It can be
|
* even try to show the icon and menu etc., in the users system tray. It can be
|
||||||
* skipped with the below command line argument.
|
* skipped with the below command line argument.
|
||||||
* <p/>
|
* <p/>
|
||||||
* --skip-tray-integration
|
* --skip-tray-integration
|
||||||
|
@ -637,17 +637,27 @@ public class App {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setupOSSpecificThings() {
|
private static void setupOSSpecificThings() {
|
||||||
// do some Mac specific stuff, setting the name of theapplication and icon
|
// do some Mac specific stuff, setting the name of the application and icon
|
||||||
if (OS.isMac()) {
|
// set only when using jar bundle, as if using *.app, macOS sets icon and name automatically and apple.laf.useScreenMenuBar is set using build.gradle
|
||||||
|
if (!OS.isUsingMacApp()) {
|
||||||
System.setProperty("apple.laf.useScreenMenuBar", "true");
|
System.setProperty("apple.laf.useScreenMenuBar", "true");
|
||||||
System.setProperty("com.apple.mrj.application.apple.menu.about.name",
|
System.setProperty("apple.awt.application.name", Constants.LAUNCHER_NAME); // setting the application name in menu bar
|
||||||
Constants.LAUNCHER_NAME + " " + Constants.VERSION);
|
|
||||||
try {
|
try {
|
||||||
|
if (Java.isSystemJavaNewerThanJava8()) {
|
||||||
|
// if Java 9 or higher
|
||||||
|
Class<?> util = Class.forName("java.awt.Taskbar");
|
||||||
|
Method getTaskbar = util.getMethod("getTaskbar");
|
||||||
|
Object taskbar = getTaskbar.invoke(util);
|
||||||
|
Method setIconImage = util.getMethod("setIconImage", Image.class);
|
||||||
|
setIconImage.invoke(taskbar, Utils.getImage("/assets/image/icon-osx.png"));
|
||||||
|
} else {
|
||||||
|
// if Java 8 or lower
|
||||||
Class<?> util = Class.forName("com.apple.eawt.Application");
|
Class<?> util = Class.forName("com.apple.eawt.Application");
|
||||||
Method getApplication = util.getMethod("getApplication");
|
Method getApplication = util.getMethod("getApplication");
|
||||||
Object application = getApplication.invoke(util);
|
Object application = getApplication.invoke(util);
|
||||||
Method setDockIconImage = util.getMethod("setDockIconImage", Image.class);
|
Method setDockIconImage = util.getMethod("setDockIconImage", Image.class);
|
||||||
setDockIconImage.invoke(application, Utils.getImage("/assets/image/icon-osx.png"));
|
setDockIconImage.invoke(application, Utils.getImage("/assets/image/icon-osx.png"));
|
||||||
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LogManager.logStackTrace("Failed to set dock icon", ex);
|
LogManager.logStackTrace("Failed to set dock icon", ex);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue