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

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

Issue 1565013002: Don't send touch events to windows like menus when the touch occurs outside the menu bounds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments. Moved the code to get the WindowTreeHost instance from the parent to menu_… Created 4 years, 11 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
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 #include "base/i18n/case_conversion.h" 7 #include "base/i18n/case_conversion.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 22 matching lines...) Expand all
33 #include "ui/views/mouse_constants.h" 33 #include "ui/views/mouse_constants.h"
34 #include "ui/views/view.h" 34 #include "ui/views/view.h"
35 #include "ui/views/view_constants.h" 35 #include "ui/views/view_constants.h"
36 #include "ui/views/views_delegate.h" 36 #include "ui/views/views_delegate.h"
37 #include "ui/views/widget/root_view.h" 37 #include "ui/views/widget/root_view.h"
38 #include "ui/views/widget/tooltip_manager.h" 38 #include "ui/views/widget/tooltip_manager.h"
39 #include "ui/views/widget/widget.h" 39 #include "ui/views/widget/widget.h"
40 40
41 #if defined(OS_WIN) 41 #if defined(OS_WIN)
42 #include "ui/base/win/internal_constants.h" 42 #include "ui/base/win/internal_constants.h"
43 #include "ui/gfx/screen_win.h"
43 #include "ui/gfx/win/dpi.h" 44 #include "ui/gfx/win/dpi.h"
44 #include "ui/views/win/hwnd_util.h" 45 #include "ui/views/win/hwnd_util.h"
45 #endif 46 #endif
46 47
47 using base::Time; 48 using base::Time;
48 using base::TimeDelta; 49 using base::TimeDelta;
49 using ui::OSExchangeData; 50 using ui::OSExchangeData;
50 51
51 // Period of the scroll timer (in milliseconds). 52 // Period of the scroll timer (in milliseconds).
52 static const int kScrollTimerMS = 30; 53 static const int kScrollTimerMS = 30;
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 current_mouse_event_target_ = forward_to_root; 467 current_mouse_event_target_ = forward_to_root;
467 } 468 }
468 469
469 // ...and we always return the result of the current handler. 470 // ...and we always return the result of the current handler.
470 if (current_mouse_event_target_) 471 if (current_mouse_event_target_)
471 return processed; 472 return processed;
472 } 473 }
473 } 474 }
474 475
475 // Otherwise, the menu handles this click directly. 476 // Otherwise, the menu handles this click directly.
476 SetSelectionOnPointerDown(source, event); 477 SetSelectionOnPointerDown(source, &event);
477 return true; 478 return true;
478 } 479 }
479 480
480 bool MenuController::OnMouseDragged(SubmenuView* source, 481 bool MenuController::OnMouseDragged(SubmenuView* source,
481 const ui::MouseEvent& event) { 482 const ui::MouseEvent& event) {
482 if (current_mouse_event_target_) { 483 if (current_mouse_event_target_) {
483 ui::MouseEvent event_for_root(event); 484 ui::MouseEvent event_for_root(event);
484 ConvertLocatedEventForRootView(source, current_mouse_event_target_, 485 ConvertLocatedEventForRootView(source, current_mouse_event_target_,
485 &event_for_root); 486 &event_for_root);
486 return current_mouse_event_target_->ProcessMouseDragged(event_for_root); 487 return current_mouse_event_target_->ProcessMouseDragged(event_for_root);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 bool MenuController::OnMouseWheel(SubmenuView* source, 629 bool MenuController::OnMouseWheel(SubmenuView* source,
629 const ui::MouseWheelEvent& event) { 630 const ui::MouseWheelEvent& event) {
630 MenuPart part = GetMenuPart(source, event.location()); 631 MenuPart part = GetMenuPart(source, event.location());
631 return part.submenu && part.submenu->OnMouseWheel(event); 632 return part.submenu && part.submenu->OnMouseWheel(event);
632 } 633 }
633 634
634 void MenuController::OnGestureEvent(SubmenuView* source, 635 void MenuController::OnGestureEvent(SubmenuView* source,
635 ui::GestureEvent* event) { 636 ui::GestureEvent* event) {
636 MenuPart part = GetMenuPart(source, event->location()); 637 MenuPart part = GetMenuPart(source, event->location());
637 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { 638 if (event->type() == ui::ET_GESTURE_TAP_DOWN) {
638 SetSelectionOnPointerDown(source, *event); 639 SetSelectionOnPointerDown(source, event);
639 event->StopPropagation(); 640 event->StopPropagation();
640 } else if (event->type() == ui::ET_GESTURE_LONG_PRESS) { 641 } else if (event->type() == ui::ET_GESTURE_LONG_PRESS) {
641 if (part.type == MenuPart::MENU_ITEM && part.menu) { 642 if (part.type == MenuPart::MENU_ITEM && part.menu) {
642 gfx::Point screen_location(event->location()); 643 gfx::Point screen_location(event->location());
643 View::ConvertPointToScreen(source->GetScrollViewContainer(), 644 View::ConvertPointToScreen(source->GetScrollViewContainer(),
644 &screen_location); 645 &screen_location);
645 if (ShowContextMenu(part.menu, screen_location, ui::MENU_SOURCE_TOUCH)) 646 if (ShowContextMenu(part.menu, screen_location, ui::MENU_SOURCE_TOUCH))
646 event->StopPropagation(); 647 event->StopPropagation();
647 } 648 }
648 } else if (event->type() == ui::ET_GESTURE_TAP) { 649 } else if (event->type() == ui::ET_GESTURE_TAP) {
(...skipping 23 matching lines...) Expand all
672 } 673 }
673 674
674 if (event->stopped_propagation()) 675 if (event->stopped_propagation())
675 return; 676 return;
676 677
677 if (!part.submenu) 678 if (!part.submenu)
678 return; 679 return;
679 part.submenu->OnGestureEvent(event); 680 part.submenu->OnGestureEvent(event);
680 } 681 }
681 682
683 void MenuController::OnTouchEvent(SubmenuView* source, ui::TouchEvent* event) {
684 if (event->type() == ui::ET_TOUCH_PRESSED) {
685 MenuPart part = GetMenuPart(source, event->location());
686 if (part.type == MenuPart::NONE) {
687 RepostEvent(source, event);
688 event->SetHandled();
689 }
690 }
691 }
692
682 View* MenuController::GetTooltipHandlerForPoint(SubmenuView* source, 693 View* MenuController::GetTooltipHandlerForPoint(SubmenuView* source,
683 const gfx::Point& point) { 694 const gfx::Point& point) {
684 MenuHostRootView* root_view = GetRootView(source, point); 695 MenuHostRootView* root_view = GetRootView(source, point);
685 return root_view ? root_view->ProcessGetTooltipHandlerForPoint(point) 696 return root_view ? root_view->ProcessGetTooltipHandlerForPoint(point)
686 : nullptr; 697 : nullptr;
687 } 698 }
688 699
689 void MenuController::ViewHierarchyChanged( 700 void MenuController::ViewHierarchyChanged(
690 SubmenuView* source, 701 SubmenuView* source,
691 const View::ViewHierarchyChangedDetails& details) { 702 const View::ViewHierarchyChangedDetails& details) {
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 // Notify an accessibility focus event on all menu items except for the root. 974 // Notify an accessibility focus event on all menu items except for the root.
964 if (menu_item && 975 if (menu_item &&
965 (MenuDepth(menu_item) != 1 || 976 (MenuDepth(menu_item) != 1 ||
966 menu_item->GetType() != MenuItemView::SUBMENU)) { 977 menu_item->GetType() != MenuItemView::SUBMENU)) {
967 menu_item->NotifyAccessibilityEvent( 978 menu_item->NotifyAccessibilityEvent(
968 ui::AX_EVENT_FOCUS, true); 979 ui::AX_EVENT_FOCUS, true);
969 } 980 }
970 } 981 }
971 982
972 void MenuController::SetSelectionOnPointerDown(SubmenuView* source, 983 void MenuController::SetSelectionOnPointerDown(SubmenuView* source,
973 const ui::LocatedEvent& event) { 984 const ui::LocatedEvent* event) {
974 if (!blocking_run_) 985 if (!blocking_run_)
975 return; 986 return;
976 987
977 DCHECK(!GetActiveMouseView()); 988 DCHECK(!GetActiveMouseView());
978 989
979 MenuPart part = GetMenuPart(source, event.location()); 990 MenuPart part = GetMenuPart(source, event->location());
980 if (part.is_scroll()) 991 if (part.is_scroll())
981 return; // Ignore presses on scroll buttons. 992 return; // Ignore presses on scroll buttons.
982 993
983 // When this menu is opened through a touch event, a simulated right-click 994 // When this menu is opened through a touch event, a simulated right-click
984 // is sent before the menu appears. Ignore it. 995 // is sent before the menu appears. Ignore it.
985 if ((event.flags() & ui::EF_RIGHT_MOUSE_BUTTON) && 996 if ((event->flags() & ui::EF_RIGHT_MOUSE_BUTTON) &&
986 (event.flags() & ui::EF_FROM_TOUCH)) 997 (event->flags() & ui::EF_FROM_TOUCH))
987 return; 998 return;
988 999
989 if (part.type == MenuPart::NONE || 1000 if (part.type == MenuPart::NONE ||
990 (part.type == MenuPart::MENU_ITEM && part.menu && 1001 (part.type == MenuPart::MENU_ITEM && part.menu &&
991 part.menu->GetRootMenuItem() != state_.item->GetRootMenuItem())) { 1002 part.menu->GetRootMenuItem() != state_.item->GetRootMenuItem())) {
992 // Remember the time stamp of the current (press down) event. The owner can 1003 // Remember the time stamp of the current (press down) event. The owner can
993 // then use this to figure out if this menu was finished with the same click 1004 // then use this to figure out if this menu was finished with the same click
994 // which is sent to it thereafter. 1005 // which is sent to it thereafter.
995 closing_event_time_ = event.time_stamp(); 1006 closing_event_time_ = event->time_stamp();
996 1007
997 // Mouse wasn't pressed over any menu, or the active menu, cancel. 1008 // Mouse wasn't pressed over any menu, or the active menu, cancel.
998 1009
999 #if defined(OS_WIN) 1010 #if defined(OS_WIN)
1000 // We're going to close and we own the mouse capture. We need to repost the 1011 // We're going to close and we own the mouse capture. We need to repost the
1001 // mouse down, otherwise the window the user clicked on won't get the event. 1012 // mouse down, otherwise the window the user clicked on won't get the event.
1002 RepostEvent(source, event); 1013 RepostEvent(source, event);
1003 #endif 1014 #endif
1004 1015
1005 // And close. 1016 // And close.
1006 ExitType exit_type = EXIT_ALL; 1017 ExitType exit_type = EXIT_ALL;
1007 if (!menu_stack_.empty()) { 1018 if (!menu_stack_.empty()) {
1008 // We're running nested menus. Only exit all if the mouse wasn't over one 1019 // We're running nested menus. Only exit all if the mouse wasn't over one
1009 // of the menus from the last run. 1020 // of the menus from the last run.
1010 gfx::Point screen_loc(event.location()); 1021 gfx::Point screen_loc(event->location());
1011 View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc); 1022 View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc);
1012 MenuPart last_part = GetMenuPartByScreenCoordinateUsingMenu( 1023 MenuPart last_part = GetMenuPartByScreenCoordinateUsingMenu(
1013 menu_stack_.back().first.item, screen_loc); 1024 menu_stack_.back().first.item, screen_loc);
1014 if (last_part.type != MenuPart::NONE) 1025 if (last_part.type != MenuPart::NONE)
1015 exit_type = EXIT_OUTERMOST; 1026 exit_type = EXIT_OUTERMOST;
1016 } 1027 }
1017 Cancel(exit_type); 1028 Cancel(exit_type);
1018 1029
1019 #if defined(OS_CHROMEOS) 1030 #if defined(OS_CHROMEOS)
1020 // We're going to exit the menu and want to repost the event so that is 1031 // We're going to exit the menu and want to repost the event so that is
1021 // is handled normally after the context menu has exited. We call 1032 // is handled normally after the context menu has exited. We call
1022 // RepostEvent after Cancel so that mouse capture has been released so 1033 // RepostEvent after Cancel so that mouse capture has been released so
1023 // that finding the event target is unaffected by the current capture. 1034 // that finding the event target is unaffected by the current capture.
1024 RepostEvent(source, event); 1035 RepostEvent(source, event);
1025 #endif 1036 #endif
1026 // Do not repost events for Linux Aura because this behavior is more 1037 // Do not repost events for Linux Aura because this behavior is more
1027 // consistent with the behavior of other Linux apps. 1038 // consistent with the behavior of other Linux apps.
1028 return; 1039 return;
1029 } 1040 }
1030 1041
1031 // On a press we immediately commit the selection, that way a submenu 1042 // On a press we immediately commit the selection, that way a submenu
1032 // pops up immediately rather than after a delay. 1043 // pops up immediately rather than after a delay.
1033 int selection_types = SELECTION_UPDATE_IMMEDIATELY; 1044 int selection_types = SELECTION_UPDATE_IMMEDIATELY;
1034 if (!part.menu) { 1045 if (!part.menu) {
1035 part.menu = part.parent; 1046 part.menu = part.parent;
1036 selection_types |= SELECTION_OPEN_SUBMENU; 1047 selection_types |= SELECTION_OPEN_SUBMENU;
1037 } else { 1048 } else {
1038 if (part.menu->GetDelegate()->CanDrag(part.menu)) { 1049 if (part.menu->GetDelegate()->CanDrag(part.menu)) {
1039 possible_drag_ = true; 1050 possible_drag_ = true;
1040 press_pt_ = event.location(); 1051 press_pt_ = event->location();
1041 } 1052 }
1042 if (part.menu->HasSubmenu()) 1053 if (part.menu->HasSubmenu())
1043 selection_types |= SELECTION_OPEN_SUBMENU; 1054 selection_types |= SELECTION_OPEN_SUBMENU;
1044 } 1055 }
1045 SetSelection(part.menu, selection_types); 1056 SetSelection(part.menu, selection_types);
1046 } 1057 }
1047 1058
1048 void MenuController::StartDrag(SubmenuView* source, 1059 void MenuController::StartDrag(SubmenuView* source,
1049 const gfx::Point& location) { 1060 const gfx::Point& location) {
1050 MenuItemView* item = state_.item; 1061 MenuItemView* item = state_.item;
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2175 item->GetSubmenu()->GetPrefixSelector()->InsertText(char_array); 2186 item->GetSubmenu()->GetPrefixSelector()->InsertText(char_array);
2176 } else { 2187 } else {
2177 // If no mnemonics found, look at first character of titles. 2188 // If no mnemonics found, look at first character of titles.
2178 details = FindChildForMnemonic(item, key, &TitleMatchesMnemonic); 2189 details = FindChildForMnemonic(item, key, &TitleMatchesMnemonic);
2179 if (details.first_match != -1) 2190 if (details.first_match != -1)
2180 AcceptOrSelect(item, details); 2191 AcceptOrSelect(item, details);
2181 } 2192 }
2182 } 2193 }
2183 2194
2184 void MenuController::RepostEvent(SubmenuView* source, 2195 void MenuController::RepostEvent(SubmenuView* source,
2185 const ui::LocatedEvent& event) { 2196 const ui::LocatedEvent* event) {
2186 if (!event.IsMouseEvent()) { 2197 if (!event->IsMouseEvent() && !event->IsTouchEvent()) {
2187 // TODO(rbyers): Gesture event repost is tricky to get right 2198 // TODO(rbyers): Gesture event repost is tricky to get right
2188 // crbug.com/170987. 2199 // crbug.com/170987.
2189 DCHECK(event.IsGestureEvent()); 2200 DCHECK(event->IsGestureEvent());
2190 return; 2201 return;
2191 } 2202 }
2192 2203
2193 #if defined(OS_WIN) 2204 #if defined(OS_WIN)
2194 if (!state_.item) { 2205 if (!state_.item) {
2195 // We some times get an event after closing all the menus. Ignore it. Make 2206 // We some times get an event after closing all the menus. Ignore it. Make
2196 // sure the menu is in fact not visible. If the menu is visible, then 2207 // sure the menu is in fact not visible. If the menu is visible, then
2197 // we're in a bad state where we think the menu isn't visibile but it is. 2208 // we're in a bad state where we think the menu isn't visibile but it is.
2198 DCHECK(!source->GetWidget()->IsVisible()); 2209 DCHECK(!source->GetWidget()->IsVisible());
2199 return; 2210 return;
2200 } 2211 }
2201 2212
2202 state_.item->GetRootMenuItem()->GetSubmenu()->ReleaseCapture(); 2213 state_.item->GetRootMenuItem()->GetSubmenu()->ReleaseCapture();
2203 #endif 2214 #endif
2204 2215
2205 gfx::Point screen_loc(event.location()); 2216 gfx::Point screen_loc(event->location());
2206 View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc); 2217 View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc);
2207 gfx::NativeView native_view = source->GetWidget()->GetNativeView(); 2218 gfx::NativeView native_view = source->GetWidget()->GetNativeView();
2208 if (!native_view) 2219 if (!native_view)
2209 return; 2220 return;
2210 2221
2211 gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view); 2222 gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view);
2212 gfx::NativeWindow window = screen->GetWindowAtScreenPoint(screen_loc); 2223 gfx::NativeWindow window = screen->GetWindowAtScreenPoint(screen_loc);
2213 2224
2214 #if defined(OS_WIN) 2225 #if defined(OS_WIN)
2226 // If we don't find a native window for the HWND at the current location,
sky 2016/01/13 21:56:08 Shouldn't this code be in the if starting on 2244?
ananta 2016/01/13 22:16:32 Yes. unified this code.
2227 // then attempt to find a native window from its parent if one exists.
2228 // There are HWNDs created outside views, which don't have associated
2229 // native windows.
2230 if (!window) {
2231 gfx::ScreenWin* screen_win = static_cast<gfx::ScreenWin*>(screen);
2232 if (screen_win) {
2233 HWND window_at_point = ::WindowFromPoint(screen_loc.ToPOINT());
2234 window_at_point = ::GetParent(window_at_point);
2235 if (window_at_point)
2236 window = screen_win->GetNativeWindowFromHWND(window_at_point);
2237 }
2238 }
2215 // Convert screen_loc to pixels for the Win32 API's like WindowFromPoint, 2239 // Convert screen_loc to pixels for the Win32 API's like WindowFromPoint,
2216 // PostMessage/SendMessage to work correctly. These API's expect the 2240 // PostMessage/SendMessage to work correctly. These API's expect the
2217 // coordinates to be in pixels. 2241 // coordinates to be in pixels.
2218 // PostMessage() to metro windows isn't allowed (access will be denied). Don't 2242 // PostMessage() to metro windows isn't allowed (access will be denied). Don't
2219 // try to repost with Win32 if the window under the mouse press is in metro. 2243 // try to repost with Win32 if the window under the mouse press is in metro.
2220 if (!ViewsDelegate::GetInstance() || 2244 if (event->IsMouseEvent() && (!ViewsDelegate::GetInstance() ||
2221 !ViewsDelegate::GetInstance()->IsWindowInMetro(window)) { 2245 !ViewsDelegate::GetInstance()->IsWindowInMetro(window))) {
2222 gfx::Point screen_loc_pixels = gfx::win::DIPToScreenPoint(screen_loc); 2246 gfx::Point screen_loc_pixels = gfx::win::DIPToScreenPoint(screen_loc);
2223 HWND target_window = window ? HWNDForNativeWindow(window) : 2247 HWND target_window = window ? HWNDForNativeWindow(window) :
2224 WindowFromPoint(screen_loc_pixels.ToPOINT()); 2248 WindowFromPoint(screen_loc_pixels.ToPOINT());
2225 HWND source_window = HWNDForNativeView(native_view); 2249 HWND source_window = HWNDForNativeView(native_view);
2226 if (!target_window || !source_window || 2250 if (!target_window || !source_window ||
2227 GetWindowThreadProcessId(source_window, NULL) != 2251 GetWindowThreadProcessId(source_window, NULL) !=
2228 GetWindowThreadProcessId(target_window, NULL)) { 2252 GetWindowThreadProcessId(target_window, NULL)) {
2229 // Even though we have mouse capture, windows generates a mouse event if 2253 // Even though we have mouse capture, windows generates a mouse event if
2230 // the other window is in a separate thread. Only repost an event if 2254 // the other window is in a separate thread. Only repost an event if
2231 // |target_window| and |source_window| were created on the same thread, 2255 // |target_window| and |source_window| were created on the same thread,
2232 // else double events can occur and lead to bad behavior. 2256 // else double events can occur and lead to bad behavior.
2233 return; 2257 return;
2234 } 2258 }
2235 2259
2236 // Determine whether the click was in the client area or not. 2260 // Determine whether the click was in the client area or not.
2237 // NOTE: WM_NCHITTEST coordinates are relative to the screen. 2261 // NOTE: WM_NCHITTEST coordinates are relative to the screen.
2238 LPARAM coords = MAKELPARAM(screen_loc_pixels.x(), screen_loc_pixels.y()); 2262 LPARAM coords = MAKELPARAM(screen_loc_pixels.x(), screen_loc_pixels.y());
2239 LRESULT nc_hit_result = SendMessage(target_window, WM_NCHITTEST, 0, coords); 2263 LRESULT nc_hit_result = SendMessage(target_window, WM_NCHITTEST, 0, coords);
2240 const bool client_area = nc_hit_result == HTCLIENT; 2264 const bool client_area = nc_hit_result == HTCLIENT;
2241 2265
2242 // TODO(sky): this isn't right. The event to generate should correspond with 2266 // TODO(sky): this isn't right. The event to generate should correspond with
2243 // the event we just got. MouseEvent only tells us what is down, which may 2267 // the event we just got. MouseEvent only tells us what is down, which may
2244 // differ. Need to add ability to get changed button from MouseEvent. 2268 // differ. Need to add ability to get changed button from MouseEvent.
2245 int event_type; 2269 int event_type;
2246 int flags = event.flags(); 2270 int flags = event->flags();
2247 if (flags & ui::EF_LEFT_MOUSE_BUTTON) { 2271 if (flags & ui::EF_LEFT_MOUSE_BUTTON) {
2248 event_type = client_area ? WM_LBUTTONDOWN : WM_NCLBUTTONDOWN; 2272 event_type = client_area ? WM_LBUTTONDOWN : WM_NCLBUTTONDOWN;
2249 } else if (flags & ui::EF_MIDDLE_MOUSE_BUTTON) { 2273 } else if (flags & ui::EF_MIDDLE_MOUSE_BUTTON) {
2250 event_type = client_area ? WM_MBUTTONDOWN : WM_NCMBUTTONDOWN; 2274 event_type = client_area ? WM_MBUTTONDOWN : WM_NCMBUTTONDOWN;
2251 } else if (flags & ui::EF_RIGHT_MOUSE_BUTTON) { 2275 } else if (flags & ui::EF_RIGHT_MOUSE_BUTTON) {
2252 event_type = client_area ? WM_RBUTTONDOWN : WM_NCRBUTTONDOWN; 2276 event_type = client_area ? WM_RBUTTONDOWN : WM_NCRBUTTONDOWN;
2253 } else { 2277 } else {
2254 NOTREACHED(); 2278 NOTREACHED();
2255 return; 2279 return;
2256 } 2280 }
2257 2281
2258 int window_x = screen_loc_pixels.x(); 2282 int window_x = screen_loc_pixels.x();
2259 int window_y = screen_loc_pixels.y(); 2283 int window_y = screen_loc_pixels.y();
2260 if (client_area) { 2284 if (client_area) {
2261 POINT pt = { window_x, window_y }; 2285 POINT pt = { window_x, window_y };
2262 ScreenToClient(target_window, &pt); 2286 ScreenToClient(target_window, &pt);
2263 window_x = pt.x; 2287 window_x = pt.x;
2264 window_y = pt.y; 2288 window_y = pt.y;
2265 } 2289 }
2266 2290
2267 WPARAM target = client_area ? event.native_event().wParam : nc_hit_result; 2291 WPARAM target = client_area ? event->native_event().wParam : nc_hit_result;
2268 LPARAM window_coords = MAKELPARAM(window_x, window_y); 2292 LPARAM window_coords = MAKELPARAM(window_x, window_y);
2269 PostMessage(target_window, event_type, target, window_coords); 2293 PostMessage(target_window, event_type, target, window_coords);
2270 return; 2294 return;
2271 } 2295 }
2272 #endif 2296 #endif
2273 // Non-Windows Aura or |window| is in metro mode. 2297 // Non-Windows Aura or |window| is in metro mode.
2274 if (!window) 2298 if (!window)
2275 return; 2299 return;
2276 2300
2277 MenuMessageLoop::RepostEventToWindow(event, window, screen_loc); 2301 MenuMessageLoop::RepostEventToWindow(event, window, screen_loc);
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
2528 } 2552 }
2529 } 2553 }
2530 2554
2531 gfx::Screen* MenuController::GetScreen() { 2555 gfx::Screen* MenuController::GetScreen() {
2532 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; 2556 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL;
2533 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) 2557 return root ? gfx::Screen::GetScreenFor(root->GetNativeView())
2534 : gfx::Screen::GetNativeScreen(); 2558 : gfx::Screen::GetNativeScreen();
2535 } 2559 }
2536 2560
2537 } // namespace views 2561 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698