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

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, addressed comments 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
« no previous file with comments | « ui/views/controls/menu/menu_controller.h ('k') | ui/views/focus/accelerator_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:
904 case WM_SYSKEYDOWN: 903 case WM_SYSKEYDOWN:
905 // Exit immediately on system keys. 904 // Exit immediately on system keys.
906 Cancel(EXIT_ALL); 905 Cancel(EXIT_ALL);
907 return false; 906 return false;
908 907
909 default: 908 default:
910 break; 909 break;
911 } 910 }
912 TranslateMessage(&msg); 911 TranslateMessage(&msg);
913 DispatchMessage(&msg); 912 DispatchMessage(&msg);
914 return exit_type_ == EXIT_NONE; 913 return exit_type_ == EXIT_NONE;
915 } 914 }
916 #elif defined(USE_AURA) 915 #elif defined(USE_AURA)
917 base::MessagePumpDispatcher::DispatchStatus 916 bool MenuController::Dispatch(const base::NativeEvent& event) {
918 MenuController::Dispatch(XEvent* xev) {
919 if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) { 917 if (exit_type_ == EXIT_ALL || exit_type_ == EXIT_DESTROYED) {
920 aura::Env::GetInstance()->GetDispatcher()->Dispatch(xev); 918 aura::Env::GetInstance()->GetDispatcher()->Dispatch(event);
921 return base::MessagePumpDispatcher::EVENT_QUIT; 919 return false;
922 } 920 }
923 switch (ui::EventTypeFromNative(xev)) { 921 switch (ui::EventTypeFromNative(event)) {
924 case ui::ET_KEY_PRESSED: 922 case ui::ET_KEY_PRESSED:
925 if (!OnKeyDown(ui::KeyboardCodeFromNative(xev))) 923 if (!OnKeyDown(ui::KeyboardCodeFromNative(event)))
926 return base::MessagePumpDispatcher::EVENT_QUIT; 924 return false;
927 925
928 return SelectByChar(ui::KeyboardCodeFromNative(xev)) ? 926 return !SelectByChar(ui::KeyboardCodeFromNative(event));
929 base::MessagePumpDispatcher::EVENT_QUIT :
930 base::MessagePumpDispatcher::EVENT_PROCESSED;
931 case ui::ET_KEY_RELEASED: 927 case ui::ET_KEY_RELEASED:
932 return base::MessagePumpDispatcher::EVENT_PROCESSED; 928 return true;
933 default: 929 default:
934 break; 930 break;
935 } 931 }
936 932
937 // TODO(oshima): Update Windows' Dispatcher to return DispatchStatus 933 aura::Env::GetInstance()->GetDispatcher()->Dispatch(event);
938 // instead of bool. 934 return exit_type_ == EXIT_NONE;
939 if (aura::Env::GetInstance()->GetDispatcher()->Dispatch(xev) ==
940 base::MessagePumpDispatcher::EVENT_IGNORED)
941 return EVENT_IGNORED;
942 return exit_type_ != EXIT_NONE ?
943 base::MessagePumpDispatcher::EVENT_QUIT :
944 base::MessagePumpDispatcher::EVENT_PROCESSED;
945 } 935 }
946 #endif 936 #endif
947 937
948 bool MenuController::OnKeyDown(ui::KeyboardCode key_code) { 938 bool MenuController::OnKeyDown(ui::KeyboardCode key_code) {
949 DCHECK(blocking_run_); 939 DCHECK(blocking_run_);
950 940
951 switch (key_code) { 941 switch (key_code) {
952 case ui::VKEY_UP: 942 case ui::VKEY_UP:
953 IncrementSelection(-1); 943 IncrementSelection(-1);
954 break; 944 break;
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after
2016 (!pending_state_.item->HasSubmenu() || 2006 (!pending_state_.item->HasSubmenu() ||
2017 !pending_state_.item->GetSubmenu()->IsShowing())) { 2007 !pending_state_.item->GetSubmenu()->IsShowing())) {
2018 // On exit if the user hasn't selected an item with a submenu, move the 2008 // On exit if the user hasn't selected an item with a submenu, move the
2019 // selection back to the parent menu item. 2009 // selection back to the parent menu item.
2020 SetSelection(pending_state_.item->GetParentMenuItem(), 2010 SetSelection(pending_state_.item->GetParentMenuItem(),
2021 SELECTION_OPEN_SUBMENU); 2011 SELECTION_OPEN_SUBMENU);
2022 } 2012 }
2023 } 2013 }
2024 2014
2025 } // namespace views 2015 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_controller.h ('k') | ui/views/focus/accelerator_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698