26 #import <dlfcn.h> 27 #import <pthread.h> 28 #import <objc/runtime.h> 29 #import <Cocoa/Cocoa.h> 30 #import <Security/AuthSession.h> 31 32 #include "jni_util.h" 33 #import "LWCToolkit.h" 34 #import "ThreadUtilities.h" 35 #import "CSystemColors.h" 36 #import "NSApplicationAWT.h" 37 #import "PropertiesUtilities.h" 38 #import "ApplicationDelegate.h" 39 40 #import "sun_lwawt_macosx_LWCToolkit.h" 41 42 #import "sizecalc.h" 43 44 #import <JavaRuntimeSupport/JavaRuntimeSupport.h> 45 46 int gNumberOfButtons; 47 jint* gButtonDownMasks; 48 49 // Indicates that the app has been started with -XstartOnFirstThread 50 // (directly or via WebStart settings), and AWT should not run its 51 // own event loop in this mode. Even if a loop isn't running yet, 52 // we expect an embedder (e.g. SWT) to start it some time later. 53 static BOOL forceEmbeddedMode = NO; 54 55 // Indicates if awt toolkit is embedded into another UI toolkit 56 static BOOL isEmbedded = NO; 57 58 // This is the data necessary to have JNI_OnLoad wait for AppKit to start. 59 static BOOL sAppKitStarted = NO; 60 static pthread_mutex_t sAppKitStarted_mutex = PTHREAD_MUTEX_INITIALIZER; 61 static pthread_cond_t sAppKitStarted_cv = PTHREAD_COND_INITIALIZER; 62 63 @implementation AWTToolkit 64 65 static long eventCount; 66 67 + (long) getEventCount{ 68 return eventCount; 69 } 70 71 + (void) eventCountPlusPlus{ 72 eventCount++; 73 } 74 75 @end 76 77 78 @interface AWTRunLoopObject : NSObject { 79 BOOL _shouldEndRunLoop; 80 } 81 @end 82 83 @implementation AWTRunLoopObject 84 85 - (id) init { 86 self = [super init]; 87 if (self != nil) { 88 _shouldEndRunLoop = NO; 89 } 90 return self; 91 } 92 93 - (BOOL) shouldEndRunLoop { 94 return _shouldEndRunLoop; | 26 #import <dlfcn.h> 27 #import <pthread.h> 28 #import <objc/runtime.h> 29 #import <Cocoa/Cocoa.h> 30 #import <Security/AuthSession.h> 31 32 #include "jni_util.h" 33 #import "LWCToolkit.h" 34 #import "ThreadUtilities.h" 35 #import "CSystemColors.h" 36 #import "NSApplicationAWT.h" 37 #import "PropertiesUtilities.h" 38 #import "ApplicationDelegate.h" 39 40 #import "sun_lwawt_macosx_LWCToolkit.h" 41 42 #import "sizecalc.h" 43 44 #import <JavaRuntimeSupport/JavaRuntimeSupport.h> 45 46 // SCROLL PHASE STATE 47 #define SCROLL_PHASE_UNSUPPORTED 1 48 #define SCROLL_PHASE_BEGAN 2 49 #define SCROLL_PHASE_CONTINUED 3 50 #define SCROLL_PHASE_CANCELLED 4 51 #define SCROLL_PHASE_ENDED 5 52 53 int gNumberOfButtons; 54 jint* gButtonDownMasks; 55 56 // Indicates that the app has been started with -XstartOnFirstThread 57 // (directly or via WebStart settings), and AWT should not run its 58 // own event loop in this mode. Even if a loop isn't running yet, 59 // we expect an embedder (e.g. SWT) to start it some time later. 60 static BOOL forceEmbeddedMode = NO; 61 62 // Indicates if awt toolkit is embedded into another UI toolkit 63 static BOOL isEmbedded = NO; 64 65 // This is the data necessary to have JNI_OnLoad wait for AppKit to start. 66 static BOOL sAppKitStarted = NO; 67 static pthread_mutex_t sAppKitStarted_mutex = PTHREAD_MUTEX_INITIALIZER; 68 static pthread_cond_t sAppKitStarted_cv = PTHREAD_COND_INITIALIZER; 69 70 @implementation AWTToolkit 71 72 static long eventCount; 73 74 + (long) getEventCount{ 75 return eventCount; 76 } 77 78 + (void) eventCountPlusPlus{ 79 eventCount++; 80 } 81 82 + (jint) scrollStateWithEvent: (NSEvent*) event { 83 84 if ([event type] != NSScrollWheel) { 85 return 0; 86 } 87 88 NSEventPhase phase = [event phase]; 89 NSEventPhase momentumPhase = [event momentumPhase]; 90 91 if (!phase && !momentumPhase) return SCROLL_PHASE_UNSUPPORTED; 92 switch (phase) { 93 case NSEventPhaseBegan: return SCROLL_PHASE_BEGAN; 94 case NSEventPhaseCancelled: return SCROLL_PHASE_CANCELLED; 95 case NSEventPhaseEnded: return SCROLL_PHASE_ENDED; 96 } 97 return SCROLL_PHASE_CONTINUED; 98 } 99 @end 100 101 102 @interface AWTRunLoopObject : NSObject { 103 BOOL _shouldEndRunLoop; 104 } 105 @end 106 107 @implementation AWTRunLoopObject 108 109 - (id) init { 110 self = [super init]; 111 if (self != nil) { 112 _shouldEndRunLoop = NO; 113 } 114 return self; 115 } 116 117 - (BOOL) shouldEndRunLoop { 118 return _shouldEndRunLoop; |