| 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 2251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2262 | 2262 |
| 2263 MenuMessageLoop::RepostEventToWindow(event, window, screen_loc); | 2263 MenuMessageLoop::RepostEventToWindow(event, window, screen_loc); |
| 2264 } | 2264 } |
| 2265 | 2265 |
| 2266 void MenuController::RepostEventAndCancel(SubmenuView* source, | 2266 void MenuController::RepostEventAndCancel(SubmenuView* source, |
| 2267 const ui::LocatedEvent* event) { | 2267 const ui::LocatedEvent* event) { |
| 2268 // Cancel can lead to the deletion |source| so we save the view and window to | 2268 // Cancel can lead to the deletion |source| so we save the view and window to |
| 2269 // be used when reposting the event. | 2269 // be used when reposting the event. |
| 2270 gfx::Point screen_loc(event->location()); | 2270 gfx::Point screen_loc(event->location()); |
| 2271 View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc); | 2271 View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc); |
| 2272 |
| 2273 #if defined(OS_WIN) || defined(OS_CHROMEOS) |
| 2272 gfx::NativeView native_view = source->GetWidget()->GetNativeView(); | 2274 gfx::NativeView native_view = source->GetWidget()->GetNativeView(); |
| 2273 gfx::NativeWindow window = nullptr; | 2275 gfx::NativeWindow window = nullptr; |
| 2274 if (native_view) { | 2276 if (native_view) { |
| 2275 gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view); | 2277 gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view); |
| 2276 window = screen->GetWindowAtScreenPoint(screen_loc); | 2278 window = screen->GetWindowAtScreenPoint(screen_loc); |
| 2277 } | 2279 } |
| 2280 #endif |
| 2278 | 2281 |
| 2279 #if defined(OS_WIN) | 2282 #if defined(OS_WIN) |
| 2280 // We're going to close and we own the event capture. We need to repost the | 2283 // We're going to close and we own the event capture. We need to repost the |
| 2281 // event, otherwise the window the user clicked on won't get the event. | 2284 // event, otherwise the window the user clicked on won't get the event. |
| 2282 RepostEvent(source, event, screen_loc, native_view, window); | 2285 RepostEvent(source, event, screen_loc, native_view, window); |
| 2283 #endif | 2286 #endif |
| 2284 | 2287 |
| 2285 // Determine target to see if a complete or partial close of the menu should | 2288 // Determine target to see if a complete or partial close of the menu should |
| 2286 // occur. | 2289 // occur. |
| 2287 ExitType exit_type = EXIT_ALL; | 2290 ExitType exit_type = EXIT_ALL; |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2568 } | 2571 } |
| 2569 } | 2572 } |
| 2570 | 2573 |
| 2571 gfx::Screen* MenuController::GetScreen() { | 2574 gfx::Screen* MenuController::GetScreen() { |
| 2572 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; | 2575 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; |
| 2573 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) | 2576 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) |
| 2574 : gfx::Screen::GetNativeScreen(); | 2577 : gfx::Screen::GetNativeScreen(); |
| 2575 } | 2578 } |
| 2576 | 2579 |
| 2577 } // namespace views | 2580 } // namespace views |
| OLD | NEW |