Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Unified Diff: ui/views/controls/menu/menu_controller.cc

Issue 341763002: Ensure that mouse events on Windows reposted by the menu_controller are converted to pixel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review comments Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/menu/menu_controller.cc
diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc
index 87e7ad2ab088321e93ec1edbbb41730936419c88..7d07345b40ff1bf98847c855c52e19feafa87081 100644
--- a/ui/views/controls/menu/menu_controller.cc
+++ b/ui/views/controls/menu/menu_controller.cc
@@ -39,6 +39,7 @@
#if defined(OS_WIN)
#include "ui/base/win/internal_constants.h"
+#include "ui/gfx/win/dpi.h"
#include "ui/views/win/hwnd_util.h"
#endif
@@ -89,6 +90,26 @@ bool TitleMatchesMnemonic(MenuItemView* menu, base::char16 key) {
return !lower_title.empty() && lower_title[0] == key;
}
+// Returns the window and the screen location for the coordinates identified
+// by |event|. The window is returned in the output parameter |window| and
+// the screen location is returned in the output parameter |screen_location|.
+void PlatformGetWindowAtLocation(const ui::LocatedEvent& event,
+ SubmenuView* source,
+ gfx::NativeView native_view,
+ gfx::NativeWindow* window,
+ gfx::Point* screen_location) {
+ gfx::Point screen_loc(event.location());
+ View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc);
+ gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view);
+#if defined(OS_WIN)
+ // On Windows convert the coordinates from DIP to pixel to ensure that we
+ // get the correct window.
+ screen_loc = gfx::win::DIPToScreenPoint(screen_loc);
+#endif
+ *window = screen->GetWindowAtScreenPoint(screen_loc);
sky 2014/06/18 22:20:26 Something seems wrong here. Why does GetWindowAtSc
oshima 2014/06/18 22:27:51 Yes, both must be in DIP.
ananta 2014/06/18 22:57:10 I updated the patch to fix ScreenWin::GetWindowAtS
+ *screen_location = screen_loc;
+}
+
} // namespace
// Returns the first descendant of |view| that is hot tracked.
@@ -2042,15 +2063,15 @@ void MenuController::RepostEvent(SubmenuView* source,
state_.item->GetRootMenuItem()->GetSubmenu()->ReleaseCapture();
#endif
- gfx::Point screen_loc(event.location());
- View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc);
gfx::NativeView native_view = source->GetWidget()->GetNativeView();
if (!native_view)
return;
- gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view);
- gfx::NativeWindow window = screen->GetWindowAtScreenPoint(screen_loc);
+ gfx::NativeWindow window = NULL;
+ gfx::Point screen_loc;
+ PlatformGetWindowAtLocation(event, source, native_view, &window,
+ &screen_loc);
#if defined(OS_WIN)
// PostMessage() to metro windows isn't allowed (access will be denied). Don't
// try to repost with Win32 if the window under the mouse press is in metro.
@@ -2068,7 +2089,6 @@ void MenuController::RepostEvent(SubmenuView* source,
// else double events can occur and lead to bad behavior.
return;
}
-
// Determine whether the click was in the client area or not.
// NOTE: WM_NCHITTEST coordinates are relative to the screen.
LPARAM coords = MAKELPARAM(screen_loc.x(), screen_loc.y());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698