diff --git a/src/macosx/classes/sun/lwawt/macosx/CToolkitThreadBlockedHandler.java b/src/macosx/classes/sun/lwawt/macosx/CToolkitThreadBlockedHandler.java index 95d15a8feaa5fa307eb6a2184b2dc413060d58af..94a74e5174bf8f435d04ab6082e71a452e89fc68 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CToolkitThreadBlockedHandler.java +++ b/src/macosx/classes/sun/lwawt/macosx/CToolkitThreadBlockedHandler.java @@ -41,10 +41,11 @@ final class CToolkitThreadBlockedHandler implements ToolkitThreadBlockedHandler } public void enter() { - toolkit.startNativeNestedEventLoop(); + // Execute the next AppKit event while we are waiting for system to + // finish our request - this will save us from biting our own tail + toolkit.executeNextAppKitEvent(); } public void exit() { - toolkit.stopNativeNestedEventLoop(); } } diff --git a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java index 0e5888ee3de61440fe2508ec27d8446d1304ac67..d3565b845ad0a0bbae7accf3405eb82b794eabe2 100644 --- a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java +++ b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java @@ -63,9 +63,7 @@ public class LWCToolkit extends LWToolkit { private static native void initIDs(); - static native void startNativeNestedEventLoop(); - - static native void stopNativeNestedEventLoop(); + static native void executeNextAppKitEvent(); private static CInputMethodDescriptor sInputMethodDescriptor; diff --git a/src/macosx/native/sun/awt/LWCToolkit.m b/src/macosx/native/sun/awt/LWCToolkit.m index 173154a151c38f0d9113aa3c64e37116561a6aa7..f9b17fca6b7cfd3ba9aea20f61cf2b11eaaf01d0 100644 --- a/src/macosx/native/sun/awt/LWCToolkit.m +++ b/src/macosx/native/sun/awt/LWCToolkit.m @@ -42,7 +42,6 @@ jint* gButtonDownMasks; @implementation AWTToolkit static long eventCount; -static bool shouldKeepRunningNestedLoop = NO; + (long) getEventCount{ return eventCount; @@ -460,33 +459,18 @@ Java_sun_font_FontManager_populateFontFileNameMap /* * Class: sun_lwawt_macosx_LWCToolkit - * Method: startNativeNestedEventLoop + * Method: executeNextAppKitEvent * Signature: ()V */ -JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_startNativeNestedEventLoop +JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_executeNextAppKitEvent (JNIEnv *env, jclass cls) { - if(!shouldKeepRunningNestedLoop) { - NSRunLoop *theRL = [NSRunLoop currentRunLoop]; - NSApplication * app = [NSApplication sharedApplication]; - shouldKeepRunningNestedLoop = YES; - while (shouldKeepRunningNestedLoop && [theRL runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]) - { - NSEvent * event = [app nextEventMatchingMask: 0xFFFFFFFF untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES]; - if (event != nil) { - [app sendEvent: event]; - } - } + // Simply get the next event in native loop and pass it to execution + // We'll be called repeatedly so there's no need to block here + NSRunLoop *theRL = [NSRunLoop currentRunLoop]; + NSApplication * app = [NSApplication sharedApplication]; + NSEvent * event = [app nextEventMatchingMask: 0xFFFFFFFF untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES]; + if (event != nil) { + [app sendEvent: event]; } } - -/* - * Class: sun_lwawt_macosx_LWCToolkit - * Method: stopNativeNestedEventLoop - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_stopNativeNestedEventLoop -(JNIEnv *env, jclass cls) -{ - shouldKeepRunningNestedLoop = NO; -} diff --git a/src/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java b/src/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java index 360bb9a63a69f7ce5f31f7b7affdd35ae41f7f52..302a6dbc62e71a6121472b906660ee5677ead4f7 100644 --- a/src/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java +++ b/src/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java @@ -498,7 +498,7 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer, postDropTargetEvent(component, x, y, dropAction, actions, formats, nativeCtxt, SunDropTargetEvent.MOUSE_DROPPED, - !SunDropTargetContextPeer.DISPATCH_SYNC); + SunDropTargetContextPeer.DISPATCH_SYNC); } /**