win: No more need to convert to DIP point for context menu.

This commit is contained in:
Cheng Zhao 2014-07-28 20:44:11 +08:00
parent 8dd7f81175
commit 1c415b0666
3 changed files with 4 additions and 20 deletions

View file

@ -8,10 +8,6 @@
#include "ui/gfx/screen.h"
#include "ui/views/controls/menu/menu_runner.h"
#if defined(OS_WIN)
#include "ui/gfx/win/dpi.h"
#endif
namespace atom {
namespace api {
@ -21,10 +17,6 @@ MenuViews::MenuViews() {
void MenuViews::Popup(Window* window) {
gfx::Point cursor = gfx::Screen::GetNativeScreen()->GetCursorScreenPoint();
#if defined(OS_WIN)
cursor = gfx::win::ScreenToDIPPoint(cursor);
#endif
views::MenuRunner menu_runner(model());
ignore_result(menu_runner.RunMenuAt(
static_cast<NativeWindowViews*>(window->window())->widget(),

View file

@ -12,7 +12,6 @@
#include "ui/gfx/icon_util.h"
#include "ui/gfx/point.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/win/dpi.h"
#include "ui/views/controls/menu/menu_runner.h"
namespace atom {
@ -61,16 +60,14 @@ void NotifyIcon::HandleClickEvent(const gfx::Point& cursor_pos,
if (!SetForegroundWindow(window_))
return;
menu_runner_.reset(new views::MenuRunner(menu_model_));
views::MenuRunner::RunResult result = menu_runner_->RunMenuAt(
views::MenuRunner menu_runner(menu_model_);
ignore_result(menu_runner.RunMenuAt(
NULL,
NULL,
gfx::Rect(gfx::win::ScreenToDIPPoint(cursor_pos), gfx::Size()),
gfx::Rect(cursor_pos, gfx::Size()),
views::MENU_ANCHOR_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";
views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU));
}
void NotifyIcon::ResetIcon() {

View file

@ -20,10 +20,6 @@ namespace gfx {
class Point;
}
namespace views {
class MenuRunner;
}
namespace atom {
class NotifyIconHost;
@ -72,7 +68,6 @@ class NotifyIcon : public TrayIcon {
// The context menu.
ui::SimpleMenuModel* menu_model_;
scoped_ptr<views::MenuRunner> menu_runner_;
DISALLOW_COPY_AND_ASSIGN(NotifyIcon);
};