src/macosx/native/sun/osxapp/NSApplicationAWT.m

Print this page




 351 }
 352 
 353 - (void)postDummyEvent {
 354     seenDummyEventLock = [[NSConditionLock alloc] initWithCondition:NO];
 355     dummyEventTimestamp = [NSProcessInfo processInfo].systemUptime;
 356     
 357     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];    
 358     NSEvent* event = [NSEvent otherEventWithType: NSApplicationDefined
 359                                         location: NSMakePoint(0,0)
 360                                    modifierFlags: 0
 361                                        timestamp: dummyEventTimestamp
 362                                     windowNumber: 0
 363                                          context: nil
 364                                          subtype: 0
 365                                            data1: 0
 366                                            data2: 0];
 367     [NSApp postEvent: event atStart: NO];
 368     [pool drain];
 369 }
 370 
 371 - (void)waitForDummyEvent {
 372     [seenDummyEventLock lockWhenCondition:YES];


 373     [seenDummyEventLock unlock];

 374     [seenDummyEventLock release];
 375 
 376     seenDummyEventLock = nil;

 377 }
 378 
 379 @end
 380 
 381 
 382 void OSXAPP_SetApplicationDelegate(id <NSApplicationDelegate> delegate)
 383 {
 384 AWT_ASSERT_APPKIT_THREAD;
 385     applicationDelegate = delegate;
 386 
 387     if (NSApp != nil) {
 388         [NSApp setDelegate: applicationDelegate];
 389 
 390         if (applicationDelegate && qad) {
 391             [qad processQueuedEventsWithTargetDelegate: applicationDelegate];
 392             qad = nil;
 393         }
 394     }
 395 }
 396 


 351 }
 352 
 353 - (void)postDummyEvent {
 354     seenDummyEventLock = [[NSConditionLock alloc] initWithCondition:NO];
 355     dummyEventTimestamp = [NSProcessInfo processInfo].systemUptime;
 356     
 357     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];    
 358     NSEvent* event = [NSEvent otherEventWithType: NSApplicationDefined
 359                                         location: NSMakePoint(0,0)
 360                                    modifierFlags: 0
 361                                        timestamp: dummyEventTimestamp
 362                                     windowNumber: 0
 363                                          context: nil
 364                                          subtype: 0
 365                                            data1: 0
 366                                            data2: 0];
 367     [NSApp postEvent: event atStart: NO];
 368     [pool drain];
 369 }
 370 
 371 - (BOOL)waitForDummyEvent:(long)timeout {
 372     BOOL result = [seenDummyEventLock lockWhenCondition:YES
 373                                              beforeDate:[NSDate dateWithTimeIntervalSinceNow:timeout / 1000.0]];
 374     if (result) {
 375         [seenDummyEventLock unlock];
 376     }
 377     [seenDummyEventLock release];

 378     seenDummyEventLock = nil;
 379     return result;
 380 }
 381 
 382 @end
 383 
 384 
 385 void OSXAPP_SetApplicationDelegate(id <NSApplicationDelegate> delegate)
 386 {
 387 AWT_ASSERT_APPKIT_THREAD;
 388     applicationDelegate = delegate;
 389 
 390     if (NSApp != nil) {
 391         [NSApp setDelegate: applicationDelegate];
 392 
 393         if (applicationDelegate && qad) {
 394             [qad processQueuedEventsWithTargetDelegate: applicationDelegate];
 395             qad = nil;
 396         }
 397     }
 398 }
 399