Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Side by Side Diff: ui/views/controls/menu/menu_controller.cc

Issue 9958152: Consolidate win/x dispatchers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/time.h" 9 #include "base/time.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 883
884 // NOTE: focus wasn't changed when the menu was shown. As such, don't 884 // NOTE: focus wasn't changed when the menu was shown. As such, don't
885 // dispatch key events otherwise the focused window will get the events. 885 // dispatch key events otherwise the focused window will get the events.
886 case WM_KEYDOWN: { 886 case WM_KEYDOWN: {
887 bool result = OnKeyDown(ui::KeyboardCodeFromNative(msg)); 887 bool result = OnKeyDown(ui::KeyboardCodeFromNative(msg));
888 TranslateMessage(&msg); 888 TranslateMessage(&msg);
889 return result; 889 return result;
890 } 890 }
891 case WM_CHAR: 891 case WM_CHAR:
892 return !SelectByChar(static_cast<char16>(msg.wParam)); 892 return !SelectByChar(static_cast<char16>(msg.wParam));
893
894 case WM_KEYUP: 893 case WM_KEYUP:
895 return true; 894 return true;
896 895
897 case WM_SYSKEYUP: 896 case WM_SYSKEYUP:
898 // We may have been shown on a system key, as such don't do anything 897 // We may have been shown on a system key, as such don't do anything
899 // here. If another system key is pushed we'll get a WM_SYSKEYDOWN and 898 // here. If another system key is pushed we'll get a WM_SYSKEYDOWN and
900 // close the menu. 899 // close the menu.
901 return true; 900 return true;
902 901
903 case WM_CANCELMODE: 902 case WM_CANCELMODE:
(...skipping 11 matching lines...) Expand all
915 } 914 }
916 #elif defined(USE_WAYLAND) 915 #elif defined(USE_WAYLAND)
917 base::MessagePumpDispatcher::DispatchStatus 916 base::MessagePumpDispatcher::DispatchStatus
918 MenuController::Dispatch(base::wayland::WaylandEvent* ev) { 917 MenuController::Dispatch(base::wayland::WaylandEvent* ev) {
919 return exit_type_ != EXIT_NONE ? 918 return exit_type_ != EXIT_NONE ?
920 base::MessagePumpDispatcher::EVENT_QUIT : 919 base::MessagePumpDispatcher::EVENT_QUIT :
921 base::MessagePumpDispatcher::EVENT_PROCESSED; 920 base::MessagePumpDispatcher::EVENT_PROCESSED;
922 } 921 }
923 922
924 #elif defined(USE_AURA) 923 #elif defined(USE_AURA)
925 base::MessagePumpDispatcher::DispatchStatus 924 bool MenuController::Dispatch(const base::NativeEvent& xev) {
926 MenuController::Dispatch(XEvent* xev) { 925 // XEvent* xev = event;
sadrul 2012/04/06 00:16:57 remove this line
oshima 2012/04/06 00:34:35 Oops, done. Thank you for the catch.
927 if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) { 926 if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) {
928 aura::Env::GetInstance()->GetDispatcher()->Dispatch(xev); 927 aura::Env::GetInstance()->GetDispatcher()->Dispatch(xev);
929 return base::MessagePumpDispatcher::EVENT_QUIT; 928 return false;
930 } 929 }
931 switch (ui::EventTypeFromNative(xev)) { 930 switch (ui::EventTypeFromNative(xev)) {
932 case ui::ET_KEY_PRESSED: 931 case ui::ET_KEY_PRESSED:
933 if (!OnKeyDown(ui::KeyboardCodeFromNative(xev))) 932 if (!OnKeyDown(ui::KeyboardCodeFromNative(xev)))
934 return base::MessagePumpDispatcher::EVENT_QUIT; 933 return false;
935 934
936 return SelectByChar(ui::KeyboardCodeFromNative(xev)) ? 935 return !SelectByChar(ui::KeyboardCodeFromNative(xev));
937 base::MessagePumpDispatcher::EVENT_QUIT :
938 base::MessagePumpDispatcher::EVENT_PROCESSED;
939 case ui::ET_KEY_RELEASED: 936 case ui::ET_KEY_RELEASED:
940 return base::MessagePumpDispatcher::EVENT_PROCESSED; 937 return true;
941 default: 938 default:
942 break; 939 break;
943 } 940 }
944 941
945 // TODO(oshima): Update Windows' Dispatcher to return DispatchStatus 942 aura::Env::GetInstance()->GetDispatcher()->Dispatch(xev);
946 // instead of bool. 943 return exit_type_ == EXIT_NONE;
947 if (aura::Env::GetInstance()->GetDispatcher()->Dispatch(xev) ==
948 base::MessagePumpDispatcher::EVENT_IGNORED)
949 return EVENT_IGNORED;
950 return exit_type_ != EXIT_NONE ?
951 base::MessagePumpDispatcher::EVENT_QUIT :
952 base::MessagePumpDispatcher::EVENT_PROCESSED;
953 } 944 }
954 #endif 945 #endif
955 946
956 bool MenuController::OnKeyDown(ui::KeyboardCode key_code) { 947 bool MenuController::OnKeyDown(ui::KeyboardCode key_code) {
957 DCHECK(blocking_run_); 948 DCHECK(blocking_run_);
958 949
959 switch (key_code) { 950 switch (key_code) {
960 case ui::VKEY_UP: 951 case ui::VKEY_UP:
961 IncrementSelection(-1); 952 IncrementSelection(-1);
962 break; 953 break;
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after
2024 (!pending_state_.item->HasSubmenu() || 2015 (!pending_state_.item->HasSubmenu() ||
2025 !pending_state_.item->GetSubmenu()->IsShowing())) { 2016 !pending_state_.item->GetSubmenu()->IsShowing())) {
2026 // On exit if the user hasn't selected an item with a submenu, move the 2017 // On exit if the user hasn't selected an item with a submenu, move the
2027 // selection back to the parent menu item. 2018 // selection back to the parent menu item.
2028 SetSelection(pending_state_.item->GetParentMenuItem(), 2019 SetSelection(pending_state_.item->GetParentMenuItem(),
2029 SELECTION_OPEN_SUBMENU); 2020 SELECTION_OPEN_SUBMENU);
2030 } 2021 }
2031 } 2022 }
2032 2023
2033 } // namespace views 2024 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698