diff --git a/atom/browser/ui/win/notify_icon.cc b/atom/browser/ui/win/notify_icon.cc index df9a65dddb28..7d01855aecbd 100644 --- a/atom/browser/ui/win/notify_icon.cc +++ b/atom/browser/ui/win/notify_icon.cc @@ -147,10 +147,10 @@ void NotifyIcon::PopUpContextMenu(const gfx::Point& pos, if (pos.IsOrigin()) rect.set_origin(display::Screen::GetScreen()->GetCursorScreenPoint()); - views::MenuRunner menu_runner( + menu_runner_.reset(new views::MenuRunner( menu_model != nullptr ? menu_model : menu_model_, - views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS); - ignore_result(menu_runner.RunMenuAt( + views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS)); + ignore_result(menu_runner_->RunMenuAt( NULL, NULL, rect, views::MENU_ANCHOR_TOPLEFT, ui::MENU_SOURCE_MOUSE)); } diff --git a/atom/browser/ui/win/notify_icon.h b/atom/browser/ui/win/notify_icon.h index 5daf15845f45..d0053ae70cb7 100644 --- a/atom/browser/ui/win/notify_icon.h +++ b/atom/browser/ui/win/notify_icon.h @@ -20,6 +20,10 @@ namespace gfx { class Point; } +namespace views { +class MenuRunner; +} + namespace atom { class NotifyIconHost; @@ -77,6 +81,9 @@ class NotifyIcon : public TrayIcon { // The context menu. AtomMenuModel* menu_model_; + // Context menu associated with this icon (if any). + std::unique_ptr menu_runner_; + DISALLOW_COPY_AND_ASSIGN(NotifyIcon); };