OLD | NEW |
---|---|
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 21 matching lines...) Expand all Loading... | |
32 #include "ui/views/focus/view_storage.h" | 32 #include "ui/views/focus/view_storage.h" |
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/aura/window_tree_host.h" | |
42 #include "ui/base/win/internal_constants.h" | 43 #include "ui/base/win/internal_constants.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). |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 Loading... | |
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 Loading... | |
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) { | |
jonross
2016/01/14 23:25:02
This change prevents CrOS from being able to close
| |
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 Loading... | |
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 Loading... | |
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 gfx::Point screen_loc_pixels = gfx::win::DIPToScreenPoint(screen_loc); | |
2227 HWND target_window = ::WindowFromPoint(screen_loc_pixels.ToPOINT()); | |
2228 // If we don't find a native window for the HWND at the current location, | |
2229 // then attempt to find a native window from its parent if one exists. | |
2230 // There are HWNDs created outside views, which don't have associated | |
2231 // native windows. | |
2232 if (!window) { | |
2233 HWND parent = ::GetParent(target_window); | |
2234 if (parent) { | |
2235 aura::WindowTreeHost* host = | |
2236 aura::WindowTreeHost::GetForAcceleratedWidget(parent); | |
2237 if (host) { | |
2238 target_window = parent; | |
2239 window = host->window(); | |
2240 } | |
2241 } | |
2242 } | |
2215 // Convert screen_loc to pixels for the Win32 API's like WindowFromPoint, | 2243 // Convert screen_loc to pixels for the Win32 API's like WindowFromPoint, |
2216 // PostMessage/SendMessage to work correctly. These API's expect the | 2244 // PostMessage/SendMessage to work correctly. These API's expect the |
2217 // coordinates to be in pixels. | 2245 // coordinates to be in pixels. |
2218 // PostMessage() to metro windows isn't allowed (access will be denied). Don't | 2246 if (event->IsMouseEvent()) { |
2219 // try to repost with Win32 if the window under the mouse press is in metro. | |
2220 if (!ViewsDelegate::GetInstance() || | |
2221 !ViewsDelegate::GetInstance()->IsWindowInMetro(window)) { | |
2222 gfx::Point screen_loc_pixels = gfx::win::DIPToScreenPoint(screen_loc); | |
2223 HWND target_window = window ? HWNDForNativeWindow(window) : | |
2224 WindowFromPoint(screen_loc_pixels.ToPOINT()); | |
2225 HWND source_window = HWNDForNativeView(native_view); | 2247 HWND source_window = HWNDForNativeView(native_view); |
2226 if (!target_window || !source_window || | 2248 if (!target_window || !source_window || |
2227 GetWindowThreadProcessId(source_window, NULL) != | 2249 GetWindowThreadProcessId(source_window, NULL) != |
2228 GetWindowThreadProcessId(target_window, NULL)) { | 2250 GetWindowThreadProcessId(target_window, NULL)) { |
2229 // Even though we have mouse capture, windows generates a mouse event if | 2251 // 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 | 2252 // 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, | 2253 // |target_window| and |source_window| were created on the same thread, |
2232 // else double events can occur and lead to bad behavior. | 2254 // else double events can occur and lead to bad behavior. |
2233 return; | 2255 return; |
2234 } | 2256 } |
2235 | 2257 |
2236 // Determine whether the click was in the client area or not. | 2258 // Determine whether the click was in the client area or not. |
2237 // NOTE: WM_NCHITTEST coordinates are relative to the screen. | 2259 // NOTE: WM_NCHITTEST coordinates are relative to the screen. |
2238 LPARAM coords = MAKELPARAM(screen_loc_pixels.x(), screen_loc_pixels.y()); | 2260 LPARAM coords = MAKELPARAM(screen_loc_pixels.x(), screen_loc_pixels.y()); |
2239 LRESULT nc_hit_result = SendMessage(target_window, WM_NCHITTEST, 0, coords); | 2261 LRESULT nc_hit_result = SendMessage(target_window, WM_NCHITTEST, 0, coords); |
2240 const bool client_area = nc_hit_result == HTCLIENT; | 2262 const bool client_area = nc_hit_result == HTCLIENT; |
2241 | 2263 |
2242 // TODO(sky): this isn't right. The event to generate should correspond with | 2264 // 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 | 2265 // 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. | 2266 // differ. Need to add ability to get changed button from MouseEvent. |
2245 int event_type; | 2267 int event_type; |
2246 int flags = event.flags(); | 2268 int flags = event->flags(); |
2247 if (flags & ui::EF_LEFT_MOUSE_BUTTON) { | 2269 if (flags & ui::EF_LEFT_MOUSE_BUTTON) { |
2248 event_type = client_area ? WM_LBUTTONDOWN : WM_NCLBUTTONDOWN; | 2270 event_type = client_area ? WM_LBUTTONDOWN : WM_NCLBUTTONDOWN; |
2249 } else if (flags & ui::EF_MIDDLE_MOUSE_BUTTON) { | 2271 } else if (flags & ui::EF_MIDDLE_MOUSE_BUTTON) { |
2250 event_type = client_area ? WM_MBUTTONDOWN : WM_NCMBUTTONDOWN; | 2272 event_type = client_area ? WM_MBUTTONDOWN : WM_NCMBUTTONDOWN; |
2251 } else if (flags & ui::EF_RIGHT_MOUSE_BUTTON) { | 2273 } else if (flags & ui::EF_RIGHT_MOUSE_BUTTON) { |
2252 event_type = client_area ? WM_RBUTTONDOWN : WM_NCRBUTTONDOWN; | 2274 event_type = client_area ? WM_RBUTTONDOWN : WM_NCRBUTTONDOWN; |
2253 } else { | 2275 } else { |
2254 NOTREACHED(); | 2276 NOTREACHED(); |
2255 return; | 2277 return; |
2256 } | 2278 } |
2257 | 2279 |
2258 int window_x = screen_loc_pixels.x(); | 2280 int window_x = screen_loc_pixels.x(); |
2259 int window_y = screen_loc_pixels.y(); | 2281 int window_y = screen_loc_pixels.y(); |
2260 if (client_area) { | 2282 if (client_area) { |
2261 POINT pt = { window_x, window_y }; | 2283 POINT pt = { window_x, window_y }; |
2262 ScreenToClient(target_window, &pt); | 2284 ScreenToClient(target_window, &pt); |
2263 window_x = pt.x; | 2285 window_x = pt.x; |
2264 window_y = pt.y; | 2286 window_y = pt.y; |
2265 } | 2287 } |
2266 | 2288 |
2267 WPARAM target = client_area ? event.native_event().wParam : nc_hit_result; | 2289 WPARAM target = client_area ? event->native_event().wParam : nc_hit_result; |
2268 LPARAM window_coords = MAKELPARAM(window_x, window_y); | 2290 LPARAM window_coords = MAKELPARAM(window_x, window_y); |
2269 PostMessage(target_window, event_type, target, window_coords); | 2291 PostMessage(target_window, event_type, target, window_coords); |
2270 return; | 2292 return; |
2271 } | 2293 } |
2272 #endif | 2294 #endif |
2273 // Non-Windows Aura or |window| is in metro mode. | 2295 // Non Aura window. |
2274 if (!window) | 2296 if (!window) |
2275 return; | 2297 return; |
2276 | 2298 |
2277 MenuMessageLoop::RepostEventToWindow(event, window, screen_loc); | 2299 MenuMessageLoop::RepostEventToWindow(event, window, screen_loc); |
2278 } | 2300 } |
2279 | 2301 |
2280 void MenuController::SetDropMenuItem( | 2302 void MenuController::SetDropMenuItem( |
2281 MenuItemView* new_target, | 2303 MenuItemView* new_target, |
2282 MenuDelegate::DropPosition new_position) { | 2304 MenuDelegate::DropPosition new_position) { |
2283 if (new_target == drop_target_ && new_position == drop_position_) | 2305 if (new_target == drop_target_ && new_position == drop_position_) |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2528 } | 2550 } |
2529 } | 2551 } |
2530 | 2552 |
2531 gfx::Screen* MenuController::GetScreen() { | 2553 gfx::Screen* MenuController::GetScreen() { |
2532 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; | 2554 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; |
2533 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) | 2555 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) |
2534 : gfx::Screen::GetNativeScreen(); | 2556 : gfx::Screen::GetNativeScreen(); |
2535 } | 2557 } |
2536 | 2558 |
2537 } // namespace views | 2559 } // namespace views |
OLD | NEW |