diff options
author | Anton Tarasov <anton.tarasov@jetbrains.com> | 2017-07-10 18:14:16 +0300 |
---|---|---|
committer | Anton Tarasov <anton.tarasov@jetbrains.com> | 2017-07-10 18:14:54 +0300 |
commit | a55989991ed3deadd940cf77a830e7a7b8bd1eed (patch) | |
tree | aa8acd8d0a91090de2979e65e1edfbedd47a93c3 /src/macosx | |
parent | 7d8b4958a44d50bfcd5e628ce47df76c20674f39 (diff) | |
download | jdk8u_jdk-a55989991ed3deadd940cf77a830e7a7b8bd1eed.tar.gz |
JRE-420 bring back the fix JDK-8068886jb8u152-b941.1jb8u152-b941jb8u152-b940
Diffstat (limited to 'src/macosx')
-rw-r--r-- | src/macosx/native/sun/osxapp/NSApplicationAWT.h | 1 | ||||
-rw-r--r-- | src/macosx/native/sun/osxapp/NSApplicationAWT.m | 30 |
2 files changed, 30 insertions, 1 deletions
diff --git a/src/macosx/native/sun/osxapp/NSApplicationAWT.h b/src/macosx/native/sun/osxapp/NSApplicationAWT.h index 9269295060..99c7d63175 100644 --- a/src/macosx/native/sun/osxapp/NSApplicationAWT.h +++ b/src/macosx/native/sun/osxapp/NSApplicationAWT.h @@ -37,6 +37,7 @@ - (void) registerWithProcessManager; - (void) setDockIconWithEnv:(JNIEnv *)env; - (void) postDummyEvent; +- (void) postRunnableEvent:(void (^)())block; - (void) waitForDummyEvent; + (void) runAWTLoopWithApp:(NSApplication*)app; diff --git a/src/macosx/native/sun/osxapp/NSApplicationAWT.m b/src/macosx/native/sun/osxapp/NSApplicationAWT.m index 5155d83429..3717b609dc 100644 --- a/src/macosx/native/sun/osxapp/NSApplicationAWT.m +++ b/src/macosx/native/sun/osxapp/NSApplicationAWT.m @@ -337,9 +337,13 @@ AWT_ASSERT_APPKIT_THREAD; - (void)sendEvent:(NSEvent *)event { - if ([event type] == NSApplicationDefined && TS_EQUAL([event timestamp], dummyEventTimestamp)) { + if ([event type] == NSApplicationDefined && TS_EQUAL([event timestamp], dummyEventTimestamp) && [event subtype] == 0) { [seenDummyEventLock lockWhenCondition:NO]; [seenDummyEventLock unlockWithCondition:YES]; + } else if ([event type] == NSApplicationDefined && [event subtype] == 777) { + void (^block)() = (void (^)()) [event data1]; + block(); + [block release]; } else if ([event type] == NSKeyUp && ([event modifierFlags] & NSCommandKeyMask)) { // Cocoa won't send us key up event when releasing a key while Cmd is down, // so we have to do it ourselves. @@ -349,6 +353,30 @@ AWT_ASSERT_APPKIT_THREAD; } } +/* + * Posts the block to the AppKit event queue which will be executed + * on the main AppKit loop. + * While running nested loops this event will be ignored. + */ +- (void)postRunnableEvent:(void (^)())block +{ + void (^copy)() = [block copy]; + NSInteger encode = (NSInteger) copy; + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSEvent* event = [NSEvent otherEventWithType: NSApplicationDefined + location: NSMakePoint(0,0) + modifierFlags: 0 + timestamp: 0 + windowNumber: 0 + context: nil + subtype: 777 + data1: encode + data2: 0]; + + [NSApp postEvent: event atStart: NO]; + [pool drain]; +} + - (void)postDummyEvent { seenDummyEventLock = [[NSConditionLock alloc] initWithCondition:NO]; dummyEventTimestamp = [NSProcessInfo processInfo].systemUptime; |