From 0e3a3d07484653bb50632cc8e2f7832b365dd6fc Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 22 Jan 2016 11:25:16 -0700 Subject: [PATCH] views: Remove PopupAtPoint --- atom/browser/api/atom_api_menu_views.cc | 17 +++++++++++------ atom/browser/api/atom_api_menu_views.h | 2 -- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/atom/browser/api/atom_api_menu_views.cc b/atom/browser/api/atom_api_menu_views.cc index 93869df87f0..248523c4537 100644 --- a/atom/browser/api/atom_api_menu_views.cc +++ b/atom/browser/api/atom_api_menu_views.cc @@ -17,7 +17,7 @@ MenuViews::MenuViews() { } void MenuViews::Popup(Window* window) { - PopupAtPoint(window, gfx::Screen::GetNativeScreen()->GetCursorScreenPoint()); + PopupAt(window, -1, -1, 0); } void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item) { @@ -31,18 +31,23 @@ void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item) { if (!view) return; - gfx::Point origin = view->GetViewBounds().origin(); - PopupAtPoint(window, gfx::Point(origin.x() + x, origin.y() + y)); -} + // (-1, -1) means showing on mouse location. + gfx::Point location; + if (x == -1 || y == -1) { + location = gfx::Screen::GetNativeScreen()->GetCursorScreenPoint(); + } else { + gfx::Point origin = view->GetViewBounds().origin(); + location = gfx::Point(origin.x() + x, origin.y() + y); + } -void MenuViews::PopupAtPoint(Window* window, const gfx::Point& point) { + // Show the menu. views::MenuRunner menu_runner( model(), views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS); ignore_result(menu_runner.RunMenuAt( static_cast(window->window())->widget(), NULL, - gfx::Rect(point, gfx::Size()), + gfx::Rect(location, gfx::Size()), views::MENU_ANCHOR_TOPLEFT, ui::MENU_SOURCE_MOUSE)); } diff --git a/atom/browser/api/atom_api_menu_views.h b/atom/browser/api/atom_api_menu_views.h index 9f1b116a004..802e1405fd5 100644 --- a/atom/browser/api/atom_api_menu_views.h +++ b/atom/browser/api/atom_api_menu_views.h @@ -21,8 +21,6 @@ class MenuViews : public Menu { void PopupAt(Window* window, int x, int y, int positioning_item = 0) override; private: - void PopupAtPoint(Window* window, const gfx::Point& point); - DISALLOW_COPY_AND_ASSIGN(MenuViews); };