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

Side by Side Diff: ui/views/controls/menu/menu_controller.cc

Issue 159713012: Don't track mouse events in HWNDMessageHandler when they are forwarded by the LegacyRenderWidgetHost (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/renderer_host/legacy_render_widget_host_win.cc ('k') | ui/views/event_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/controls/menu/menu_controller.h" 5 #include "ui/views/controls/menu/menu_controller.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windowsx.h> 8 #include <windowsx.h>
9 #endif 9 #endif
10 10
(...skipping 2112 matching lines...) Expand 10 before | Expand all | Expand 10 after
2123 2123
2124 void MenuController::RepostEvent(SubmenuView* source, 2124 void MenuController::RepostEvent(SubmenuView* source,
2125 const ui::LocatedEvent& event) { 2125 const ui::LocatedEvent& event) {
2126 gfx::Point screen_loc(event.location()); 2126 gfx::Point screen_loc(event.location());
2127 View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc); 2127 View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc);
2128 2128
2129 gfx::NativeView native_view = source->GetWidget()->GetNativeView(); 2129 gfx::NativeView native_view = source->GetWidget()->GetNativeView();
2130 gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view); 2130 gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view);
2131 gfx::NativeWindow window = screen->GetWindowAtScreenPoint(screen_loc); 2131 gfx::NativeWindow window = screen->GetWindowAtScreenPoint(screen_loc);
2132 2132
2133 if (!window) 2133 // On Windows, it is ok for window to be NULL. Please refer to the
2134 return; 2134 // RepostLocatedEvent function for more information.
2135
2136 #if defined(OS_WIN) 2135 #if defined(OS_WIN)
2137 // Release the capture. 2136 // Release the capture.
2138 SubmenuView* submenu = state_.item->GetRootMenuItem()->GetSubmenu(); 2137 SubmenuView* submenu = state_.item->GetRootMenuItem()->GetSubmenu();
2139 submenu->ReleaseCapture(); 2138 submenu->ReleaseCapture();
2140 2139
2141 gfx::NativeView view = submenu->GetWidget()->GetNativeView(); 2140 gfx::NativeView view = submenu->GetWidget()->GetNativeView();
2142 if (view) { 2141 if (view && window) {
2143 DWORD view_tid = GetWindowThreadProcessId(HWNDForNativeView(view), NULL); 2142 DWORD view_tid = GetWindowThreadProcessId(HWNDForNativeView(view), NULL);
2144 if (view_tid != GetWindowThreadProcessId(HWNDForNativeView(window), NULL)) { 2143 if (view_tid != GetWindowThreadProcessId(HWNDForNativeView(window), NULL)) {
2145 // Even though we have mouse capture, windows generates a mouse event if 2144 // Even though we have mouse capture, windows generates a mouse event if
2146 // the other window is in a separate thread. Only repost an event if 2145 // the other window is in a separate thread. Only repost an event if
2147 // |view| was created on the same thread, else the target window can get 2146 // |view| was created on the same thread, else the target window can get
2148 // double events leading to bad behavior. 2147 // double events leading to bad behavior.
2149 return; 2148 return;
2150 } 2149 }
2151 } 2150 }
2151 #else
2152 if (!window)
2153 return;
2152 #endif 2154 #endif
2153 2155
2154 scoped_ptr<ui::LocatedEvent> clone; 2156 scoped_ptr<ui::LocatedEvent> clone;
2155 if (event.IsMouseEvent()) { 2157 if (event.IsMouseEvent()) {
2156 clone.reset(new ui::MouseEvent(static_cast<const ui::MouseEvent&>(event))); 2158 clone.reset(new ui::MouseEvent(static_cast<const ui::MouseEvent&>(event)));
2157 } else if (event.IsGestureEvent()) { 2159 } else if (event.IsGestureEvent()) {
2158 // TODO(rbyers): Gesture event repost is tricky to get right 2160 // TODO(rbyers): Gesture event repost is tricky to get right
2159 // crbug.com/170987. 2161 // crbug.com/170987.
2160 return; 2162 return;
2161 } else { 2163 } else {
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
2334 (!pending_state_.item->HasSubmenu() || 2336 (!pending_state_.item->HasSubmenu() ||
2335 !pending_state_.item->GetSubmenu()->IsShowing())) { 2337 !pending_state_.item->GetSubmenu()->IsShowing())) {
2336 // On exit if the user hasn't selected an item with a submenu, move the 2338 // On exit if the user hasn't selected an item with a submenu, move the
2337 // selection back to the parent menu item. 2339 // selection back to the parent menu item.
2338 SetSelection(pending_state_.item->GetParentMenuItem(), 2340 SetSelection(pending_state_.item->GetParentMenuItem(),
2339 SELECTION_OPEN_SUBMENU); 2341 SELECTION_OPEN_SUBMENU);
2340 } 2342 }
2341 } 2343 }
2342 2344
2343 } // namespace views 2345 } // namespace views
OLDNEW
« no previous file with comments | « content/browser/renderer_host/legacy_render_widget_host_win.cc ('k') | ui/views/event_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698