< prev index next >
src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m
Print this page
@@ -347,10 +347,11 @@
if ([event type] == NSApplicationDefined
&& TS_EQUAL([event timestamp], dummyEventTimestamp)
&& [event subtype] == NativeSyncQueueEvent) {
[seenDummyEventLock lockWhenCondition:NO];
[seenDummyEventLock unlockWithCondition:YES];
+
} else if ([event type] == NSApplicationDefined && [event subtype] == ExecuteBlockEvent) {
void (^block)() = (void (^)()) [event data1];
block();
[block release];
} else if ([event type] == NSKeyUp && ([event modifierFlags] & NSCommandKeyMask)) {
@@ -385,13 +386,11 @@
[NSApp postEvent: event atStart: NO];
[pool drain];
}
-
-
-- (void)postDummyEvent {
+- (void)postDummyEvent:(bool)useCocoa {
seenDummyEventLock = [[NSConditionLock alloc] initWithCondition:NO];
dummyEventTimestamp = [NSProcessInfo processInfo].systemUptime;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSEvent* event = [NSEvent otherEventWithType: NSApplicationDefined
@@ -401,23 +400,32 @@
windowNumber: 0
context: nil
subtype: NativeSyncQueueEvent
data1: 0
data2: 0];
- [NSApp postEvent: event atStart: NO];
+ if (useCocoa) {
+ [NSApp postEvent:event atStart:NO];
+ } else {
+ ProcessSerialNumber psn;
+ GetCurrentProcess(&psn);
+ CGEventPostToPSN(&psn, [event CGEvent]);
+ }
[pool drain];
}
-- (void)waitForDummyEvent:(long long) timeout {
+- (void)waitForDummyEvent:(double)timeout {
+ bool unlock = true;
if (timeout >= 0) {
- double sec = ((double) timeout)/1000;
- [seenDummyEventLock lockWhenCondition:YES
+ double sec = timeout / 1000;
+ unlock = [seenDummyEventLock lockWhenCondition:YES
beforeDate:[NSDate dateWithTimeIntervalSinceNow:sec]];
} else {
[seenDummyEventLock lockWhenCondition:YES];
}
+ if (unlock) {
[seenDummyEventLock unlock];
+ }
[seenDummyEventLock release];
seenDummyEventLock = nil;
}
< prev index next >