Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8343398: Add reducedData preference #1656

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,12 @@ private static void finishKeepAliveThread() {

private Menu appleMenu;

native void _runLoop(ClassLoader classLoader, Runnable launchable,
boolean isTaskbarApplication);
private long delegateHandle;

native long _initDelegate(ClassLoader classLoader, Runnable launchable, boolean isTaskbarApplication);

native void _runLoop(long delegate);

@Override
protected void runLoop(final Runnable launchable) {
// For normal (not embedded) taskbar applications the masOS activation
Expand All @@ -128,7 +132,8 @@ protected void runLoop(final Runnable launchable) {
startKeepAliveThread();

ClassLoader classLoader = MacApplication.class.getClassLoader();
_runLoop(classLoader, wrappedRunnable, isTaskbarApplication);
delegateHandle = _initDelegate(classLoader, wrappedRunnable, isTaskbarApplication);
_runLoop(delegateHandle);
}

private final CountDownLatch reactivationLatch = new CountDownLatch(1);
Expand All @@ -154,10 +159,10 @@ void waitForReactivation() {
eventLoop.enter();
}

native private void _finishTerminating();
native private void _finishTerminating(long delegateHandle);
@Override
protected void finishTerminating() {
_finishTerminating();
_finishTerminating(delegateHandle);
finishKeepAliveThread();

super.finishTerminating();
Expand Down Expand Up @@ -420,8 +425,12 @@ public String getDataDirectory() {

private native String _getApplicationClassName();

private native Map<String, Object> _getPlatformPreferences(long delegateHandle);

@Override
public native Map<String, Object> getPlatformPreferences();
public Map<String, Object> getPlatformPreferences() {
return _getPlatformPreferences(delegateHandle);
}

@Override
public Map<String, PreferenceMapping<?, ?>> getPlatformKeyMappings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -952,30 +952,47 @@ + (BOOL)syncRenderingDisabled {

/*
* Class: com_sun_glass_ui_mac_MacApplication
* Method: _runLoop
* Signature: (Ljava/lang/ClassLoader;Ljava/lang/Runnable;Z)V
* Method: _initDelegate
* Signature: (Ljava/lang/ClassLoader;Ljava/lang/Runnable;Z)J
*/
JNIEXPORT void JNICALL Java_com_sun_glass_ui_mac_MacApplication__1runLoop
JNIEXPORT jlong JNICALL Java_com_sun_glass_ui_mac_MacApplication__1initDelegate
(JNIEnv *env, jobject japplication, jobject classLoader,
jobject jlaunchable, jboolean isTaskbarApplication)
{
LOG("Java_com_sun_glass_ui_mac_MacApplication__1runLoop");
LOG("Java_com_sun_glass_ui_mac_MacApplication__1initDelegate");

NSAutoreleasePool *glasspool = [[NSAutoreleasePool alloc] init];
if ([NSThread isMainThread] == YES)
{
if ([NSThread isMainThread] == YES)
{
// fprintf(stderr, "\nWARNING: Glass was started on 1st thread and will block this thread.\nYou most likely do not want to do this - please remove \"-XstartOnFirstThread\" from VM arguments.\n\n");
}
else
// fprintf(stderr, "\nWARNING: Glass was started on 1st thread and will block this thread.\nYou most likely do not want to do this - please remove \"-XstartOnFirstThread\" from VM arguments.\n\n");
}
else
{
if ([[NSThread currentThread] name] == nil)
{
if ([[NSThread currentThread] name] == nil)
{
[[NSThread currentThread] setName:@"Main Java Thread"];
}
[[NSThread currentThread] setName:@"Main Java Thread"];
}
}

return (jlong)[[GlassApplication alloc] initWithEnv:env
application:japplication
launchable:jlaunchable
taskbarApplication:isTaskbarApplication
classLoader:classLoader];
}

GlassApplication *glass = [[GlassApplication alloc] initWithEnv:env application:japplication launchable:jlaunchable taskbarApplication:isTaskbarApplication classLoader:classLoader];
/*
* Class: com_sun_glass_ui_mac_MacApplication
* Method: _runLoop
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_com_sun_glass_ui_mac_MacApplication__1runLoop
(JNIEnv *env, jobject japplication, jlong appDelegate)
{
LOG("Java_com_sun_glass_ui_mac_MacApplication__1runLoop");

NSAutoreleasePool *glasspool = [[NSAutoreleasePool alloc] init];
{
GlassApplication* glass = (GlassApplication*)appDelegate;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a clean split to me.

if ([NSThread isMainThread] == YES) {
[glass runLoop: glass];
} else {
Expand All @@ -998,13 +1015,17 @@ + (BOOL)syncRenderingDisabled {
/*
* Class: com_sun_glass_ui_mac_MacApplication
* Method: _finishTerminating
* Signature: ()V
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_com_sun_glass_ui_mac_MacApplication__1finishTerminating
(JNIEnv *env, jobject japplication)
(JNIEnv *env, jobject japplication, jlong appDelegate)
{
LOG("Java_com_sun_glass_ui_mac_MacApplication__1finishTerminating");

if (appDelegate) {
[(GlassApplication*)appDelegate release];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed because you moved the allocation of GlassApplication outside (before) the auto-release pool in runLoop, so looks good.

}

if (isEmbedded) {
return;
}
Expand Down Expand Up @@ -1262,11 +1283,12 @@ + (BOOL)syncRenderingDisabled {
/*
* Class: com_sun_glass_ui_mac_MacApplication
* Method: getPlatformPreferences
* Signature: ()Ljava/util/Map;
* Signature: (J)Ljava/util/Map;
*/
JNIEXPORT jobject JNICALL Java_com_sun_glass_ui_mac_MacApplication_getPlatformPreferences
(JNIEnv *env, jobject self)
JNIEXPORT jobject JNICALL Java_com_sun_glass_ui_mac_MacApplication__1getPlatformPreferences
(JNIEnv *env, jobject self, jlong appDelegate)
{
GlassApplication* app = (GlassApplication*)[NSApp delegate];
return [app getPlatformPreferences];
return appDelegate
? [(GlassApplication*)appDelegate getPlatformPreferences]
: nil;
}