src/macosx/native/sun/awt/LWCToolkit.m

Print this page




  25 
  26 #import <dlfcn.h>
  27 #import <JavaNativeFoundation/JavaNativeFoundation.h>
  28 
  29 #include "jni_util.h"
  30 #import "CMenuBar.h"
  31 #import "InitIDs.h"
  32 #import "LWCToolkit.h"
  33 #import "ThreadUtilities.h"
  34 #import "AWT_debug.h"
  35 #import "CSystemColors.h"
  36 
  37 #import "sun_lwawt_macosx_LWCToolkit.h"
  38 
  39 int gNumberOfButtons;
  40 jint* gButtonDownMasks;
  41 
  42 @implementation AWTToolkit
  43 
  44 static long eventCount;
  45 static bool shouldKeepRunningNestedLoop = NO;
  46 
  47 + (long) getEventCount{
  48     return eventCount;
  49 }
  50 
  51 + (void) eventCountPlusPlus{
  52     eventCount++;
  53 }
  54 
  55 @end
  56 
  57 
  58 @interface AWTRunLoopObject : NSObject {
  59     BOOL _shouldEndRunLoop;
  60 }
  61 @end
  62 
  63 @implementation AWTRunLoopObject
  64 
  65 - (id) init {


 449     return JNFNSToJavaString(env, @"/Library/Fonts");
 450 }
 451 
 452 // This isn't yet used on unix, the implementation is added since shared
 453 // code calls this method in preparation for future use.
 454 JNIEXPORT void JNICALL
 455 Java_sun_font_FontManager_populateFontFileNameMap
 456 (JNIEnv *env, jclass obj, jobject fontToFileMap, jobject fontToFamilyMap, jobject familyToFontListMap, jobject locale)
 457 {
 458 
 459 }
 460 
 461 /*
 462  * Class:     sun_lwawt_macosx_LWCToolkit
 463  * Method:    startNativeNestedEventLoop
 464  * Signature: ()V
 465  */
 466 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_startNativeNestedEventLoop
 467 (JNIEnv *env, jclass cls)
 468 {
 469     if(!shouldKeepRunningNestedLoop) {

 470         NSRunLoop *theRL = [NSRunLoop currentRunLoop];
 471         NSApplication * app = [NSApplication sharedApplication];
 472         shouldKeepRunningNestedLoop = YES;
 473         while (shouldKeepRunningNestedLoop && [theRL runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]])
 474         {
 475             NSEvent * event = [app nextEventMatchingMask: 0xFFFFFFFF untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES];
 476             if (event != nil) {
 477                 [app sendEvent: event];
 478             }
 479         }
 480     }
 481 }
 482 
 483 /*
 484  * Class:     sun_lwawt_macosx_LWCToolkit
 485  * Method:    stopNativeNestedEventLoop
 486  * Signature: ()V
 487  */
 488 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_stopNativeNestedEventLoop
 489 (JNIEnv *env, jclass cls)
 490 {
 491     shouldKeepRunningNestedLoop = NO;
 492 }


  25 
  26 #import <dlfcn.h>
  27 #import <JavaNativeFoundation/JavaNativeFoundation.h>
  28 
  29 #include "jni_util.h"
  30 #import "CMenuBar.h"
  31 #import "InitIDs.h"
  32 #import "LWCToolkit.h"
  33 #import "ThreadUtilities.h"
  34 #import "AWT_debug.h"
  35 #import "CSystemColors.h"
  36 
  37 #import "sun_lwawt_macosx_LWCToolkit.h"
  38 
  39 int gNumberOfButtons;
  40 jint* gButtonDownMasks;
  41 
  42 @implementation AWTToolkit
  43 
  44 static long eventCount;

  45 
  46 + (long) getEventCount{
  47     return eventCount;
  48 }
  49 
  50 + (void) eventCountPlusPlus{
  51     eventCount++;
  52 }
  53 
  54 @end
  55 
  56 
  57 @interface AWTRunLoopObject : NSObject {
  58     BOOL _shouldEndRunLoop;
  59 }
  60 @end
  61 
  62 @implementation AWTRunLoopObject
  63 
  64 - (id) init {


 448     return JNFNSToJavaString(env, @"/Library/Fonts");
 449 }
 450 
 451 // This isn't yet used on unix, the implementation is added since shared
 452 // code calls this method in preparation for future use.
 453 JNIEXPORT void JNICALL
 454 Java_sun_font_FontManager_populateFontFileNameMap
 455 (JNIEnv *env, jclass obj, jobject fontToFileMap, jobject fontToFamilyMap, jobject familyToFontListMap, jobject locale)
 456 {
 457 
 458 }
 459 
 460 /*
 461  * Class:     sun_lwawt_macosx_LWCToolkit
 462  * Method:    startNativeNestedEventLoop
 463  * Signature: ()V
 464  */
 465 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_startNativeNestedEventLoop
 466 (JNIEnv *env, jclass cls)
 467 {
 468     // Simply get the next event in native loop and pass it to execution
 469     // We'll be called repeatedly so there's no need to block here
 470     NSRunLoop *theRL = [NSRunLoop currentRunLoop];
 471     NSApplication * app = [NSApplication sharedApplication];



 472     NSEvent * event = [app nextEventMatchingMask: 0xFFFFFFFF untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES];
 473     if (event != nil) {
 474         [app sendEvent: event];
 475     }


 476 }
 477 
 478 /*
 479  * Class:     sun_lwawt_macosx_LWCToolkit
 480  * Method:    stopNativeNestedEventLoop
 481  * Signature: ()V
 482  */
 483 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_stopNativeNestedEventLoop
 484 (JNIEnv *env, jclass cls)
 485 {
 486 //    At this moment it seems that this method should be no-op
 487 }