< prev index next >

src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m

Print this page




  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #import "NSApplicationAWT.h"
  27 
  28 #import <objc/runtime.h>
  29 #import <JavaRuntimeSupport/JavaRuntimeSupport.h>
  30 
  31 #import "PropertiesUtilities.h"
  32 #import "ThreadUtilities.h"
  33 #import "QueuingApplicationDelegate.h"
  34 #import "AWTIconData.h"
  35 




  36 
  37 static BOOL sUsingDefaultNIB = YES;
  38 static NSString *SHARED_FRAMEWORK_BUNDLE = @"/System/Library/Frameworks/JavaVM.framework";
  39 static id <NSApplicationDelegate> applicationDelegate = nil;
  40 static QueuingApplicationDelegate * qad = nil;
  41 
  42 // Flag used to indicate to the Plugin2 event synthesis code to do a postEvent instead of sendEvent
  43 BOOL postEventDuringEventSynthesis = NO;
  44 
  45 /**
  46  * Subtypes of NSApplicationDefined, which are used for custom events.
  47  */
  48 enum {
  49     ExecuteBlockEvent, NativeSyncQueueEvent
  50 };
  51 
  52 @implementation NSApplicationAWT
  53 
  54 - (id) init
  55 {


 415 - (void)waitForDummyEvent:(double)timeout {
 416     bool unlock = true;
 417     if (timeout >= 0) {
 418         double sec = timeout / 1000;
 419         unlock = [seenDummyEventLock lockWhenCondition:YES
 420                                beforeDate:[NSDate dateWithTimeIntervalSinceNow:sec]];
 421     } else {
 422         [seenDummyEventLock lockWhenCondition:YES];
 423     }
 424     if (unlock) {
 425         [seenDummyEventLock unlock];
 426     }
 427     [seenDummyEventLock release];
 428 
 429     seenDummyEventLock = nil;
 430 }
 431 
 432 @end
 433 
 434 
 435 void OSXAPP_SetApplicationDelegate(id <NSApplicationDelegate> delegate)
 436 {
 437 AWT_ASSERT_APPKIT_THREAD;
 438     applicationDelegate = delegate;
 439 
 440     if (NSApp != nil) {
 441         [NSApp setDelegate: applicationDelegate];
 442 
 443         if (applicationDelegate && qad) {
 444             [qad processQueuedEventsWithTargetDelegate: applicationDelegate];
 445             qad = nil;
 446         }
 447     }
 448 }
 449 


  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #import "NSApplicationAWT.h"
  27 
  28 #import <objc/runtime.h>
  29 #import <JavaRuntimeSupport/JavaRuntimeSupport.h>
  30 
  31 #import "PropertiesUtilities.h"
  32 #import "ThreadUtilities.h"
  33 #import "QueuingApplicationDelegate.h"
  34 #import "AWTIconData.h"
  35 
  36 /*
  37  * Declare library specific JNI_Onload entry if static build
  38  */
  39 DEF_STATIC_JNI_OnLoad
  40 
  41 static BOOL sUsingDefaultNIB = YES;
  42 static NSString *SHARED_FRAMEWORK_BUNDLE = @"/System/Library/Frameworks/JavaVM.framework";
  43 static id <NSApplicationDelegate> applicationDelegate = nil;
  44 static QueuingApplicationDelegate * qad = nil;
  45 
  46 // Flag used to indicate to the Plugin2 event synthesis code to do a postEvent instead of sendEvent
  47 BOOL postEventDuringEventSynthesis = NO;
  48 
  49 /**
  50  * Subtypes of NSApplicationDefined, which are used for custom events.
  51  */
  52 enum {
  53     ExecuteBlockEvent, NativeSyncQueueEvent
  54 };
  55 
  56 @implementation NSApplicationAWT
  57 
  58 - (id) init
  59 {


 419 - (void)waitForDummyEvent:(double)timeout {
 420     bool unlock = true;
 421     if (timeout >= 0) {
 422         double sec = timeout / 1000;
 423         unlock = [seenDummyEventLock lockWhenCondition:YES
 424                                beforeDate:[NSDate dateWithTimeIntervalSinceNow:sec]];
 425     } else {
 426         [seenDummyEventLock lockWhenCondition:YES];
 427     }
 428     if (unlock) {
 429         [seenDummyEventLock unlock];
 430     }
 431     [seenDummyEventLock release];
 432 
 433     seenDummyEventLock = nil;
 434 }
 435 
 436 @end
 437 
 438 
 439 void OSXAPP_SetApplicationDelegate(id <NSApplicationDelegate> newdelegate)
 440 {
 441 AWT_ASSERT_APPKIT_THREAD;
 442     applicationDelegate = newdelegate;
 443 
 444     if (NSApp != nil) {
 445         [NSApp setDelegate: applicationDelegate];
 446 
 447         if (applicationDelegate && qad) {
 448             [qad processQueuedEventsWithTargetDelegate: applicationDelegate];
 449             qad = nil;
 450         }
 451     }
 452 }
 453 
< prev index next >