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