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 default: return SCROLL_PHASE_CONTINUED; 97 } 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 { | 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_MOMENTUM_BEGAN 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 if ([event phase]) { 89 // process a phase of manual scrolling 90 switch ([event phase]) { 91 case NSEventPhaseBegan: return SCROLL_PHASE_BEGAN; 92 case NSEventPhaseCancelled: return SCROLL_PHASE_ENDED; 93 case NSEventPhaseEnded: return SCROLL_PHASE_ENDED; 94 default: return SCROLL_PHASE_CONTINUED; 95 } 96 } 97 98 if ([event momentumPhase]) { 99 // process a phase of automatic scrolling 100 switch ([event momentumPhase]) { 101 case NSEventPhaseBegan: return SCROLL_PHASE_MOMENTUM_BEGAN; 102 case NSEventPhaseCancelled: return SCROLL_PHASE_ENDED; 103 case NSEventPhaseEnded: return SCROLL_PHASE_ENDED; 104 default: return SCROLL_PHASE_CONTINUED; 105 } 106 } 107 // phase and momentum phase both are not set 108 return SCROLL_PHASE_UNSUPPORTED; 109 } 110 111 + (BOOL) hasPreciseScrollingDeltas: (NSEvent*) event { 112 return [event type] == NSScrollWheel 113 && [event respondsToSelector:@selector(hasPreciseScrollingDeltas)] 114 && [event hasPreciseScrollingDeltas]; 115 } 116 @end 117 118 119 @interface AWTRunLoopObject : NSObject { 120 BOOL _shouldEndRunLoop; 121 } 122 @end 123 124 @implementation AWTRunLoopObject 125 126 - (id) init { 127 self = [super init]; 128 if (self != nil) { 129 _shouldEndRunLoop = NO; 130 } 131 return self; 132 } 133 134 - (BOOL) shouldEndRunLoop { |