return new Tray(image);
}
-void Tray::OnClicked(const gfx::Point& pos) {
- Emit("clicked", pos);
+void Tray::OnClicked(const gfx::Rect& bounds) {
+ Emit("clicked", bounds);
}
void Tray::OnDoubleClicked() {
virtual ~Tray();
// TrayIconObserver:
- void OnClicked(const gfx::Point&) override;
+ void OnClicked(const gfx::Rect&) override;
void OnDoubleClicked() override;
void OnBalloonShow() override;
void OnBalloonClicked() override;
const base::string16& contents) {
}
-void TrayIcon::NotifyClicked(const gfx::Point& pos) {
- FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnClicked(pos));
+void TrayIcon::NotifyClicked(const gfx::Rect& bounds) {
+ FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnClicked(bounds));
}
void TrayIcon::NotifyDoubleClicked() {
#include "atom/browser/ui/tray_icon_observer.h"
#include "base/observer_list.h"
#include "ui/base/models/simple_menu_model.h"
+#include "ui/gfx/geometry/rect.h"
namespace atom {
void AddObserver(TrayIconObserver* obs) { observers_.AddObserver(obs); }
void RemoveObserver(TrayIconObserver* obs) { observers_.RemoveObserver(obs); }
- void NotifyClicked(const gfx::Point&);
+ void NotifyClicked(const gfx::Rect& = gfx::Rect());
void NotifyDoubleClicked();
void NotifyBalloonShow();
void NotifyBalloonClicked();
}
- (void)handleClick:(id)sender {
- // Get the position of the frame of the NSStatusItem.
- NSPoint pos = [NSApp currentEvent].window.frame.origin;
+ // Get the frame of the NSStatusItem.
+ NSRect frame = [NSApp currentEvent].window.frame;
+ gfx::Rect bounds(frame.origin.x, 0, NSWidth(frame), NSHeight(frame));
// Flip coordinates to gfx (0,0 in top-left corner) using current screen.
NSScreen* screen = [NSScreen mainScreen];
- pos.y = NSMaxY([screen frame]) - pos.y;
+ bounds.set_y(NSHeight([screen frame]) - NSMaxY(frame));
- trayIcon_->NotifyClicked(gfx::Point(pos.x, pos.y));
+ trayIcon_->NotifyClicked(bounds);
}
- (void)handleDoubleClick:(id)sender {
#define ATOM_BROWSER_UI_TRAY_ICON_OBSERVER_H_
namespace gfx {
-class Point;
+class Rect;
}
namespace atom {
class TrayIconObserver {
public:
- virtual void OnClicked(const gfx::Point&) {}
+ virtual void OnClicked(const gfx::Rect&) {}
virtual void OnDoubleClicked() {}
virtual void OnBalloonShow() {}
virtual void OnBalloonClicked() {}