changeset 31883:be405ebc8355

8129894: NSApplicationAWT.m:343:72: error: comparison of constant 777 with expression of type 'NSEventSubtype' Reviewed-by: alexsch, azvegint
author serb
date Fri, 10 Jul 2015 15:38:40 +0300
parents 0268245131a9
children 15ece91df8e9
files jdk/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m
diffstat 1 files changed, 22 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m	Thu Jul 09 16:37:35 2015 +0300
+++ b/jdk/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m	Fri Jul 10 15:38:40 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -42,6 +42,13 @@
 // Flag used to indicate to the Plugin2 event synthesis code to do a postEvent instead of sendEvent
 BOOL postEventDuringEventSynthesis = NO;
 
+/**
+ * Subtypes of NSApplicationDefined, which are used for custom events.
+ */
+enum {
+    ExecuteBlockEvent, NativeSyncQueueEvent
+};
+
 @implementation NSApplicationAWT
 
 - (id) init
@@ -262,7 +269,7 @@
     NSImage* iconImage = nil;
     if (theIconPath != nil) {
         iconImage = [[NSImage alloc] initWithContentsOfFile:theIconPath];
-    } 
+    }
 
     // If no icon file was specified or we failed to get the icon image
     // and there is no bundle's icon, then use the default icon
@@ -337,10 +344,12 @@
 
 - (void)sendEvent:(NSEvent *)event
 {
-    if ([event type] == NSApplicationDefined && TS_EQUAL([event timestamp], dummyEventTimestamp) && [event subtype] == 0) {
+    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] == 777) {
+    } else if ([event type] == NSApplicationDefined && [event subtype] == ExecuteBlockEvent) {
         void (^block)() = (void (^)()) [event data1];
         block();
         [block release];
@@ -354,23 +363,23 @@
 }
 
 /*
- * Posts the block to the AppKit event queue which will be executed 
- * on the main AppKit loop. 
- * While running nested loops this event will be ignored. 
+ * Posts the block to the AppKit event queue which will be executed
+ * on the main AppKit loop.
+ * While running nested loops this event will be ignored.
  */
-- (void)postRunnableEvent:(void (^)())block 
+- (void)postRunnableEvent:(void (^)())block
 {
     void (^copy)() = [block copy];
     NSInteger encode = (NSInteger) copy;
     [copy retain];
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];    
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     NSEvent* event = [NSEvent otherEventWithType: NSApplicationDefined
                                         location: NSMakePoint(0,0)
                                    modifierFlags: 0
                                        timestamp: 0
                                     windowNumber: 0
                                          context: nil
-                                         subtype: 777
+                                         subtype: ExecuteBlockEvent
                                            data1: encode
                                            data2: 0];
 
@@ -383,15 +392,15 @@
 - (void)postDummyEvent {
     seenDummyEventLock = [[NSConditionLock alloc] initWithCondition:NO];
     dummyEventTimestamp = [NSProcessInfo processInfo].systemUptime;
-    
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];    
+
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     NSEvent* event = [NSEvent otherEventWithType: NSApplicationDefined
                                         location: NSMakePoint(0,0)
                                    modifierFlags: 0
                                        timestamp: dummyEventTimestamp
                                     windowNumber: 0
                                          context: nil
-                                         subtype: 0
+                                         subtype: NativeSyncQueueEvent
                                            data1: 0
                                            data2: 0];
     [NSApp postEvent: event atStart: NO];