7153700: [macosx] add support for MouseMotionListener to the TrayIcon
authormhalder
Mon, 07 Nov 2016 14:35:21 +0530
changeset 42201 cdf51b0d0361
parent 42200 0ab62056c933
child 42202 31974f43ef4a
7153700: [macosx] add support for MouseMotionListener to the TrayIcon Reviewed-by: serb, aniyogi Contributed-by: manajit.halder@oracle.com
jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.h
jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.m
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.h	Mon Nov 07 11:22:53 2016 +0300
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.h	Mon Nov 07 14:35:21 2016 +0530
@@ -26,6 +26,7 @@
 #include <jni.h>
 #import <Foundation/Foundation.h>
 #import <AppKit/AppKit.h>
+#import <AppKit/NSTrackingArea.h>
 
 #import "CPopupMenu.h"
 
@@ -64,12 +65,14 @@
 @public
     AWTTrayIcon *trayIcon;
     NSImage* image;
+    NSTrackingArea *trackingArea;
     BOOL isHighlighted;
 }
 -(id)initWithTrayIcon:(AWTTrayIcon *)theTrayIcon;
 -(void)setHighlighted:(BOOL)aFlag;
 -(void)setImage:(NSImage*)anImage;
 -(void)setTrayIcon:(AWTTrayIcon*)theTrayIcon;
+-(void)addTrackingArea;
 
 @end //AWTTrayIconView
 
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.m	Mon Nov 07 11:22:53 2016 +0300
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.m	Mon Nov 07 14:35:21 2016 +0530
@@ -171,12 +171,27 @@
     [self setTrayIcon: theTrayIcon];
     isHighlighted = NO;
     image = nil;
+    trackingArea = nil;
+	
+    [self addTrackingArea];
+	
+    return self;
+}
 
-    return self;
+- (void)addTrackingArea {
+    NSTrackingAreaOptions options = NSTrackingMouseMoved | 
+                                    NSTrackingInVisibleRect | 
+                                    NSTrackingActiveAlways;
+    trackingArea = [[NSTrackingArea alloc] initWithRect: CGRectZero
+                                                options: options
+                                                owner: self
+                                                userInfo: nil];
+    [self addTrackingArea:trackingArea];
 }
 
 -(void) dealloc {
     [image release];
+    [trackingArea release];
     [super dealloc];
 }
 
@@ -269,6 +284,10 @@
     [trayIcon deliverJavaMouseEvent: event];
 }
 
+- (void) mouseMoved: (NSEvent *)event {
+    [trayIcon deliverJavaMouseEvent: event];
+}
+
 - (void) rightMouseDown:(NSEvent *)event {
     [trayIcon deliverJavaMouseEvent: event];
 }