7153700: [macosx] add support for MouseMotionListener to the TrayIcon

Reviewed-by: serb, aniyogi
This commit is contained in:
Manajit Halder 2016-11-07 14:35:21 +05:30 committed by Manajit Halder
parent 36bb41faf9
commit 9fc6d8f3aa
2 changed files with 23 additions and 1 deletions

View File

@ -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 @@ extern "C" {
@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

View File

@ -171,12 +171,27 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize, BOOL autosize) {
[self setTrayIcon: theTrayIcon];
isHighlighted = NO;
image = nil;
trackingArea = nil;
[self addTrackingArea];
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 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize, BOOL autosize) {
[trayIcon deliverJavaMouseEvent: event];
}
- (void) mouseMoved: (NSEvent *)event {
[trayIcon deliverJavaMouseEvent: event];
}
- (void) rightMouseDown:(NSEvent *)event {
[trayIcon deliverJavaMouseEvent: event];
}