* 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
|
||||
.DS_Store
|
||||
._*
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# ACT
|
||||
.actrc
|
||||
|
|
|
@ -8,5 +8,6 @@ This changelog only contains the changes that are unreleased. For changes for in
|
|||
### New Features
|
||||
|
||||
### Fixes
|
||||
- Default Java icon in macOS Dock when using Java 9 or later [#655] (@WhiteBear60)
|
||||
|
||||
### Misc
|
||||
|
|
|
@ -135,7 +135,7 @@ public class App {
|
|||
|
||||
/**
|
||||
* 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.
|
||||
* <p/>
|
||||
* --skip-tray-integration
|
||||
|
@ -638,16 +638,26 @@ public class App {
|
|||
|
||||
private static void setupOSSpecificThings() {
|
||||
// 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("com.apple.mrj.application.apple.menu.about.name",
|
||||
Constants.LAUNCHER_NAME + " " + Constants.VERSION);
|
||||
System.setProperty("apple.awt.application.name", Constants.LAUNCHER_NAME); // setting the application name in menu bar
|
||||
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");
|
||||
Method getApplication = util.getMethod("getApplication");
|
||||
Object application = getApplication.invoke(util);
|
||||
Method setDockIconImage = util.getMethod("setDockIconImage", Image.class);
|
||||
setDockIconImage.invoke(application, Utils.getImage("/assets/image/icon-osx.png"));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LogManager.logStackTrace("Failed to set dock icon", ex);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue