Lines 840-878
Link Here
|
840 |
NSNumber id = new NSNumber(dictionary.objectForKey(key)); |
840 |
NSNumber id = new NSNumber(dictionary.objectForKey(key)); |
841 |
addPool(new NSAutoreleasePool(id.integerValue())); |
841 |
addPool(new NSAutoreleasePool(id.integerValue())); |
842 |
|
842 |
|
|
|
843 |
boolean appRegistered = registerApplication(); |
844 |
|
843 |
application = NSApplication.sharedApplication(); |
845 |
application = NSApplication.sharedApplication(); |
844 |
isEmbedded = application.isRunning(); |
846 |
isEmbedded = application.isRunning(); |
845 |
|
847 |
|
846 |
/* |
848 |
if (!appRegistered) { |
847 |
* Feature in the Macintosh. On OS 10.2, it is necessary |
849 |
/* |
848 |
* to explicitly check in with the Process Manager and set |
850 |
* Feature in the Macintosh. On OS 10.2, it is necessary |
849 |
* the current process to be the front process in order for |
851 |
* to explicitly check in with the Process Manager and set |
850 |
* windows to come to the front by default. The fix is call |
852 |
* the current process to be the front process in order for |
851 |
* both GetCurrentProcess() and SetFrontProcess(). |
853 |
* windows to come to the front by default. The fix is call |
852 |
* |
854 |
* both GetCurrentProcess() and SetFrontProcess(). |
853 |
* NOTE: It is not actually necessary to use the process |
855 |
* |
854 |
* serial number returned by GetCurrentProcess() in the |
856 |
* NOTE: It is not actually necessary to use the process |
855 |
* call to SetFrontProcess() (ie. kCurrentProcess can be |
857 |
* serial number returned by GetCurrentProcess() in the |
856 |
* used) but both functions must be called in order for |
858 |
* call to SetFrontProcess() (ie. kCurrentProcess can be |
857 |
* windows to come to the front. |
859 |
* used) but both functions must be called in order for |
858 |
*/ |
860 |
* windows to come to the front. |
859 |
int [] psn = new int [2]; |
861 |
*/ |
860 |
if (OS.GetCurrentProcess (psn) == OS.noErr) { |
862 |
int [] psn = new int [2]; |
861 |
int pid = OS.getpid (); |
863 |
if (OS.GetCurrentProcess (psn) == OS.noErr) { |
862 |
long /*int*/ ptr = getApplicationName().UTF8String(); |
864 |
long /*int*/ ptr = getApplicationName().UTF8String(); |
863 |
if (ptr != 0) OS.CPSSetProcessName (psn, ptr); |
865 |
if (ptr != 0) OS.CPSSetProcessName (psn, ptr); |
864 |
if (!isBundled ()) { |
866 |
if (!isBundled ()) { |
865 |
OS.TransformProcessType (psn, OS.kProcessTransformToForegroundApplication); |
867 |
OS.TransformProcessType (psn, OS.kProcessTransformToForegroundApplication); |
866 |
OS.SetFrontProcess (psn); |
868 |
OS.SetFrontProcess (psn); |
|
|
869 |
} |
867 |
} |
870 |
} |
868 |
ptr = OS.getenv (ascii ("APP_ICON_" + pid)); |
871 |
} |
869 |
if (ptr != 0) { |
872 |
|
870 |
NSString path = NSString.stringWithUTF8String (ptr); |
873 |
// Set the dock icon |
871 |
NSImage image = (NSImage) new NSImage().alloc(); |
874 |
int pid = OS.getpid (); |
872 |
image = image.initByReferencingFile(path); |
875 |
long /*int*/ ptr = OS.getenv (ascii ("APP_ICON_" + pid)); |
873 |
dockImage = image; |
876 |
if (ptr != 0) { |
874 |
application.setApplicationIconImage(image); |
877 |
NSString path = NSString.stringWithUTF8String (ptr); |
875 |
} |
878 |
NSImage image = (NSImage) new NSImage().alloc(); |
|
|
879 |
image = image.initByReferencingFile(path); |
880 |
dockImage = image; |
881 |
application.setApplicationIconImage(image); |
876 |
} |
882 |
} |
877 |
|
883 |
|
878 |
String className = "SWTApplication"; |
884 |
String className = "SWTApplication"; |
Lines 930-935
Link Here
|
930 |
systemUIOptions = bufferOptions[0]; |
936 |
systemUIOptions = bufferOptions[0]; |
931 |
} |
937 |
} |
932 |
|
938 |
|
|
|
939 |
/** |
940 |
* Register a non-bundled application with Launch Services, using the JavaRuntimeSupport framework. |
941 |
* This causes the app to show up in the dock, using the specified name. (The dock icon isn't set since, |
942 |
* unlike the name, the icon may be changed anytime.) |
943 |
* This framework is public and supposedly supported, but documentation is nearly non-existent. |
944 |
* <p> |
945 |
* Method signature and keys are defined in |
946 |
* <tt>/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Headers/JRSAppKitAWT.h</tt> |
947 |
* Some corresponding properties are defined in |
948 |
* <a href="https://developer.apple.com/library/mac/documentation/Java/Reference/Java_PropertiesRef/Articles/JavaSystemProperties.html">JavaSystemProperties.html</a> |
949 |
* and are correlated with Launch Services keys in |
950 |
* <a href="https://developer.apple.com/library/mac/documentation/general/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html">LaunchServicesKeys.html</a>. |
951 |
* <p> |
952 |
* Seems not to work on OS X 10.9(.0) yet. |
953 |
* @return true iff the application was successfully registered |
954 |
*/ |
955 |
private static boolean registerApplication() { |
956 |
NSString appName = getApplicationName(); |
957 |
if (OS.class_JRSAppKitAWT != 0) { |
958 |
NSDictionary dict = NSMutableDictionary.dictionaryWithObject(appName, NSString.stringWith("JRSAppNameKey")); |
959 |
|
960 |
// TODO Skip this if bundled? Might affect icon and localized names. |
961 |
// Without this, the dock name and icon will be taken from [NSBundle mainBundle]. |
962 |
dict.setValue(NSNumber.numberWithBool(true), NSString.stringWith("JRSAppIsCommandLineKey")); |
963 |
|
964 |
if (Boolean.getBoolean("apple.awt.UIElement")) { |
965 |
// Is an "agent app". Not shown in the dock, but can show UI. |
966 |
// Corresponds to the LSUIElement key in Info.plist. |
967 |
dict.setValue(NSNumber.numberWithBool(true), NSString.stringWith("JRSAppIsUIElementKey")); |
968 |
} |
969 |
|
970 |
if (Boolean.getBoolean("apple.awt.BackgroundOnly")) { |
971 |
// Is a "faceless background app". Does not show any UI. |
972 |
// Corresponds to the LSBackgroundOnly key in Info.plist. |
973 |
dict.setValue(NSNumber.numberWithBool(true), NSString.stringWith("JRSAppIsBackgroundOnlyKey")); |
974 |
} |
975 |
|
976 |
// The "AWT" in these names are historical artifacts and has no significance. |
977 |
OS.objc_msgSend(OS.class_JRSAppKitAWT, OS.sel_registerAWTAppWithOptions_, dict.id); |
978 |
return true; |
979 |
} |
980 |
return false; |
981 |
} |
982 |
|
933 |
void createMainMenu () { |
983 |
void createMainMenu () { |
934 |
NSString appName = getApplicationName(); |
984 |
NSString appName = getApplicationName(); |
935 |
NSString emptyStr = NSString.string(); |
985 |
NSString emptyStr = NSString.string(); |