| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/time.h" | 9 #include "base/time.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "ui/base/dragdrop/os_exchange_data.h" | 11 #include "ui/base/dragdrop/os_exchange_data.h" |
| 12 #include "ui/base/events.h" | 12 #include "ui/base/events.h" |
| 13 #include "ui/base/keycodes/keyboard_codes.h" | 13 #include "ui/base/keycodes/keyboard_codes.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/gfx/canvas_skia.h" | 15 #include "ui/gfx/canvas_skia.h" |
| 16 #include "ui/gfx/screen.h" | 16 #include "ui/gfx/screen.h" |
| 17 #include "ui/views/controls/button/menu_button.h" | 17 #include "ui/views/controls/button/menu_button.h" |
| 18 #include "ui/views/controls/menu/menu_controller_delegate.h" | 18 #include "ui/views/controls/menu/menu_controller_delegate.h" |
| 19 #include "ui/views/controls/menu/menu_scroll_view_container.h" | 19 #include "ui/views/controls/menu/menu_scroll_view_container.h" |
| 20 #include "ui/views/controls/menu/submenu_view.h" | 20 #include "ui/views/controls/menu/submenu_view.h" |
| 21 #include "ui/views/drag_utils.h" | 21 #include "ui/views/drag_utils.h" |
| 22 #include "ui/views/view_constants.h" | 22 #include "ui/views/view_constants.h" |
| 23 #include "ui/views/views_delegate.h" | 23 #include "ui/views/views_delegate.h" |
| 24 #include "ui/views/widget/root_view.h" | 24 #include "ui/views/widget/root_view.h" |
| 25 #include "ui/views/widget/widget.h" | 25 #include "ui/views/widget/widget.h" |
| 26 | 26 |
| 27 #if defined(USE_AURA) | 27 #if defined(USE_AURA) |
| 28 #include "ui/aura/desktop.h" | 28 #include "ui/aura/root_window.h" |
| 29 #elif defined(TOOLKIT_USES_GTK) | 29 #elif defined(TOOLKIT_USES_GTK) |
| 30 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h" | 30 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h" |
| 31 #endif | 31 #endif |
| 32 | 32 |
| 33 using base::Time; | 33 using base::Time; |
| 34 using base::TimeDelta; | 34 using base::TimeDelta; |
| 35 using ui::OSExchangeData; | 35 using ui::OSExchangeData; |
| 36 | 36 |
| 37 // Period of the scroll timer (in milliseconds). | 37 // Period of the scroll timer (in milliseconds). |
| 38 static const int kScrollTimerMS = 30; | 38 static const int kScrollTimerMS = 30; |
| (...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 MenuController::Dispatch(base::wayland::WaylandEvent* ev) { | 877 MenuController::Dispatch(base::wayland::WaylandEvent* ev) { |
| 878 return exit_type_ != EXIT_NONE ? | 878 return exit_type_ != EXIT_NONE ? |
| 879 base::MessagePumpDispatcher::EVENT_QUIT : | 879 base::MessagePumpDispatcher::EVENT_QUIT : |
| 880 base::MessagePumpDispatcher::EVENT_PROCESSED; | 880 base::MessagePumpDispatcher::EVENT_PROCESSED; |
| 881 } | 881 } |
| 882 | 882 |
| 883 #elif defined(USE_AURA) | 883 #elif defined(USE_AURA) |
| 884 base::MessagePumpDispatcher::DispatchStatus | 884 base::MessagePumpDispatcher::DispatchStatus |
| 885 MenuController::Dispatch(XEvent* xev) { | 885 MenuController::Dispatch(XEvent* xev) { |
| 886 if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) { | 886 if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) { |
| 887 aura::Desktop::GetInstance()->GetDispatcher()->Dispatch(xev); | 887 aura::RootWindow::GetInstance()->GetDispatcher()->Dispatch(xev); |
| 888 return base::MessagePumpDispatcher::EVENT_QUIT; | 888 return base::MessagePumpDispatcher::EVENT_QUIT; |
| 889 } | 889 } |
| 890 switch (ui::EventTypeFromNative(xev)) { | 890 switch (ui::EventTypeFromNative(xev)) { |
| 891 case ui::ET_KEY_PRESSED: | 891 case ui::ET_KEY_PRESSED: |
| 892 OnKeyDown(ui::KeyboardCodeFromNative(xev)); | 892 OnKeyDown(ui::KeyboardCodeFromNative(xev)); |
| 893 // OnKeyDown may have set exit_type_. | 893 // OnKeyDown may have set exit_type_. |
| 894 if (exit_type_ != EXIT_NONE) | 894 if (exit_type_ != EXIT_NONE) |
| 895 return base::MessagePumpDispatcher::EVENT_QUIT; | 895 return base::MessagePumpDispatcher::EVENT_QUIT; |
| 896 | 896 |
| 897 // TODO(oshima): support SelectChar | 897 // TODO(oshima): support SelectChar |
| 898 break; | 898 break; |
| 899 case ui::ET_KEY_RELEASED: | 899 case ui::ET_KEY_RELEASED: |
| 900 return base::MessagePumpDispatcher::EVENT_PROCESSED; | 900 return base::MessagePumpDispatcher::EVENT_PROCESSED; |
| 901 default: | 901 default: |
| 902 break; | 902 break; |
| 903 } | 903 } |
| 904 | 904 |
| 905 // TODO(oshima): Update Windows' Dispatcher to return DispatchStatus | 905 // TODO(oshima): Update Windows' Dispatcher to return DispatchStatus |
| 906 // instead of bool. | 906 // instead of bool. |
| 907 if (aura::Desktop::GetInstance()->GetDispatcher()->Dispatch(xev) == | 907 if (aura::RootWindow::GetInstance()->GetDispatcher()->Dispatch(xev) == |
| 908 base::MessagePumpDispatcher::EVENT_IGNORED) | 908 base::MessagePumpDispatcher::EVENT_IGNORED) |
| 909 return EVENT_IGNORED; | 909 return EVENT_IGNORED; |
| 910 return exit_type_ != EXIT_NONE ? | 910 return exit_type_ != EXIT_NONE ? |
| 911 base::MessagePumpDispatcher::EVENT_QUIT : | 911 base::MessagePumpDispatcher::EVENT_QUIT : |
| 912 base::MessagePumpDispatcher::EVENT_PROCESSED; | 912 base::MessagePumpDispatcher::EVENT_PROCESSED; |
| 913 } | 913 } |
| 914 #else | 914 #else |
| 915 bool MenuController::Dispatch(GdkEvent* event) { | 915 bool MenuController::Dispatch(GdkEvent* event) { |
| 916 if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) { | 916 if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) { |
| 917 gtk_main_do_event(event); | 917 gtk_main_do_event(event); |
| (...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1940 } | 1940 } |
| 1941 | 1941 |
| 1942 void MenuController::SetExitType(ExitType type) { | 1942 void MenuController::SetExitType(ExitType type) { |
| 1943 exit_type_ = type; | 1943 exit_type_ = type; |
| 1944 #if defined(USE_AURA) | 1944 #if defined(USE_AURA) |
| 1945 // On aura, closing menu may not trigger next native event, which | 1945 // On aura, closing menu may not trigger next native event, which |
| 1946 // is necessary to exit from nested loop (See Dispatch methods). | 1946 // is necessary to exit from nested loop (See Dispatch methods). |
| 1947 // Send non-op event so that Dispatch method will always be called. | 1947 // Send non-op event so that Dispatch method will always be called. |
| 1948 // crbug.com/104684. | 1948 // crbug.com/104684. |
| 1949 if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) | 1949 if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) |
| 1950 aura::Desktop::GetInstance()->PostNativeEvent(ui::CreateNoopEvent()); | 1950 aura::RootWindow::GetInstance()->PostNativeEvent(ui::CreateNoopEvent()); |
| 1951 #endif | 1951 #endif |
| 1952 } | 1952 } |
| 1953 | 1953 |
| 1954 | 1954 |
| 1955 } // namespace views | 1955 } // namespace views |
| OLD | NEW |