Pass bounds in clicked event of tray
This commit is contained in:
parent
a53b1f7edf
commit
f5cf3556b1
6 changed files with 14 additions and 12 deletions
|
@ -40,8 +40,8 @@ mate::Wrappable* Tray::New(const gfx::Image& image) {
|
||||||
return new Tray(image);
|
return new Tray(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tray::OnClicked(const gfx::Point& pos) {
|
void Tray::OnClicked(const gfx::Rect& bounds) {
|
||||||
Emit("clicked", pos);
|
Emit("clicked", bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tray::OnDoubleClicked() {
|
void Tray::OnDoubleClicked() {
|
||||||
|
|
|
@ -41,7 +41,7 @@ class Tray : public mate::EventEmitter,
|
||||||
virtual ~Tray();
|
virtual ~Tray();
|
||||||
|
|
||||||
// TrayIconObserver:
|
// TrayIconObserver:
|
||||||
void OnClicked(const gfx::Point&) override;
|
void OnClicked(const gfx::Rect&) override;
|
||||||
void OnDoubleClicked() override;
|
void OnDoubleClicked() override;
|
||||||
void OnBalloonShow() override;
|
void OnBalloonShow() override;
|
||||||
void OnBalloonClicked() override;
|
void OnBalloonClicked() override;
|
||||||
|
|
|
@ -26,8 +26,8 @@ void TrayIcon::DisplayBalloon(const gfx::Image& icon,
|
||||||
const base::string16& contents) {
|
const base::string16& contents) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrayIcon::NotifyClicked(const gfx::Point& pos) {
|
void TrayIcon::NotifyClicked(const gfx::Rect& bounds) {
|
||||||
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnClicked(pos));
|
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnClicked(bounds));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrayIcon::NotifyDoubleClicked() {
|
void TrayIcon::NotifyDoubleClicked() {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "atom/browser/ui/tray_icon_observer.h"
|
#include "atom/browser/ui/tray_icon_observer.h"
|
||||||
#include "base/observer_list.h"
|
#include "base/observer_list.h"
|
||||||
#include "ui/base/models/simple_menu_model.h"
|
#include "ui/base/models/simple_menu_model.h"
|
||||||
|
#include "ui/gfx/geometry/rect.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
|
@ -50,7 +51,7 @@ class TrayIcon {
|
||||||
|
|
||||||
void AddObserver(TrayIconObserver* obs) { observers_.AddObserver(obs); }
|
void AddObserver(TrayIconObserver* obs) { observers_.AddObserver(obs); }
|
||||||
void RemoveObserver(TrayIconObserver* obs) { observers_.RemoveObserver(obs); }
|
void RemoveObserver(TrayIconObserver* obs) { observers_.RemoveObserver(obs); }
|
||||||
void NotifyClicked(const gfx::Point&);
|
void NotifyClicked(const gfx::Rect& = gfx::Rect());
|
||||||
void NotifyDoubleClicked();
|
void NotifyDoubleClicked();
|
||||||
void NotifyBalloonShow();
|
void NotifyBalloonShow();
|
||||||
void NotifyBalloonClicked();
|
void NotifyBalloonClicked();
|
||||||
|
|
|
@ -26,13 +26,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)handleClick:(id)sender {
|
- (void)handleClick:(id)sender {
|
||||||
// Get the position of the frame of the NSStatusItem.
|
// Get the frame of the NSStatusItem.
|
||||||
NSPoint pos = [NSApp currentEvent].window.frame.origin;
|
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.
|
// Flip coordinates to gfx (0,0 in top-left corner) using current screen.
|
||||||
NSScreen* screen = [NSScreen mainScreen];
|
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 {
|
- (void)handleDoubleClick:(id)sender {
|
||||||
|
|
|
@ -6,14 +6,14 @@
|
||||||
#define ATOM_BROWSER_UI_TRAY_ICON_OBSERVER_H_
|
#define ATOM_BROWSER_UI_TRAY_ICON_OBSERVER_H_
|
||||||
|
|
||||||
namespace gfx {
|
namespace gfx {
|
||||||
class Point;
|
class Rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
class TrayIconObserver {
|
class TrayIconObserver {
|
||||||
public:
|
public:
|
||||||
virtual void OnClicked(const gfx::Point&) {}
|
virtual void OnClicked(const gfx::Rect&) {}
|
||||||
virtual void OnDoubleClicked() {}
|
virtual void OnDoubleClicked() {}
|
||||||
virtual void OnBalloonShow() {}
|
virtual void OnBalloonShow() {}
|
||||||
virtual void OnBalloonClicked() {}
|
virtual void OnBalloonClicked() {}
|
||||||
|
|
Loading…
Reference in a new issue