< prev index next >

src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 368,384 **** * Signature: (J)Z */ JNIEXPORT jboolean JNICALL Java_sun_lwawt_macosx_LWCToolkit_nativeSyncQueue (JNIEnv *env, jobject self, jlong timeout) { ! int currentEventNum = [AWTToolkit getEventCount]; NSApplication* sharedApp = [NSApplication sharedApplication]; if ([sharedApp isKindOfClass:[NSApplicationAWT class]]) { NSApplicationAWT* theApp = (NSApplicationAWT*)sharedApp; ! [theApp postDummyEvent]; ! [theApp waitForDummyEvent:timeout]; } else { // could happen if we are embedded inside SWT application, // in this case just spin a single empty block through // the event loop to give it a chance to process pending events [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){}]; --- 368,394 ---- * Signature: (J)Z */ JNIEXPORT jboolean JNICALL Java_sun_lwawt_macosx_LWCToolkit_nativeSyncQueue (JNIEnv *env, jobject self, jlong timeout) { ! long currentEventNum = [AWTToolkit getEventCount]; NSApplication* sharedApp = [NSApplication sharedApplication]; if ([sharedApp isKindOfClass:[NSApplicationAWT class]]) { NSApplicationAWT* theApp = (NSApplicationAWT*)sharedApp; ! // We use two different API to post events to the application, ! // - [NSApplication postEvent] ! // - CGEventPost(), see CRobot.m ! // It was found that if we post an event via CGEventPost in robot and ! // immediately after this we will post the second event via ! // [NSApp postEvent] then sometimes the second event will be handled ! // first. The opposite isn't proved, but we use both here to be safer. ! [theApp postDummyEvent:false]; ! [theApp waitForDummyEvent:timeout / 2.0]; ! [theApp postDummyEvent:true]; ! [theApp waitForDummyEvent:timeout / 2.0]; ! } else { // could happen if we are embedded inside SWT application, // in this case just spin a single empty block through // the event loop to give it a chance to process pending events [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){}];
< prev index next >