jdk/src/macosx/native/sun/awt/LWCToolkit.m
changeset 13004 3774b4225633
parent 12641 40df38d36cb4
child 13991 e62879b84a14
equal deleted inserted replaced
13003:a30d38cef987 13004:3774b4225633
    40 jint* gButtonDownMasks;
    40 jint* gButtonDownMasks;
    41 
    41 
    42 @implementation AWTToolkit
    42 @implementation AWTToolkit
    43 
    43 
    44 static long eventCount;
    44 static long eventCount;
    45 static bool shouldKeepRunningNestedLoop = NO;
       
    46 
    45 
    47 + (long) getEventCount{
    46 + (long) getEventCount{
    48     return eventCount;
    47     return eventCount;
    49 }
    48 }
    50 
    49 
   458 
   457 
   459 }
   458 }
   460 
   459 
   461 /*
   460 /*
   462  * Class:     sun_lwawt_macosx_LWCToolkit
   461  * Class:     sun_lwawt_macosx_LWCToolkit
   463  * Method:    startNativeNestedEventLoop
   462  * Method:    executeNextAppKitEvent
   464  * Signature: ()V
   463  * Signature: ()V
   465  */
   464  */
   466 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_startNativeNestedEventLoop
   465 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_executeNextAppKitEvent
   467 (JNIEnv *env, jclass cls)
   466 (JNIEnv *env, jclass cls)
   468 {
   467 {
   469     if(!shouldKeepRunningNestedLoop) {
   468     // Simply get the next event in native loop and pass it to execution
   470         NSRunLoop *theRL = [NSRunLoop currentRunLoop];
   469     // We'll be called repeatedly so there's no need to block here
   471         NSApplication * app = [NSApplication sharedApplication];
   470     NSRunLoop *theRL = [NSRunLoop currentRunLoop];
   472         shouldKeepRunningNestedLoop = YES;
   471     NSApplication * app = [NSApplication sharedApplication];
   473         while (shouldKeepRunningNestedLoop && [theRL runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]])
   472     NSEvent * event = [app nextEventMatchingMask: 0xFFFFFFFF untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES];
   474         {
   473     if (event != nil) {
   475             NSEvent * event = [app nextEventMatchingMask: 0xFFFFFFFF untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES];
   474         [app sendEvent: event];
   476             if (event != nil) {
   475     }
   477                 [app sendEvent: event];
   476 }
   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 }