< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  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


 315 }
 316 
 317 - (BOOL)usingDefaultNib {
 318     return sUsingDefaultNIB;
 319 }
 320 
 321 - (void)orderFrontStandardAboutPanelWithOptions:(NSDictionary *)optionsDictionary {
 322     if (!optionsDictionary) {
 323         optionsDictionary = [NSMutableDictionary dictionaryWithCapacity:2];
 324         [optionsDictionary setValue:[[[[[NSApp mainMenu] itemAtIndex:0] submenu] itemAtIndex:0] title] forKey:@"ApplicationName"];
 325         if (![NSImage imageNamed:@"NSApplicationIcon"]) {
 326             [optionsDictionary setValue:[NSApp applicationIconImage] forKey:@"ApplicationIcon"];
 327         }
 328     }
 329 
 330     [super orderFrontStandardAboutPanelWithOptions:optionsDictionary];
 331 }
 332 
 333 #define DRAGMASK (NSMouseMovedMask | NSLeftMouseDraggedMask | NSRightMouseDownMask | NSRightMouseDraggedMask | NSLeftMouseUpMask | NSRightMouseUpMask | NSFlagsChangedMask | NSKeyDownMask)
 334 
 335 - (NSEvent *)nextEventMatchingMask:(NSUInteger)mask untilDate:(NSDate *)expiration inMode:(NSString *)mode dequeue:(BOOL)deqFlag {
 336     if (mask == DRAGMASK && [((NSString *)kCFRunLoopDefaultMode) isEqual:mode]) {
 337         postEventDuringEventSynthesis = YES;
 338     }
 339 
 340     NSEvent *event = [super nextEventMatchingMask:mask untilDate:expiration inMode:mode dequeue: deqFlag];
 341     postEventDuringEventSynthesis = NO;
 342 
 343     return event;
 344 }
 345 
 346 // NSTimeInterval has microseconds precision
 347 #define TS_EQUAL(ts1, ts2) (fabs((ts1) - (ts2)) < 1e-6)
 348 
 349 - (void)sendEvent:(NSEvent *)event
 350 {
 351     if ([event type] == NSApplicationDefined
 352             && TS_EQUAL([event timestamp], dummyEventTimestamp)
 353             && [event subtype] == NativeSyncQueueEvent) {
 354         [seenDummyEventLock lockWhenCondition:NO];
 355         [seenDummyEventLock unlockWithCondition:YES];


 432     seenDummyEventLock = nil;
 433 }
 434 
 435 @end
 436 
 437 
 438 void OSXAPP_SetApplicationDelegate(id <NSApplicationDelegate> newdelegate)
 439 {
 440 AWT_ASSERT_APPKIT_THREAD;
 441     applicationDelegate = newdelegate;
 442 
 443     if (NSApp != nil) {
 444         [NSApp setDelegate: applicationDelegate];
 445 
 446         if (applicationDelegate && qad) {
 447             [qad processQueuedEventsWithTargetDelegate: applicationDelegate];
 448             qad = nil;
 449         }
 450     }
 451 }
 452 
   1 /*
   2  * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  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


 315 }
 316 
 317 - (BOOL)usingDefaultNib {
 318     return sUsingDefaultNIB;
 319 }
 320 
 321 - (void)orderFrontStandardAboutPanelWithOptions:(NSDictionary *)optionsDictionary {
 322     if (!optionsDictionary) {
 323         optionsDictionary = [NSMutableDictionary dictionaryWithCapacity:2];
 324         [optionsDictionary setValue:[[[[[NSApp mainMenu] itemAtIndex:0] submenu] itemAtIndex:0] title] forKey:@"ApplicationName"];
 325         if (![NSImage imageNamed:@"NSApplicationIcon"]) {
 326             [optionsDictionary setValue:[NSApp applicationIconImage] forKey:@"ApplicationIcon"];
 327         }
 328     }
 329 
 330     [super orderFrontStandardAboutPanelWithOptions:optionsDictionary];
 331 }
 332 
 333 #define DRAGMASK (NSMouseMovedMask | NSLeftMouseDraggedMask | NSRightMouseDownMask | NSRightMouseDraggedMask | NSLeftMouseUpMask | NSRightMouseUpMask | NSFlagsChangedMask | NSKeyDownMask)
 334 
 335 - (NSEvent *)nextEventMatchingMask:(NSEventMask)mask untilDate:(NSDate *)expiration inMode:(NSString *)mode dequeue:(BOOL)deqFlag {
 336     if (mask == DRAGMASK && [((NSString *)kCFRunLoopDefaultMode) isEqual:mode]) {
 337         postEventDuringEventSynthesis = YES;
 338     }
 339 
 340     NSEvent *event = [super nextEventMatchingMask:mask untilDate:expiration inMode:mode dequeue: deqFlag];
 341     postEventDuringEventSynthesis = NO;
 342 
 343     return event;
 344 }
 345 
 346 // NSTimeInterval has microseconds precision
 347 #define TS_EQUAL(ts1, ts2) (fabs((ts1) - (ts2)) < 1e-6)
 348 
 349 - (void)sendEvent:(NSEvent *)event
 350 {
 351     if ([event type] == NSApplicationDefined
 352             && TS_EQUAL([event timestamp], dummyEventTimestamp)
 353             && [event subtype] == NativeSyncQueueEvent) {
 354         [seenDummyEventLock lockWhenCondition:NO];
 355         [seenDummyEventLock unlockWithCondition:YES];


 432     seenDummyEventLock = nil;
 433 }
 434 
 435 @end
 436 
 437 
 438 void OSXAPP_SetApplicationDelegate(id <NSApplicationDelegate> newdelegate)
 439 {
 440 AWT_ASSERT_APPKIT_THREAD;
 441     applicationDelegate = newdelegate;
 442 
 443     if (NSApp != nil) {
 444         [NSApp setDelegate: applicationDelegate];
 445 
 446         if (applicationDelegate && qad) {
 447             [qad processQueuedEventsWithTargetDelegate: applicationDelegate];
 448             qad = nil;
 449         }
 450     }
 451 }

< prev index next >