diff --git a/atom.gyp b/atom.gyp index b471a04d5e86..2e602e5e9d26 100644 --- a/atom.gyp +++ b/atom.gyp @@ -439,7 +439,6 @@ '-loleacc.lib', '-lComdlg32.lib', '-lWininet.lib', - '<(atom_source_root)/<(libchromiumcontent_library_dir)/chromiumviews.lib', ], }, 'dependencies': [ diff --git a/atom/browser/api/lib/menu-item.coffee b/atom/browser/api/lib/menu-item.coffee index bbac726acce6..64d69881688f 100644 --- a/atom/browser/api/lib/menu-item.coffee +++ b/atom/browser/api/lib/menu-item.coffee @@ -44,9 +44,7 @@ class MenuItem Object.defineProperty this, name, enumerable: true get: => v8Util.getHiddenValue this, name - set: (val) => - v8Util.setHiddenValue this, name, val - @menu?._updateStates() + set: (val) => v8Util.setHiddenValue this, name, val overrideReadOnlyProperty: (name, defaultValue=null) -> this[name] ?= defaultValue diff --git a/atom/browser/api/lib/menu.coffee b/atom/browser/api/lib/menu.coffee index 8a4f15380e35..f53dc21635b0 100644 --- a/atom/browser/api/lib/menu.coffee +++ b/atom/browser/api/lib/menu.coffee @@ -76,9 +76,6 @@ Menu::insert = (pos, item) -> v8Util.setHiddenValue otherItem, 'checked', false v8Util.setHiddenValue item, 'checked', true - # Update states when clicked on Windows. - @_updateStates() if process.platform is 'win32' - @insertRadioItem pos, item.commandId, item.label, item.groupId @setSublabel pos, item.sublabel if item.sublabel? diff --git a/atom/browser/ui/win/notify_icon.cc b/atom/browser/ui/win/notify_icon.cc index 105f223fbbb2..83cd5a3b1901 100644 --- a/atom/browser/ui/win/notify_icon.cc +++ b/atom/browser/ui/win/notify_icon.cc @@ -13,6 +13,7 @@ #include "ui/gfx/icon_util.h" #include "ui/gfx/point.h" #include "ui/gfx/rect.h" +#include "ui/views/controls/menu/menu_runner.h" namespace atom { @@ -60,8 +61,16 @@ void NotifyIcon::HandleClickEvent(const gfx::Point& cursor_pos, if (!SetForegroundWindow(window_)) return; - menu_.reset(new Menu2(menu_model_)); - menu_->RunContextMenuAt(cursor_pos); + menu_runner_.reset(new views::MenuRunner(menu_model_)); + views::MenuRunner::RunResult result = menu_runner_->RunMenuAt( + NULL, + NULL, + gfx::Rect(cursor_pos, gfx::Size()), + views::MenuItemView::TOPLEFT, + ui::MENU_SOURCE_MOUSE, + views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU); + if (result == views::MenuRunner::MENU_DELETED) + LOG(ERROR) << "Menu deleted when running"; } void NotifyIcon::ResetIcon() { diff --git a/atom/browser/ui/win/notify_icon.h b/atom/browser/ui/win/notify_icon.h index 51e854b802e2..b7cdbe229e1a 100644 --- a/atom/browser/ui/win/notify_icon.h +++ b/atom/browser/ui/win/notify_icon.h @@ -20,9 +20,12 @@ namespace gfx { class Point; } +namespace views { +class MenuRunner; +} + namespace atom { -class Menu2; class NotifyIconHost; class NotifyIcon : public TrayIcon { @@ -69,7 +72,7 @@ class NotifyIcon : public TrayIcon { // The context menu. ui::SimpleMenuModel* menu_model_; - scoped_ptr menu_; + scoped_ptr menu_runner_; DISALLOW_COPY_AND_ASSIGN(NotifyIcon); };