mirror of
https://github.com/electron/electron.git
synced 2026-05-02 03:00:22 -04:00
feat: add tray.focus() (#19548)
This commit is contained in:
committed by
Shelley Vohr
parent
ed3b69ffb1
commit
03debb4ef9
@@ -18,6 +18,8 @@ void TrayIcon::DisplayBalloon(const BalloonOptions& options) {}
|
||||
|
||||
void TrayIcon::RemoveBalloon() {}
|
||||
|
||||
void TrayIcon::Focus() {}
|
||||
|
||||
void TrayIcon::PopUpContextMenu(const gfx::Point& pos,
|
||||
AtomMenuModel* menu_model) {}
|
||||
|
||||
|
||||
@@ -74,6 +74,9 @@ class TrayIcon {
|
||||
// Removes the notification balloon.
|
||||
virtual void RemoveBalloon();
|
||||
|
||||
// Returns focus to the taskbar notification area.
|
||||
virtual void Focus();
|
||||
|
||||
// Popups the menu.
|
||||
virtual void PopUpContextMenu(const gfx::Point& pos,
|
||||
AtomMenuModel* menu_model);
|
||||
|
||||
@@ -176,6 +176,15 @@ void NotifyIcon::RemoveBalloon() {
|
||||
LOG(WARNING) << "Unable to remove status tray balloon.";
|
||||
}
|
||||
|
||||
void NotifyIcon::Focus() {
|
||||
NOTIFYICONDATA icon_data;
|
||||
InitIconData(&icon_data);
|
||||
|
||||
BOOL result = Shell_NotifyIcon(NIM_SETFOCUS, &icon_data);
|
||||
if (!result)
|
||||
LOG(WARNING) << "Unable to focus tray icon.";
|
||||
}
|
||||
|
||||
void NotifyIcon::PopUpContextMenu(const gfx::Point& pos,
|
||||
AtomMenuModel* menu_model) {
|
||||
// Returns if context menu isn't set.
|
||||
|
||||
@@ -60,6 +60,7 @@ class NotifyIcon : public TrayIcon {
|
||||
void SetToolTip(const std::string& tool_tip) override;
|
||||
void DisplayBalloon(const BalloonOptions& options) override;
|
||||
void RemoveBalloon() override;
|
||||
void Focus() override;
|
||||
void PopUpContextMenu(const gfx::Point& pos,
|
||||
AtomMenuModel* menu_model) override;
|
||||
void SetContextMenu(AtomMenuModel* menu_model) override;
|
||||
|
||||
Reference in New Issue
Block a user