Chromium Code Reviews| 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 "views/controls/menu/menu_controller.h" | 5 #include "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/widget/root_view.h" | 17 #include "ui/views/widget/root_view.h" |
| 18 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
| 19 #include "views/controls/button/menu_button.h" | 19 #include "views/controls/button/menu_button.h" |
| 20 #include "views/controls/menu/menu_controller_delegate.h" | 20 #include "views/controls/menu/menu_controller_delegate.h" |
| 21 #include "views/controls/menu/menu_scroll_view_container.h" | 21 #include "views/controls/menu/menu_scroll_view_container.h" |
| 22 #include "views/controls/menu/submenu_view.h" | 22 #include "views/controls/menu/submenu_view.h" |
| 23 #include "views/drag_utils.h" | 23 #include "views/drag_utils.h" |
| 24 #include "views/view_constants.h" | 24 #include "views/view_constants.h" |
| 25 #include "views/views_delegate.h" | 25 #include "views/views_delegate.h" |
| 26 | 26 |
| 27 #if defined(USE_AURA) | 27 #if defined(USE_AURA) |
| 28 #include "ui/aura/desktop.h" | 28 #include "ui/aura/desktop.h" |
| 29 #endif | 29 #elif defined(TOOLKIT_USES_GTK) |
| 30 | |
| 31 #if defined(TOOLKIT_USES_GTK) | |
| 32 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h" | 30 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h" |
| 33 #endif | 31 #endif |
| 34 | 32 |
| 35 #if defined(TOUCH_UI) | |
| 36 #include "ui/views/focus/accelerator_handler.h" | |
| 37 #endif | |
| 38 | |
| 39 using base::Time; | 33 using base::Time; |
| 40 using base::TimeDelta; | 34 using base::TimeDelta; |
| 41 using ui::OSExchangeData; | 35 using ui::OSExchangeData; |
| 42 | 36 |
| 43 // Period of the scroll timer (in milliseconds). | 37 // Period of the scroll timer (in milliseconds). |
| 44 static const int kScrollTimerMS = 30; | 38 static const int kScrollTimerMS = 30; |
| 45 | 39 |
| 46 // Delay, in ms, between when menus are selected are moused over and the menu | 40 // Delay, in ms, between when menus are selected are moused over and the menu |
| 47 // appears. | 41 // appears. |
| 48 static const int kShowDelay = 400; | 42 static const int kShowDelay = 400; |
| (...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 910 | 904 |
| 911 // TODO(oshima): Update Windows' Dispatcher to return DispatchStatus | 905 // TODO(oshima): Update Windows' Dispatcher to return DispatchStatus |
| 912 // instead of bool. | 906 // instead of bool. |
| 913 if (aura::Desktop::GetInstance()->GetDispatcher()->Dispatch(xev) == | 907 if (aura::Desktop::GetInstance()->GetDispatcher()->Dispatch(xev) == |
| 914 base::MessagePumpDispatcher::EVENT_IGNORED) | 908 base::MessagePumpDispatcher::EVENT_IGNORED) |
| 915 return EVENT_IGNORED; | 909 return EVENT_IGNORED; |
| 916 return exit_type_ != EXIT_NONE ? | 910 return exit_type_ != EXIT_NONE ? |
| 917 base::MessagePumpDispatcher::EVENT_QUIT : | 911 base::MessagePumpDispatcher::EVENT_QUIT : |
| 918 base::MessagePumpDispatcher::EVENT_PROCESSED; | 912 base::MessagePumpDispatcher::EVENT_PROCESSED; |
| 919 } | 913 } |
| 920 #elif defined(TOUCH_UI) | |
| 921 base::MessagePumpDispatcher::DispatchStatus | |
|
sky
2011/11/22 22:39:18
Does the header need to be updated too?
Emmanuel Saint-loubert-Bié
2011/11/22 22:42:38
No the header is already clean (not sure why thoug
| |
| 922 MenuController::Dispatch(XEvent* xev) { | |
| 923 if (!DispatchXEvent(xev)) | |
| 924 return EVENT_IGNORED; | |
| 925 | |
| 926 return exit_type_ != EXIT_NONE ? | |
| 927 base::MessagePumpDispatcher::EVENT_QUIT : | |
| 928 base::MessagePumpDispatcher::EVENT_PROCESSED; | |
| 929 } | |
| 930 #else | 914 #else |
| 931 bool MenuController::Dispatch(GdkEvent* event) { | 915 bool MenuController::Dispatch(GdkEvent* event) { |
| 932 if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) { | 916 if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) { |
| 933 gtk_main_do_event(event); | 917 gtk_main_do_event(event); |
| 934 return false; | 918 return false; |
| 935 } | 919 } |
| 936 | 920 |
| 937 switch (event->type) { | 921 switch (event->type) { |
| 938 case GDK_KEY_PRESS: { | 922 case GDK_KEY_PRESS: { |
| 939 if (!OnKeyDown(ui::WindowsKeyCodeForGdkKeyCode(event->key.keyval))) | 923 if (!OnKeyDown(ui::WindowsKeyCodeForGdkKeyCode(event->key.keyval))) |
| (...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1962 // is necessary to exit from nested loop (See Dispatch methods). | 1946 // is necessary to exit from nested loop (See Dispatch methods). |
| 1963 // 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. |
| 1964 // crbug.com/104684. | 1948 // crbug.com/104684. |
| 1965 if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) | 1949 if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) |
| 1966 aura::Desktop::GetInstance()->PostNativeEvent(ui::CreateNoopEvent()); | 1950 aura::Desktop::GetInstance()->PostNativeEvent(ui::CreateNoopEvent()); |
| 1967 #endif | 1951 #endif |
| 1968 } | 1952 } |
| 1969 | 1953 |
| 1970 | 1954 |
| 1971 } // namespace views | 1955 } // namespace views |
| OLD | NEW |