win: Add "balloon-show" and "balloon-closed" events
This commit is contained in:
parent
ee3fa67c48
commit
9f99209733
8 changed files with 31 additions and 8 deletions
|
@ -41,10 +41,18 @@ void Tray::OnDoubleClicked() {
|
||||||
Emit("double-clicked");
|
Emit("double-clicked");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Tray::OnBalloonShow() {
|
||||||
|
Emit("balloon-show");
|
||||||
|
}
|
||||||
|
|
||||||
void Tray::OnBalloonClicked() {
|
void Tray::OnBalloonClicked() {
|
||||||
Emit("balloon-clicked");
|
Emit("balloon-clicked");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Tray::OnBalloonClosed() {
|
||||||
|
Emit("balloon-closed");
|
||||||
|
}
|
||||||
|
|
||||||
void Tray::Destroy() {
|
void Tray::Destroy() {
|
||||||
tray_icon_.reset();
|
tray_icon_.reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,9 @@ class Tray : public mate::EventEmitter,
|
||||||
// TrayIconObserver:
|
// TrayIconObserver:
|
||||||
void OnClicked() override;
|
void OnClicked() override;
|
||||||
void OnDoubleClicked() override;
|
void OnDoubleClicked() override;
|
||||||
|
void OnBalloonShow() override;
|
||||||
void OnBalloonClicked() override;
|
void OnBalloonClicked() override;
|
||||||
|
void OnBalloonClosed() override;
|
||||||
|
|
||||||
void Destroy();
|
void Destroy();
|
||||||
void SetImage(mate::Arguments* args, const gfx::ImageSkia& image);
|
void SetImage(mate::Arguments* args, const gfx::ImageSkia& image);
|
||||||
|
|
|
@ -31,8 +31,16 @@ void TrayIcon::NotifyDoubleClicked() {
|
||||||
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDoubleClicked());
|
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDoubleClicked());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrayIcon::NotifyBalloonShow() {
|
||||||
|
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnBalloonShow());
|
||||||
|
}
|
||||||
|
|
||||||
void TrayIcon::NotifyBalloonClicked() {
|
void TrayIcon::NotifyBalloonClicked() {
|
||||||
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnBalloonClicked());
|
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnBalloonClicked());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrayIcon::NotifyBalloonClosed() {
|
||||||
|
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnBalloonClosed());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -52,7 +52,9 @@ class TrayIcon {
|
||||||
void RemoveObserver(TrayIconObserver* obs) { observers_.RemoveObserver(obs); }
|
void RemoveObserver(TrayIconObserver* obs) { observers_.RemoveObserver(obs); }
|
||||||
void NotifyClicked();
|
void NotifyClicked();
|
||||||
void NotifyDoubleClicked();
|
void NotifyDoubleClicked();
|
||||||
|
void NotifyBalloonShow();
|
||||||
void NotifyBalloonClicked();
|
void NotifyBalloonClicked();
|
||||||
|
void NotifyBalloonClosed();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TrayIcon();
|
TrayIcon();
|
||||||
|
|
|
@ -11,7 +11,9 @@ class TrayIconObserver {
|
||||||
public:
|
public:
|
||||||
virtual void OnClicked() {}
|
virtual void OnClicked() {}
|
||||||
virtual void OnDoubleClicked() {}
|
virtual void OnDoubleClicked() {}
|
||||||
|
virtual void OnBalloonShow() {}
|
||||||
virtual void OnBalloonClicked() {}
|
virtual void OnBalloonClicked() {}
|
||||||
|
virtual void OnBalloonClosed() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~TrayIconObserver() {}
|
virtual ~TrayIconObserver() {}
|
||||||
|
|
|
@ -71,10 +71,6 @@ void NotifyIcon::HandleClickEvent(const gfx::Point& cursor_pos,
|
||||||
ui::MENU_SOURCE_MOUSE));
|
ui::MENU_SOURCE_MOUSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotifyIcon::HandleBalloonClickEvent() {
|
|
||||||
NotifyBalloonClicked();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NotifyIcon::ResetIcon() {
|
void NotifyIcon::ResetIcon() {
|
||||||
NOTIFYICONDATA icon_data;
|
NOTIFYICONDATA icon_data;
|
||||||
InitIconData(&icon_data);
|
InitIconData(&icon_data);
|
||||||
|
|
|
@ -35,9 +35,6 @@ class NotifyIcon : public TrayIcon {
|
||||||
// otherwise displays the context menu if there is one.
|
// otherwise displays the context menu if there is one.
|
||||||
void HandleClickEvent(const gfx::Point& cursor_pos, bool left_button_click);
|
void HandleClickEvent(const gfx::Point& cursor_pos, bool left_button_click);
|
||||||
|
|
||||||
// Handles a click on the balloon from the user.
|
|
||||||
void HandleBalloonClickEvent();
|
|
||||||
|
|
||||||
// Re-creates the status tray icon now after the taskbar has been created.
|
// Re-creates the status tray icon now after the taskbar has been created.
|
||||||
void ResetIcon();
|
void ResetIcon();
|
||||||
|
|
||||||
|
|
|
@ -132,8 +132,16 @@ LRESULT CALLBACK NotifyIconHost::WndProc(HWND hwnd,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
switch (lparam) {
|
switch (lparam) {
|
||||||
|
case TB_CHECKBUTTON:
|
||||||
|
win_icon->NotifyBalloonShow();
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
case TB_INDETERMINATE:
|
case TB_INDETERMINATE:
|
||||||
win_icon->HandleBalloonClickEvent();
|
win_icon->NotifyBalloonClicked();
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
case TB_HIDEBUTTON:
|
||||||
|
win_icon->NotifyBalloonClosed();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
|
|
Loading…
Reference in a new issue