]> khamidou — GitHub mirrors - electron.git/commitdiff
views: Remove PopupAtPoint
authorCheng Zhao <zcbenz@gmail.com>
Fri, 22 Jan 2016 18:25:16 +0000 (11:25 -0700)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 22 Jan 2016 18:25:16 +0000 (11:25 -0700)
atom/browser/api/atom_api_menu_views.cc
atom/browser/api/atom_api_menu_views.h

index 93869df87f0d09344e9bd428dd98ad8f1d6f90b4..248523c45378e697e222a0f25ff6c7ca6ad8f0d9 100644 (file)
@@ -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<NativeWindowViews*>(window->window())->widget(),
       NULL,
-      gfx::Rect(point, gfx::Size()),
+      gfx::Rect(location, gfx::Size()),
       views::MENU_ANCHOR_TOPLEFT,
       ui::MENU_SOURCE_MOUSE));
 }
index 9f1b116a004690a6803acb5bf16c48bf5622fc68..802e1405fd5b4041f2ab20c55949e450086a96bc 100644 (file)
@@ -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);
 };