jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m
author serb
Sat, 26 Sep 2015 22:38:36 +0300
changeset 32872 abca6234313d
parent 32293 269494f7adec
child 32875 eb8e90bef9aa
permissions -rw-r--r--
8079965: Stop ignoring warnings for libawt_lwawt Reviewed-by: prr, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     1
/*
32293
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
     2
 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     4
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    10
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    15
 * accompanied this code).
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    16
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    20
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    23
 * questions.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    24
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    25
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    26
#import <dlfcn.h>
25563
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
    27
#import <pthread.h>
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
    28
#import <objc/runtime.h>
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
    29
#import <Cocoa/Cocoa.h>
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
    30
#import <Security/AuthSession.h>
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    31
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    32
#include "jni_util.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    33
#import "LWCToolkit.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    34
#import "ThreadUtilities.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    35
#import "CSystemColors.h"
13991
e62879b84a14 7124239: [macosx] sun.awt.SunToolkit.InfiniteLoop exception in realSync called from SwingTestHelper
leonidr
parents: 13004
diff changeset
    36
#import  "NSApplicationAWT.h"
25563
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
    37
#import "PropertiesUtilities.h"
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
    38
#import "ApplicationDelegate.h"
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    39
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    40
#import "sun_lwawt_macosx_LWCToolkit.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    41
18232
b538b71fb429 8009071: Improve shape handling
anthony
parents: 15988
diff changeset
    42
#import "sizecalc.h"
b538b71fb429 8009071: Improve shape handling
anthony
parents: 15988
diff changeset
    43
32872
abca6234313d 8079965: Stop ignoring warnings for libawt_lwawt
serb
parents: 32293
diff changeset
    44
#import <JavaRuntimeSupport/JavaRuntimeSupport.h>
abca6234313d 8079965: Stop ignoring warnings for libawt_lwawt
serb
parents: 32293
diff changeset
    45
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    46
int gNumberOfButtons;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    47
jint* gButtonDownMasks;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    48
25563
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
    49
// Indicates that the app has been started with -XstartOnFirstThread
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
    50
// (directly or via WebStart settings), and AWT should not run its
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
    51
// own event loop in this mode. Even if a loop isn't running yet,
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
    52
// we expect an embedder (e.g. SWT) to start it some time later.
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
    53
static BOOL forceEmbeddedMode = NO;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
    54
25564
871d3490f14d 8048549: [macosx] Disable usage of system menu bar if AWT is embedded in FX
pchelko
parents: 25563
diff changeset
    55
// Indicates if awt toolkit is embedded into another UI toolkit
871d3490f14d 8048549: [macosx] Disable usage of system menu bar if AWT is embedded in FX
pchelko
parents: 25563
diff changeset
    56
static BOOL isEmbedded = NO;
871d3490f14d 8048549: [macosx] Disable usage of system menu bar if AWT is embedded in FX
pchelko
parents: 25563
diff changeset
    57
25563
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
    58
// This is the data necessary to have JNI_OnLoad wait for AppKit to start.
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
    59
static BOOL sAppKitStarted = NO;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
    60
static pthread_mutex_t sAppKitStarted_mutex = PTHREAD_MUTEX_INITIALIZER;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
    61
static pthread_cond_t sAppKitStarted_cv = PTHREAD_COND_INITIALIZER;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
    62
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    63
@implementation AWTToolkit
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    64
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    65
static long eventCount;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    66
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    67
+ (long) getEventCount{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    68
    return eventCount;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    69
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    70
32293
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
    71
+ (void) eventCountPlusPlus{
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    72
    eventCount++;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    73
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    74
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    75
@end
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    76
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    77
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    78
@interface AWTRunLoopObject : NSObject {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    79
    BOOL _shouldEndRunLoop;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    80
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    81
@end
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    82
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    83
@implementation AWTRunLoopObject
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    84
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    85
- (id) init {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    86
    self = [super init];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    87
    if (self != nil) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    88
        _shouldEndRunLoop = NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    89
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    90
    return self;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    91
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    92
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    93
- (BOOL) shouldEndRunLoop {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    94
    return _shouldEndRunLoop;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    95
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    96
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    97
- (void) endRunLoop {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    98
    _shouldEndRunLoop = YES;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    99
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   100
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   101
@end
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   102
23681
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   103
@interface JavaRunnable : NSObject { }
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   104
@property jobject runnable;
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   105
- (id)initWithRunnable:(jobject)gRunnable;
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   106
- (void)perform;
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   107
@end
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   108
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   109
@implementation JavaRunnable
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   110
@synthesize runnable = _runnable;
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   111
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   112
- (id)initWithRunnable:(jobject)gRunnable {
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   113
    if (self = [super init]) {
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   114
        self.runnable = gRunnable;
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   115
    }
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   116
    return self;
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   117
}
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   118
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   119
- (void)dealloc {
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   120
    JNIEnv *env = [ThreadUtilities getJNIEnv];
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   121
    if (self.runnable) {
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   122
        (*env)->DeleteGlobalRef(env, self.runnable);
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   123
    }
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   124
    [super dealloc];
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   125
}
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   126
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   127
- (void)perform {
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   128
    JNIEnv* env = [ThreadUtilities getJNIEnv];
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   129
    static JNF_CLASS_CACHE(sjc_Runnable, "java/lang/Runnable");
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   130
    static JNF_MEMBER_CACHE(jm_Runnable_run, sjc_Runnable, "run", "()V");
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   131
    JNFCallVoidMethod(env, self.runnable, jm_Runnable_run);
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   132
    [self release];
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   133
}
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   134
@end
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   135
25563
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   136
void setBusy(BOOL busy) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   137
    AWT_ASSERT_APPKIT_THREAD;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   138
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   139
    JNIEnv *env = [ThreadUtilities getJNIEnv];
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   140
    static JNF_CLASS_CACHE(jc_AWTAutoShutdown, "sun/awt/AWTAutoShutdown");
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   141
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   142
    if (busy) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   143
        static JNF_STATIC_MEMBER_CACHE(jm_notifyBusyMethod, jc_AWTAutoShutdown, "notifyToolkitThreadBusy", "()V");
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   144
        JNFCallStaticVoidMethod(env, jm_notifyBusyMethod);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   145
    } else {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   146
        static JNF_STATIC_MEMBER_CACHE(jm_notifyFreeMethod, jc_AWTAutoShutdown, "notifyToolkitThreadFree", "()V");
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   147
        JNFCallStaticVoidMethod(env, jm_notifyFreeMethod);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   148
    }
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   149
}
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   150
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   151
static void setUpAWTAppKit(BOOL installObservers)
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   152
{
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   153
    if (installObservers) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   154
        AWT_STARTUP_LOG(@"Setting up busy observers");
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   155
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   156
        // Add CFRunLoopObservers to call into AWT so that AWT knows that the
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   157
        //  AWT thread (which is the AppKit main thread) is alive. This way AWT
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   158
        //  will not automatically shutdown.
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   159
        CFRunLoopObserverRef busyObserver = CFRunLoopObserverCreateWithHandler(
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   160
                                               NULL,                        // CFAllocator
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   161
                                               kCFRunLoopAfterWaiting,      // CFOptionFlags
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   162
                                               true,                        // repeats
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   163
                                               NSIntegerMax,                // order
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   164
                                               ^(CFRunLoopObserverRef observer, CFRunLoopActivity activity) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   165
                                                   setBusy(YES);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   166
                                               });
32293
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   167
25563
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   168
        CFRunLoopObserverRef notBusyObserver = CFRunLoopObserverCreateWithHandler(
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   169
                                                NULL,                        // CFAllocator
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   170
                                                kCFRunLoopBeforeWaiting,     // CFOptionFlags
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   171
                                                true,                        // repeats
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   172
                                                NSIntegerMin,                // order
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   173
                                                ^(CFRunLoopObserverRef observer, CFRunLoopActivity activity) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   174
                                                    setBusy(NO);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   175
                                                });
32293
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   176
25563
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   177
        CFRunLoopRef runLoop = [[NSRunLoop currentRunLoop] getCFRunLoop];
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   178
        CFRunLoopAddObserver(runLoop, busyObserver, kCFRunLoopDefaultMode);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   179
        CFRunLoopAddObserver(runLoop, notBusyObserver, kCFRunLoopDefaultMode);
32293
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   180
25563
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   181
        CFRelease(busyObserver);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   182
        CFRelease(notBusyObserver);
32293
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   183
25563
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   184
        setBusy(YES);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   185
    }
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   186
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   187
    JNIEnv* env = [ThreadUtilities getJNIEnv];
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   188
    static JNF_CLASS_CACHE(jc_LWCToolkit, "sun/lwawt/macosx/LWCToolkit");
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   189
    static JNF_STATIC_MEMBER_CACHE(jsm_installToolkitThreadInJava, jc_LWCToolkit, "installToolkitThreadInJava", "()V");
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   190
    JNFCallStaticVoidMethod(env, jsm_installToolkitThreadInJava);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   191
}
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   192
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   193
BOOL isSWTInWebStart(JNIEnv* env) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   194
    NSString *swtWebStart = [PropertiesUtilities javaSystemPropertyForKey:@"com.apple.javaws.usingSWT" withEnv:env];
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   195
    return [@"true" isCaseInsensitiveLike:swtWebStart];
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   196
}
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   197
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   198
static void AWT_NSUncaughtExceptionHandler(NSException *exception) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   199
    NSLog(@"Apple AWT Internal Exception: %@", [exception description]);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   200
}
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   201
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   202
@interface AWTStarter : NSObject
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   203
+ (void)start:(BOOL)headless;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   204
+ (void)starter:(BOOL)onMainThread headless:(BOOL)headless;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   205
+ (void)appKitIsRunning:(id)arg;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   206
@end
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   207
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   208
@implementation AWTStarter
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   209
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   210
+ (BOOL) isConnectedToWindowServer {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   211
    SecuritySessionId session_id;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   212
    SessionAttributeBits session_info;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   213
    OSStatus status = SessionGetInfo(callerSecuritySession, &session_id, &session_info);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   214
    if (status != noErr) return NO;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   215
    if (!(session_info & sessionHasGraphicAccess)) return NO;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   216
    return YES;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   217
}
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   218
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   219
+ (BOOL) markAppAsDaemon {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   220
    id jrsAppKitAWTClass = objc_getClass("JRSAppKitAWT");
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   221
    SEL markAppSel = @selector(markAppIsDaemon);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   222
    if (![jrsAppKitAWTClass respondsToSelector:markAppSel]) return NO;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   223
    return [jrsAppKitAWTClass performSelector:markAppSel] ? YES : NO;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   224
}
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   225
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   226
+ (void)appKitIsRunning:(id)arg {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   227
    AWT_ASSERT_APPKIT_THREAD;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   228
    AWT_STARTUP_LOG(@"About to message AppKit started");
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   229
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   230
    // Signal that AppKit has started (or is already running).
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   231
    pthread_mutex_lock(&sAppKitStarted_mutex);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   232
    sAppKitStarted = YES;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   233
    pthread_cond_signal(&sAppKitStarted_cv);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   234
    pthread_mutex_unlock(&sAppKitStarted_mutex);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   235
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   236
    AWT_STARTUP_LOG(@"Finished messaging AppKit started");
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   237
}
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   238
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   239
+ (void)start:(BOOL)headless
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   240
{
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   241
    // onMainThread is NOT the same at SWT mode!
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   242
    // If the JVM was started on the first thread for SWT, but the SWT loads the AWT on a secondary thread,
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   243
    // onMainThread here will be false but SWT mode will be true.  If we are currently on the main thread, we don't
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   244
    // need to throw AWT startup over to another thread.
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   245
    BOOL onMainThread = [NSThread isMainThread];
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   246
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   247
    NSString* msg = [NSString stringWithFormat:@"+[AWTStarter start headless:%d] { onMainThread:%d }", headless, onMainThread];
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   248
    AWT_STARTUP_LOG(msg);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   249
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   250
    if (!headless)
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   251
    {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   252
        // Listen for the NSApp to start. This indicates that JNI_OnLoad can proceed.
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   253
        //  It must wait because there is a chance that another java thread will grab
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   254
        //  the AppKit lock before the +[NSApplication sharedApplication] returns.
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   255
        //  See <rdar://problem/3492666> for an example.
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   256
        [[NSNotificationCenter defaultCenter] addObserver:[AWTStarter class]
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   257
                                                 selector:@selector(appKitIsRunning:)
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   258
                                                     name:NSApplicationDidFinishLaunchingNotification
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   259
                                                   object:nil];
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   260
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   261
        AWT_STARTUP_LOG(@"+[AWTStarter start:::]: registered NSApplicationDidFinishLaunchingNotification");
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   262
    }
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   263
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   264
    [ThreadUtilities performOnMainThreadWaiting:NO block:^() {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   265
        [AWTStarter starter:onMainThread headless:headless];
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   266
    }];
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   267
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   268
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   269
    if (!headless && !onMainThread) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   270
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   271
        AWT_STARTUP_LOG(@"about to wait on AppKit startup mutex");
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   272
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   273
        // Wait here for AppKit to have started (or for AWT to have been loaded into
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   274
        //  an already running NSApplication).
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   275
        pthread_mutex_lock(&sAppKitStarted_mutex);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   276
        while (sAppKitStarted == NO) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   277
            pthread_cond_wait(&sAppKitStarted_cv, &sAppKitStarted_mutex);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   278
        }
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   279
        pthread_mutex_unlock(&sAppKitStarted_mutex);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   280
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   281
        // AWT gets here AFTER +[AWTStarter appKitIsRunning:] is called.
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   282
        AWT_STARTUP_LOG(@"got out of the AppKit startup mutex");
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   283
    }
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   284
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   285
    if (!headless) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   286
        // Don't set the delegate until the NSApplication has been created and
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   287
        // its finishLaunching has initialized it.
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   288
        //  ApplicationDelegate is the support code for com.apple.eawt.
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   289
        [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   290
            id<NSApplicationDelegate> delegate = [ApplicationDelegate sharedDelegate];
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   291
            if (delegate != nil) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   292
                OSXAPP_SetApplicationDelegate(delegate);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   293
            }
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   294
        }];
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   295
    }
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   296
}
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   297
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   298
+ (void)starter:(BOOL)wasOnMainThread headless:(BOOL)headless {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   299
    NSAutoreleasePool *pool = [NSAutoreleasePool new];
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   300
    // Add the exception handler of last resort
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   301
    NSSetUncaughtExceptionHandler(AWT_NSUncaughtExceptionHandler);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   302
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   303
    // Headless mode trumps either ordinary AWT or SWT-in-AWT mode.  Declare us a daemon and return.
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   304
    if (headless) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   305
        // Note that we don't install run loop observers in headless mode
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   306
        // because we don't need them (see 7174704)
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   307
        if (!forceEmbeddedMode) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   308
            setUpAWTAppKit(false);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   309
        }
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   310
        [AWTStarter markAppAsDaemon];
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   311
        return;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   312
    }
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   313
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   314
    if (forceEmbeddedMode) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   315
        AWT_STARTUP_LOG(@"in SWT or SWT/WebStart mode");
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   316
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   317
        // Init a default NSApplication instance instead of the NSApplicationAWT.
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   318
        // Note that [NSApp isRunning] will return YES after that, though
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   319
        // this behavior isn't specified anywhere. We rely on that.
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   320
        NSApplicationLoad();
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   321
    }
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   322
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   323
    // This will create a NSApplicationAWT for standalone AWT programs, unless there is
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   324
    //  already a NSApplication instance. If there is already a NSApplication instance,
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   325
    //  and -[NSApplication isRunning] returns YES, AWT is embedded inside another
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   326
    //  AppKit Application.
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   327
    NSApplication *app = [NSApplicationAWT sharedApplication];
25564
871d3490f14d 8048549: [macosx] Disable usage of system menu bar if AWT is embedded in FX
pchelko
parents: 25563
diff changeset
   328
    isEmbedded = ![NSApp isKindOfClass:[NSApplicationAWT class]];
25563
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   329
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   330
    if (!isEmbedded) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   331
        // Install run loop observers and set the AppKit Java thread name
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   332
        setUpAWTAppKit(true);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   333
    }
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   334
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   335
    // AWT gets to this point BEFORE NSApplicationDidFinishLaunchingNotification is sent.
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   336
    if (![app isRunning]) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   337
        AWT_STARTUP_LOG(@"+[AWTStarter startAWT]: ![app isRunning]");
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   338
        // This is where the AWT AppKit thread parks itself to process events.
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   339
        [NSApplicationAWT runAWTLoopWithApp: app];
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   340
    } else {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   341
        // We're either embedded, or showing a splash screen
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   342
        if (isEmbedded) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   343
            AWT_STARTUP_LOG(@"running embedded");
32293
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   344
25563
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   345
            // We don't track if the runloop is busy, so set it free to let AWT finish when it needs
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   346
            setBusy(NO);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   347
        } else {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   348
            AWT_STARTUP_LOG(@"running after showing a splash screen");
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   349
        }
32293
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   350
25563
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   351
        // Signal so that JNI_OnLoad can proceed.
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   352
        if (!wasOnMainThread) [AWTStarter appKitIsRunning:nil];
32293
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   353
25563
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   354
        // Proceed to exit this call as there is no reason to run the NSApplication event loop.
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   355
    }
32293
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   356
25563
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   357
    [pool drain];
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   358
}
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   359
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   360
@end
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   361
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   362
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   363
 * Class:     sun_lwawt_macosx_LWCToolkit
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   364
 * Method:    nativeSyncQueue
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   365
 * Signature: (J)Z
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   366
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   367
JNIEXPORT jboolean JNICALL Java_sun_lwawt_macosx_LWCToolkit_nativeSyncQueue
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   368
(JNIEnv *env, jobject self, jlong timeout)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   369
{
32293
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   370
    long currentEventNum = [AWTToolkit getEventCount];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   371
13991
e62879b84a14 7124239: [macosx] sun.awt.SunToolkit.InfiniteLoop exception in realSync called from SwingTestHelper
leonidr
parents: 13004
diff changeset
   372
    NSApplication* sharedApp = [NSApplication sharedApplication];
e62879b84a14 7124239: [macosx] sun.awt.SunToolkit.InfiniteLoop exception in realSync called from SwingTestHelper
leonidr
parents: 13004
diff changeset
   373
    if ([sharedApp isKindOfClass:[NSApplicationAWT class]]) {
e62879b84a14 7124239: [macosx] sun.awt.SunToolkit.InfiniteLoop exception in realSync called from SwingTestHelper
leonidr
parents: 13004
diff changeset
   374
        NSApplicationAWT* theApp = (NSApplicationAWT*)sharedApp;
32293
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   375
        // We use two different API to post events to the application,
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   376
        //  - [NSApplication postEvent]
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   377
        //  - CGEventPost(), see CRobot.m
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   378
        // It was found that if we post an event via CGEventPost in robot and
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   379
        // immediately after this we will post the second event via
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   380
        // [NSApp postEvent] then sometimes the second event will be handled
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   381
        // first. The opposite isn't proved, but we use both here to be safer.
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   382
        [theApp postDummyEvent:false];
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   383
        [theApp waitForDummyEvent:timeout / 2.0];
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   384
        [theApp postDummyEvent:true];
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   385
        [theApp waitForDummyEvent:timeout / 2.0];
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   386
13991
e62879b84a14 7124239: [macosx] sun.awt.SunToolkit.InfiniteLoop exception in realSync called from SwingTestHelper
leonidr
parents: 13004
diff changeset
   387
    } else {
e62879b84a14 7124239: [macosx] sun.awt.SunToolkit.InfiniteLoop exception in realSync called from SwingTestHelper
leonidr
parents: 13004
diff changeset
   388
        // could happen if we are embedded inside SWT application,
32293
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   389
        // in this case just spin a single empty block through
13991
e62879b84a14 7124239: [macosx] sun.awt.SunToolkit.InfiniteLoop exception in realSync called from SwingTestHelper
leonidr
parents: 13004
diff changeset
   390
        // the event loop to give it a chance to process pending events
e62879b84a14 7124239: [macosx] sun.awt.SunToolkit.InfiniteLoop exception in realSync called from SwingTestHelper
leonidr
parents: 13004
diff changeset
   391
        [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){}];
e62879b84a14 7124239: [macosx] sun.awt.SunToolkit.InfiniteLoop exception in realSync called from SwingTestHelper
leonidr
parents: 13004
diff changeset
   392
    }
32293
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   393
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   394
    if (([AWTToolkit getEventCount] - currentEventNum) != 0) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   395
        return JNI_TRUE;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   396
    }
32293
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   397
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   398
    return JNI_FALSE;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   399
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   400
24169
4efa892f600b 8038765: [macosx] Toolkit.sync should be implemented
serb
parents: 23681
diff changeset
   401
/*
4efa892f600b 8038765: [macosx] Toolkit.sync should be implemented
serb
parents: 23681
diff changeset
   402
 * Class:     sun_lwawt_macosx_LWCToolkit
4efa892f600b 8038765: [macosx] Toolkit.sync should be implemented
serb
parents: 23681
diff changeset
   403
 * Method:    flushNativeSelectors
4efa892f600b 8038765: [macosx] Toolkit.sync should be implemented
serb
parents: 23681
diff changeset
   404
 * Signature: ()J
4efa892f600b 8038765: [macosx] Toolkit.sync should be implemented
serb
parents: 23681
diff changeset
   405
 */
4efa892f600b 8038765: [macosx] Toolkit.sync should be implemented
serb
parents: 23681
diff changeset
   406
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_flushNativeSelectors
4efa892f600b 8038765: [macosx] Toolkit.sync should be implemented
serb
parents: 23681
diff changeset
   407
(JNIEnv *env, jclass clz)
4efa892f600b 8038765: [macosx] Toolkit.sync should be implemented
serb
parents: 23681
diff changeset
   408
{
4efa892f600b 8038765: [macosx] Toolkit.sync should be implemented
serb
parents: 23681
diff changeset
   409
JNF_COCOA_ENTER(env);
4efa892f600b 8038765: [macosx] Toolkit.sync should be implemented
serb
parents: 23681
diff changeset
   410
        [ThreadUtilities performOnMainThreadWaiting:YES block:^(){}];
4efa892f600b 8038765: [macosx] Toolkit.sync should be implemented
serb
parents: 23681
diff changeset
   411
JNF_COCOA_EXIT(env);
4efa892f600b 8038765: [macosx] Toolkit.sync should be implemented
serb
parents: 23681
diff changeset
   412
}
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   413
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   414
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   415
 * Class:     sun_lwawt_macosx_LWCToolkit
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   416
 * Method:    beep
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   417
 * Signature: ()V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   418
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   419
JNIEXPORT void JNICALL
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   420
Java_sun_lwawt_macosx_LWCToolkit_beep
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   421
(JNIEnv *env, jobject self)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   422
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   423
    NSBeep(); // produces both sound and visual flash, if configured in System Preferences
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   424
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   425
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   426
static UInt32 RGB(NSColor *c) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   427
    c = [c colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   428
    if (c == nil)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   429
    {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   430
        return -1; // opaque white
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   431
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   432
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   433
    CGFloat r, g, b, a;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   434
    [c getRed:&r green:&g blue:&b alpha:&a];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   435
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   436
    UInt32 ir = (UInt32) (r*255+0.5),
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   437
    ig = (UInt32) (g*255+0.5),
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   438
    ib = (UInt32) (b*255+0.5),
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   439
    ia = (UInt32) (a*255+0.5);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   440
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   441
    //    NSLog(@"%@ %d, %d, %d", c, ir, ig, ib);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   442
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   443
    return ((ia & 0xFF) << 24) | ((ir & 0xFF) << 16) | ((ig & 0xFF) << 8) | ((ib & 0xFF) << 0);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   444
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   445
23301
618f7a6142c0 8034035: [parfait] JNI exception pending in jdk/src/macosx/native/sun/awt/LWCToolkit.m
pchelko
parents: 18274
diff changeset
   446
BOOL doLoadNativeColors(JNIEnv *env, jintArray jColors, BOOL useAppleColors) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   447
    jint len = (*env)->GetArrayLength(env, jColors);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   448
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   449
    UInt32 colorsArray[len];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   450
    UInt32 *colors = colorsArray;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   451
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   452
    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   453
        NSUInteger i;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   454
        for (i = 0; i < len; i++) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   455
            colors[i] = RGB([CSystemColors getColor:i useAppleColor:useAppleColors]);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   456
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   457
    }];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   458
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   459
    jint *_colors = (*env)->GetPrimitiveArrayCritical(env, jColors, 0);
23301
618f7a6142c0 8034035: [parfait] JNI exception pending in jdk/src/macosx/native/sun/awt/LWCToolkit.m
pchelko
parents: 18274
diff changeset
   460
    if (_colors == NULL) {
618f7a6142c0 8034035: [parfait] JNI exception pending in jdk/src/macosx/native/sun/awt/LWCToolkit.m
pchelko
parents: 18274
diff changeset
   461
        return NO;
618f7a6142c0 8034035: [parfait] JNI exception pending in jdk/src/macosx/native/sun/awt/LWCToolkit.m
pchelko
parents: 18274
diff changeset
   462
    }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   463
    memcpy(_colors, colors, len * sizeof(UInt32));
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   464
    (*env)->ReleasePrimitiveArrayCritical(env, jColors, _colors, 0);
23301
618f7a6142c0 8034035: [parfait] JNI exception pending in jdk/src/macosx/native/sun/awt/LWCToolkit.m
pchelko
parents: 18274
diff changeset
   465
    return YES;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   466
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   467
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   468
/**
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   469
 * Class:     sun_lwawt_macosx_LWCToolkit
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   470
 * Method:    loadNativeColors
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   471
 * Signature: ([I[I)V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   472
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   473
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_loadNativeColors
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   474
(JNIEnv *env, jobject peer, jintArray jSystemColors, jintArray jAppleColors)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   475
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   476
JNF_COCOA_ENTER(env);
23301
618f7a6142c0 8034035: [parfait] JNI exception pending in jdk/src/macosx/native/sun/awt/LWCToolkit.m
pchelko
parents: 18274
diff changeset
   477
    if (doLoadNativeColors(env, jSystemColors, NO)) {
618f7a6142c0 8034035: [parfait] JNI exception pending in jdk/src/macosx/native/sun/awt/LWCToolkit.m
pchelko
parents: 18274
diff changeset
   478
        doLoadNativeColors(env, jAppleColors, YES);
618f7a6142c0 8034035: [parfait] JNI exception pending in jdk/src/macosx/native/sun/awt/LWCToolkit.m
pchelko
parents: 18274
diff changeset
   479
    }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   480
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   481
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   482
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   483
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   484
 * Class:     sun_lwawt_macosx_LWCToolkit
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   485
 * Method:    createAWTRunLoopMediator
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   486
 * Signature: ()J
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   487
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   488
JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_LWCToolkit_createAWTRunLoopMediator
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   489
(JNIEnv *env, jclass clz)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   490
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   491
AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   492
23651
e41298d0da2f 8037099: [macosx] Remove all references to GC from native OBJ-C code
pchelko
parents: 23328
diff changeset
   493
    jlong result;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   494
23651
e41298d0da2f 8037099: [macosx] Remove all references to GC from native OBJ-C code
pchelko
parents: 23328
diff changeset
   495
JNF_COCOA_ENTER(env);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   496
    // We double retain because this object is owned by both main thread and "other" thread
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   497
    // We release in both doAWTRunLoop and stopAWTRunLoop
23651
e41298d0da2f 8037099: [macosx] Remove all references to GC from native OBJ-C code
pchelko
parents: 23328
diff changeset
   498
    result = ptr_to_jlong([[[AWTRunLoopObject alloc] init] retain]);
e41298d0da2f 8037099: [macosx] Remove all references to GC from native OBJ-C code
pchelko
parents: 23328
diff changeset
   499
JNF_COCOA_EXIT(env);
e41298d0da2f 8037099: [macosx] Remove all references to GC from native OBJ-C code
pchelko
parents: 23328
diff changeset
   500
e41298d0da2f 8037099: [macosx] Remove all references to GC from native OBJ-C code
pchelko
parents: 23328
diff changeset
   501
    return result;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   502
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   503
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   504
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   505
 * Class:     sun_lwawt_macosx_LWCToolkit
17899
d3a864bdee7d 8015477: Support single threaded AWT/FX mode.
pchelko
parents: 15988
diff changeset
   506
 * Method:    doAWTRunLoopImpl
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   507
 * Signature: (JZZ)V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   508
 */
17899
d3a864bdee7d 8015477: Support single threaded AWT/FX mode.
pchelko
parents: 15988
diff changeset
   509
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_doAWTRunLoopImpl
d3a864bdee7d 8015477: Support single threaded AWT/FX mode.
pchelko
parents: 15988
diff changeset
   510
(JNIEnv *env, jclass clz, jlong mediator, jboolean processEvents, jboolean inAWT)
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   511
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   512
AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   513
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   514
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   515
    AWTRunLoopObject* mediatorObject = (AWTRunLoopObject*)jlong_to_ptr(mediator);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   516
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   517
    if (mediatorObject == nil) return;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   518
15985
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
   519
    // Don't use acceptInputForMode because that doesn't setup autorelease pools properly
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
   520
    BOOL isRunning = true;
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
   521
    while (![mediatorObject shouldEndRunLoop] && isRunning) {
17899
d3a864bdee7d 8015477: Support single threaded AWT/FX mode.
pchelko
parents: 15988
diff changeset
   522
        isRunning = [[NSRunLoop currentRunLoop] runMode:(inAWT ? [JNFRunLoop javaRunLoopMode] : NSDefaultRunLoopMode)
15985
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
   523
                                             beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.010]];
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
   524
        if (processEvents) {
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
   525
            //We do not spin a runloop here as date is nil, so does not matter which mode to use
32293
269494f7adec 7124271: [macosx] RealSync test failure
serb
parents: 31654
diff changeset
   526
            // Processing all events excluding NSApplicationDefined which need to be processed
31170
4d414cfb92cc 8068886: IDEA IntelliJ crashes in objc_msgSend when an accessibility tool is enabled
anashaty
parents: 27272
diff changeset
   527
            // on the main loop only (those events are intended for disposing resources)
15985
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
   528
            NSEvent *event;
31170
4d414cfb92cc 8068886: IDEA IntelliJ crashes in objc_msgSend when an accessibility tool is enabled
anashaty
parents: 27272
diff changeset
   529
            if ((event = [NSApp nextEventMatchingMask:(NSAnyEventMask & ~NSApplicationDefined)
15985
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
   530
                                           untilDate:nil
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
   531
                                              inMode:NSDefaultRunLoopMode
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
   532
                                             dequeue:YES]) != nil) {
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
   533
                [NSApp sendEvent:event];
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
   534
            }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   535
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   536
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   537
    }
23651
e41298d0da2f 8037099: [macosx] Remove all references to GC from native OBJ-C code
pchelko
parents: 23328
diff changeset
   538
    [mediatorObject release];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   539
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   540
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   541
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   542
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   543
 * Class:     sun_lwawt_macosx_LWCToolkit
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   544
 * Method:    stopAWTRunLoop
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   545
 * Signature: (J)V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   546
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   547
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_stopAWTRunLoop
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   548
(JNIEnv *env, jclass clz, jlong mediator)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   549
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   550
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   551
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   552
    AWTRunLoopObject* mediatorObject = (AWTRunLoopObject*)jlong_to_ptr(mediator);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   553
15985
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
   554
    [ThreadUtilities performOnMainThread:@selector(endRunLoop) on:mediatorObject withObject:nil waitUntilDone:NO];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   555
23651
e41298d0da2f 8037099: [macosx] Remove all references to GC from native OBJ-C code
pchelko
parents: 23328
diff changeset
   556
    [mediatorObject release];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   557
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   558
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   559
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   560
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   561
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   562
 * Class:     sun_lwawt_macosx_LWCToolkit
23681
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   563
 * Method:    performOnMainThreadAfterDelay
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   564
 * Signature: (Ljava/lang/Runnable;J)V
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   565
 */
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   566
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_performOnMainThreadAfterDelay
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   567
(JNIEnv *env, jclass clz, jobject runnable, jlong delay)
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   568
{
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   569
JNF_COCOA_ENTER(env);
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   570
    jobject gRunnable = (*env)->NewGlobalRef(env, runnable);
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   571
    CHECK_NULL(gRunnable);
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   572
    [ThreadUtilities performOnMainThreadWaiting:NO block:^() {
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   573
        JavaRunnable* performer = [[JavaRunnable alloc] initWithRunnable:gRunnable];
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   574
        [performer performSelector:@selector(perform) withObject:nil afterDelay:(delay/1000.0)];
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   575
    }];
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   576
JNF_COCOA_EXIT(env);
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   577
}
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   578
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   579
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   580
/*
2044c9d2b681 8037840: [macosx] Rewrite CWarning window to eliminate the ExecutorService
pchelko
parents: 23651
diff changeset
   581
 * Class:     sun_lwawt_macosx_LWCToolkit
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   582
 * Method:    isCapsLockOn
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   583
 * Signature: ()Z
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   584
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   585
JNIEXPORT jboolean JNICALL Java_sun_lwawt_macosx_LWCToolkit_isCapsLockOn
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   586
(JNIEnv *env, jobject self)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   587
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   588
    __block jboolean isOn = JNI_FALSE;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   589
    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   590
        NSUInteger modifiers = [NSEvent modifierFlags];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   591
        isOn = (modifiers & NSAlphaShiftKeyMask) != 0;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   592
    }];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   593
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   594
    return isOn;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   595
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   596
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   597
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   598
 * Class:     sun_lwawt_macosx_LWCToolkit
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   599
 * Method:    isApplicationActive
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   600
 * Signature: ()Z
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   601
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   602
JNIEXPORT jboolean JNICALL Java_sun_lwawt_macosx_LWCToolkit_isApplicationActive
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   603
(JNIEnv *env, jclass clazz)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   604
{
12177
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12047
diff changeset
   605
    __block jboolean active = JNI_FALSE;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   606
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   607
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   608
15322
3638f33225ec 7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents: 13991
diff changeset
   609
    [ThreadUtilities performOnMainThreadWaiting:YES block:^() {
12177
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12047
diff changeset
   610
        active = (jboolean)[NSRunningApplication currentApplication].active;
15322
3638f33225ec 7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents: 13991
diff changeset
   611
    }];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   612
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   613
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   614
12177
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12047
diff changeset
   615
    return active;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   616
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   617
27272
cffe6690ee9d 8038919: Requesting focus to a modeless dialog doesn't work on Safari
mcherkas
parents: 26751
diff changeset
   618
/*
cffe6690ee9d 8038919: Requesting focus to a modeless dialog doesn't work on Safari
mcherkas
parents: 26751
diff changeset
   619
 * Class:     sun_lwawt_macosx_LWCToolkit
cffe6690ee9d 8038919: Requesting focus to a modeless dialog doesn't work on Safari
mcherkas
parents: 26751
diff changeset
   620
 * Method:    activateApplicationIgnoringOtherApps
cffe6690ee9d 8038919: Requesting focus to a modeless dialog doesn't work on Safari
mcherkas
parents: 26751
diff changeset
   621
 * Signature: ()V
cffe6690ee9d 8038919: Requesting focus to a modeless dialog doesn't work on Safari
mcherkas
parents: 26751
diff changeset
   622
 */
cffe6690ee9d 8038919: Requesting focus to a modeless dialog doesn't work on Safari
mcherkas
parents: 26751
diff changeset
   623
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_activateApplicationIgnoringOtherApps
cffe6690ee9d 8038919: Requesting focus to a modeless dialog doesn't work on Safari
mcherkas
parents: 26751
diff changeset
   624
(JNIEnv *env, jclass clazz)
cffe6690ee9d 8038919: Requesting focus to a modeless dialog doesn't work on Safari
mcherkas
parents: 26751
diff changeset
   625
{
cffe6690ee9d 8038919: Requesting focus to a modeless dialog doesn't work on Safari
mcherkas
parents: 26751
diff changeset
   626
    JNF_COCOA_ENTER(env);
cffe6690ee9d 8038919: Requesting focus to a modeless dialog doesn't work on Safari
mcherkas
parents: 26751
diff changeset
   627
    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
cffe6690ee9d 8038919: Requesting focus to a modeless dialog doesn't work on Safari
mcherkas
parents: 26751
diff changeset
   628
        if(![NSApp isActive]){
cffe6690ee9d 8038919: Requesting focus to a modeless dialog doesn't work on Safari
mcherkas
parents: 26751
diff changeset
   629
            [NSApp activateIgnoringOtherApps:YES];
cffe6690ee9d 8038919: Requesting focus to a modeless dialog doesn't work on Safari
mcherkas
parents: 26751
diff changeset
   630
        }
cffe6690ee9d 8038919: Requesting focus to a modeless dialog doesn't work on Safari
mcherkas
parents: 26751
diff changeset
   631
    }];
cffe6690ee9d 8038919: Requesting focus to a modeless dialog doesn't work on Safari
mcherkas
parents: 26751
diff changeset
   632
    JNF_COCOA_EXIT(env);
cffe6690ee9d 8038919: Requesting focus to a modeless dialog doesn't work on Safari
mcherkas
parents: 26751
diff changeset
   633
}
cffe6690ee9d 8038919: Requesting focus to a modeless dialog doesn't work on Safari
mcherkas
parents: 26751
diff changeset
   634
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   635
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   636
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   637
 * Class:     sun_awt_SunToolkit
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   638
 * Method:    closeSplashScreen
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   639
 * Signature: ()V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   640
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   641
JNIEXPORT void JNICALL
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   642
Java_sun_awt_SunToolkit_closeSplashScreen(JNIEnv *env, jclass cls)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   643
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   644
    void *hSplashLib = dlopen(0, RTLD_LAZY);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   645
    if (!hSplashLib) return;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   646
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   647
    void (*splashClose)() = dlsym(hSplashLib, "SplashClose");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   648
    if (splashClose) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   649
        splashClose();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   650
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   651
    dlclose(hSplashLib);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   652
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   653
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   654
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   655
// TODO: definitely doesn't belong here (copied from fontpath.c in the
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   656
// solaris tree)...
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   657
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   658
JNIEXPORT jstring JNICALL
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   659
Java_sun_font_FontManager_getFontPath
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   660
(JNIEnv *env, jclass obj, jboolean noType1)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   661
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   662
    return JNFNSToJavaString(env, @"/Library/Fonts");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   663
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   664
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   665
// This isn't yet used on unix, the implementation is added since shared
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   666
// code calls this method in preparation for future use.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   667
JNIEXPORT void JNICALL
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   668
Java_sun_font_FontManager_populateFontFileNameMap
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   669
(JNIEnv *env, jclass obj, jobject fontToFileMap, jobject fontToFamilyMap, jobject familyToFontListMap, jobject locale)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   670
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   671
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   672
}
25563
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   673
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   674
/*
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   675
 * Class:     sun_lwawt_macosx_LWCToolkit
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   676
 * Method:    initIDs
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   677
 * Signature: ()V
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   678
 */
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   679
JNIEXPORT void JNICALL
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   680
Java_sun_lwawt_macosx_LWCToolkit_initIDs
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   681
(JNIEnv *env, jclass klass) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   682
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   683
    JNF_COCOA_ENTER(env)
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   684
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   685
    gNumberOfButtons = sun_lwawt_macosx_LWCToolkit_BUTTONS;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   686
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   687
    jclass inputEventClazz = (*env)->FindClass(env, "java/awt/event/InputEvent");
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   688
    CHECK_NULL(inputEventClazz);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   689
    jmethodID getButtonDownMasksID = (*env)->GetStaticMethodID(env, inputEventClazz, "getButtonDownMasks", "()[I");
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   690
    CHECK_NULL(getButtonDownMasksID);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   691
    jintArray obj = (jintArray)(*env)->CallStaticObjectMethod(env, inputEventClazz, getButtonDownMasksID);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   692
    jint * tmp = (*env)->GetIntArrayElements(env, obj, JNI_FALSE);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   693
    CHECK_NULL(tmp);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   694
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   695
    gButtonDownMasks = (jint*)SAFE_SIZE_ARRAY_ALLOC(malloc, sizeof(jint), gNumberOfButtons);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   696
    if (gButtonDownMasks == NULL) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   697
        gNumberOfButtons = 0;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   698
        (*env)->ReleaseIntArrayElements(env, obj, tmp, JNI_ABORT);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   699
        JNU_ThrowOutOfMemoryError(env, NULL);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   700
        return;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   701
    }
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   702
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   703
    int i;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   704
    for (i = 0; i < gNumberOfButtons; i++) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   705
        gButtonDownMasks[i] = tmp[i];
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   706
    }
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   707
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   708
    (*env)->ReleaseIntArrayElements(env, obj, tmp, 0);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   709
    (*env)->DeleteLocalRef(env, obj);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   710
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   711
    JNF_COCOA_EXIT(env)
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   712
}
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   713
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   714
/*
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   715
 * Class:     sun_lwawt_macosx_LWCToolkit
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   716
 * Method:    initAppkit
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   717
 * Signature: (Ljava/lang/ThreadGroup;)V
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   718
 */
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   719
JNIEXPORT void JNICALL
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   720
Java_sun_lwawt_macosx_LWCToolkit_initAppkit
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   721
(JNIEnv *env, jclass klass, jobject appkitThreadGroup, jboolean headless) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   722
    JNF_COCOA_ENTER(env)
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   723
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   724
    [ThreadUtilities setAppkitThreadGroup:(*env)->NewGlobalRef(env, appkitThreadGroup)];
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   725
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   726
    // Launcher sets this env variable if -XstartOnFirstThread is specified
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   727
    char envVar[80];
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   728
    snprintf(envVar, sizeof(envVar), "JAVA_STARTED_ON_FIRST_THREAD_%d", getpid());
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   729
    if (getenv(envVar) != NULL) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   730
        forceEmbeddedMode = YES;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   731
        unsetenv(envVar);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   732
    }
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   733
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   734
    if (isSWTInWebStart(env)) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   735
        forceEmbeddedMode = YES;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   736
    }
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   737
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   738
    [AWTStarter start:headless ? YES : NO];
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   739
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   740
    JNF_COCOA_EXIT(env)
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   741
}
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   742
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   743
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   744
    OSXAPP_SetJavaVM(vm);
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   745
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   746
    // We need to let Foundation know that this is a multithreaded application, if it isn't already.
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   747
    if (![NSThread isMultiThreaded]) {
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   748
        [NSThread detachNewThreadSelector:nil toTarget:nil withObject:nil];
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   749
    }
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   750
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   751
    return JNI_VERSION_1_4;
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   752
}
248400a88627 8033367: [macosx] Appletviewer was broken in jdk8 b124
pchelko
parents: 24550
diff changeset
   753
25564
871d3490f14d 8048549: [macosx] Disable usage of system menu bar if AWT is embedded in FX
pchelko
parents: 25563
diff changeset
   754
/*
871d3490f14d 8048549: [macosx] Disable usage of system menu bar if AWT is embedded in FX
pchelko
parents: 25563
diff changeset
   755
 * Class:     sun_lwawt_macosx_LWCToolkit
871d3490f14d 8048549: [macosx] Disable usage of system menu bar if AWT is embedded in FX
pchelko
parents: 25563
diff changeset
   756
 * Method:    isEmbedded
871d3490f14d 8048549: [macosx] Disable usage of system menu bar if AWT is embedded in FX
pchelko
parents: 25563
diff changeset
   757
 * Signature: ()Z
871d3490f14d 8048549: [macosx] Disable usage of system menu bar if AWT is embedded in FX
pchelko
parents: 25563
diff changeset
   758
 */
871d3490f14d 8048549: [macosx] Disable usage of system menu bar if AWT is embedded in FX
pchelko
parents: 25563
diff changeset
   759
JNIEXPORT jboolean JNICALL
871d3490f14d 8048549: [macosx] Disable usage of system menu bar if AWT is embedded in FX
pchelko
parents: 25563
diff changeset
   760
Java_sun_lwawt_macosx_LWCToolkit_isEmbedded
871d3490f14d 8048549: [macosx] Disable usage of system menu bar if AWT is embedded in FX
pchelko
parents: 25563
diff changeset
   761
(JNIEnv *env, jclass klass) {
871d3490f14d 8048549: [macosx] Disable usage of system menu bar if AWT is embedded in FX
pchelko
parents: 25563
diff changeset
   762
    return isEmbedded ? JNI_TRUE : JNI_FALSE;
871d3490f14d 8048549: [macosx] Disable usage of system menu bar if AWT is embedded in FX
pchelko
parents: 25563
diff changeset
   763
}
871d3490f14d 8048549: [macosx] Disable usage of system menu bar if AWT is embedded in FX
pchelko
parents: 25563
diff changeset
   764