win: No more need to convert to DIP point for context menu.
This commit is contained in:
parent
8dd7f81175
commit
1c415b0666
3 changed files with 4 additions and 20 deletions
|
@ -8,10 +8,6 @@
|
||||||
#include "ui/gfx/screen.h"
|
#include "ui/gfx/screen.h"
|
||||||
#include "ui/views/controls/menu/menu_runner.h"
|
#include "ui/views/controls/menu/menu_runner.h"
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
|
||||||
#include "ui/gfx/win/dpi.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
namespace api {
|
namespace api {
|
||||||
|
@ -21,10 +17,6 @@ MenuViews::MenuViews() {
|
||||||
|
|
||||||
void MenuViews::Popup(Window* window) {
|
void MenuViews::Popup(Window* window) {
|
||||||
gfx::Point cursor = gfx::Screen::GetNativeScreen()->GetCursorScreenPoint();
|
gfx::Point cursor = gfx::Screen::GetNativeScreen()->GetCursorScreenPoint();
|
||||||
#if defined(OS_WIN)
|
|
||||||
cursor = gfx::win::ScreenToDIPPoint(cursor);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
views::MenuRunner menu_runner(model());
|
views::MenuRunner menu_runner(model());
|
||||||
ignore_result(menu_runner.RunMenuAt(
|
ignore_result(menu_runner.RunMenuAt(
|
||||||
static_cast<NativeWindowViews*>(window->window())->widget(),
|
static_cast<NativeWindowViews*>(window->window())->widget(),
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include "ui/gfx/icon_util.h"
|
#include "ui/gfx/icon_util.h"
|
||||||
#include "ui/gfx/point.h"
|
#include "ui/gfx/point.h"
|
||||||
#include "ui/gfx/rect.h"
|
#include "ui/gfx/rect.h"
|
||||||
#include "ui/gfx/win/dpi.h"
|
|
||||||
#include "ui/views/controls/menu/menu_runner.h"
|
#include "ui/views/controls/menu/menu_runner.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
@ -61,16 +60,14 @@ void NotifyIcon::HandleClickEvent(const gfx::Point& cursor_pos,
|
||||||
if (!SetForegroundWindow(window_))
|
if (!SetForegroundWindow(window_))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
menu_runner_.reset(new views::MenuRunner(menu_model_));
|
views::MenuRunner menu_runner(menu_model_);
|
||||||
views::MenuRunner::RunResult result = menu_runner_->RunMenuAt(
|
ignore_result(menu_runner.RunMenuAt(
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
gfx::Rect(gfx::win::ScreenToDIPPoint(cursor_pos), gfx::Size()),
|
gfx::Rect(cursor_pos, gfx::Size()),
|
||||||
views::MENU_ANCHOR_TOPLEFT,
|
views::MENU_ANCHOR_TOPLEFT,
|
||||||
ui::MENU_SOURCE_MOUSE,
|
ui::MENU_SOURCE_MOUSE,
|
||||||
views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU);
|
views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU));
|
||||||
if (result == views::MenuRunner::MENU_DELETED)
|
|
||||||
LOG(ERROR) << "Menu deleted when running";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotifyIcon::ResetIcon() {
|
void NotifyIcon::ResetIcon() {
|
||||||
|
|
|
@ -20,10 +20,6 @@ namespace gfx {
|
||||||
class Point;
|
class Point;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace views {
|
|
||||||
class MenuRunner;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
class NotifyIconHost;
|
class NotifyIconHost;
|
||||||
|
@ -72,7 +68,6 @@ class NotifyIcon : public TrayIcon {
|
||||||
|
|
||||||
// The context menu.
|
// The context menu.
|
||||||
ui::SimpleMenuModel* menu_model_;
|
ui::SimpleMenuModel* menu_model_;
|
||||||
scoped_ptr<views::MenuRunner> menu_runner_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(NotifyIcon);
|
DISALLOW_COPY_AND_ASSIGN(NotifyIcon);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue