| 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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windowsx.h> | 8 #include <windowsx.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 #include "base/i18n/case_conversion.h" | 11 #include "base/i18n/case_conversion.h" |
| 12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
| 13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "ui/aura/env.h" |
| 17 #include "ui/aura/window_event_dispatcher.h" |
| 16 #include "ui/base/dragdrop/drag_utils.h" | 18 #include "ui/base/dragdrop/drag_utils.h" |
| 17 #include "ui/base/dragdrop/os_exchange_data.h" | 19 #include "ui/base/dragdrop/os_exchange_data.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/events/event_constants.h" | 21 #include "ui/events/event_constants.h" |
| 20 #include "ui/events/event_utils.h" | 22 #include "ui/events/event_utils.h" |
| 21 #include "ui/events/keycodes/keyboard_code_conversion.h" | 23 #include "ui/events/keycodes/keyboard_code_conversion.h" |
| 22 #include "ui/events/keycodes/keyboard_codes.h" | 24 #include "ui/events/keycodes/keyboard_codes.h" |
| 23 #include "ui/gfx/canvas.h" | 25 #include "ui/gfx/canvas.h" |
| 24 #include "ui/gfx/native_widget_types.h" | 26 #include "ui/gfx/native_widget_types.h" |
| 25 #include "ui/gfx/screen.h" | 27 #include "ui/gfx/screen.h" |
| 26 #include "ui/gfx/vector2d.h" | 28 #include "ui/gfx/vector2d.h" |
| 27 #include "ui/native_theme/native_theme.h" | 29 #include "ui/native_theme/native_theme.h" |
| 28 #include "ui/views/controls/button/menu_button.h" | 30 #include "ui/views/controls/button/menu_button.h" |
| 29 #include "ui/views/controls/menu/menu_config.h" | 31 #include "ui/views/controls/menu/menu_config.h" |
| 30 #include "ui/views/controls/menu/menu_controller_delegate.h" | 32 #include "ui/views/controls/menu/menu_controller_delegate.h" |
| 31 #include "ui/views/controls/menu/menu_host_root_view.h" | 33 #include "ui/views/controls/menu/menu_host_root_view.h" |
| 32 #include "ui/views/controls/menu/menu_scroll_view_container.h" | 34 #include "ui/views/controls/menu/menu_scroll_view_container.h" |
| 33 #include "ui/views/controls/menu/submenu_view.h" | 35 #include "ui/views/controls/menu/submenu_view.h" |
| 34 #include "ui/views/drag_utils.h" | 36 #include "ui/views/drag_utils.h" |
| 35 #include "ui/views/event_utils.h" | 37 #include "ui/views/event_utils.h" |
| 36 #include "ui/views/focus/view_storage.h" | 38 #include "ui/views/focus/view_storage.h" |
| 37 #include "ui/views/mouse_constants.h" | 39 #include "ui/views/mouse_constants.h" |
| 38 #include "ui/views/view_constants.h" | 40 #include "ui/views/view_constants.h" |
| 39 #include "ui/views/views_delegate.h" | 41 #include "ui/views/views_delegate.h" |
| 40 #include "ui/views/widget/root_view.h" | 42 #include "ui/views/widget/root_view.h" |
| 41 #include "ui/views/widget/tooltip_manager.h" | 43 #include "ui/views/widget/tooltip_manager.h" |
| 42 #include "ui/views/widget/widget.h" | 44 #include "ui/views/widget/widget.h" |
| 43 | 45 |
| 44 #if defined(USE_AURA) | |
| 45 #include "ui/aura/env.h" | |
| 46 #include "ui/aura/window_event_dispatcher.h" | |
| 47 #endif | |
| 48 | |
| 49 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
| 50 #include "ui/views/win/hwnd_message_handler.h" | 47 #include "ui/views/win/hwnd_message_handler.h" |
| 51 #include "ui/views/win/hwnd_util.h" | 48 #include "ui/views/win/hwnd_util.h" |
| 52 #endif | 49 #endif |
| 53 | 50 |
| 54 #if defined(USE_X11) | 51 #if defined(USE_X11) |
| 55 #include <X11/Xlib.h> | 52 #include <X11/Xlib.h> |
| 56 #endif | 53 #endif |
| 57 | 54 |
| 58 using base::Time; | 55 using base::Time; |
| (...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 // of the menus from the last run. | 925 // of the menus from the last run. |
| 929 gfx::Point screen_loc(event.location()); | 926 gfx::Point screen_loc(event.location()); |
| 930 View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc); | 927 View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc); |
| 931 MenuPart last_part = GetMenuPartByScreenCoordinateUsingMenu( | 928 MenuPart last_part = GetMenuPartByScreenCoordinateUsingMenu( |
| 932 menu_stack_.back().item, screen_loc); | 929 menu_stack_.back().item, screen_loc); |
| 933 if (last_part.type != MenuPart::NONE) | 930 if (last_part.type != MenuPart::NONE) |
| 934 exit_type = EXIT_OUTERMOST; | 931 exit_type = EXIT_OUTERMOST; |
| 935 } | 932 } |
| 936 Cancel(exit_type); | 933 Cancel(exit_type); |
| 937 | 934 |
| 938 #if defined(USE_AURA) && !defined(OS_WIN) | 935 #if !defined(OS_WIN) |
| 939 // We're going to exit the menu and want to repost the event so that is | 936 // We're going to exit the menu and want to repost the event so that is |
| 940 // is handled normally after the context menu has exited. We call | 937 // is handled normally after the context menu has exited. We call |
| 941 // RepostEvent after Cancel so that mouse capture has been released so | 938 // RepostEvent after Cancel so that mouse capture has been released so |
| 942 // that finding the event target is unaffected by the current capture. | 939 // that finding the event target is unaffected by the current capture. |
| 943 RepostEvent(source, event); | 940 RepostEvent(source, event); |
| 944 #endif | 941 #endif |
| 945 | 942 |
| 946 return; | 943 return; |
| 947 } | 944 } |
| 948 | 945 |
| (...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2342 (!pending_state_.item->HasSubmenu() || | 2339 (!pending_state_.item->HasSubmenu() || |
| 2343 !pending_state_.item->GetSubmenu()->IsShowing())) { | 2340 !pending_state_.item->GetSubmenu()->IsShowing())) { |
| 2344 // On exit if the user hasn't selected an item with a submenu, move the | 2341 // On exit if the user hasn't selected an item with a submenu, move the |
| 2345 // selection back to the parent menu item. | 2342 // selection back to the parent menu item. |
| 2346 SetSelection(pending_state_.item->GetParentMenuItem(), | 2343 SetSelection(pending_state_.item->GetParentMenuItem(), |
| 2347 SELECTION_OPEN_SUBMENU); | 2344 SELECTION_OPEN_SUBMENU); |
| 2348 } | 2345 } |
| 2349 } | 2346 } |
| 2350 | 2347 |
| 2351 } // namespace views | 2348 } // namespace views |
| OLD | NEW |