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

Side by Side Diff: ui/views/focus/focus_manager.cc

Issue 727583002: Regression: Search+Key pops up app launcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « ui/base/ui_base.gyp ('k') | ui/wm/core/accelerator_filter.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/focus/focus_manager.h" 5 #include "ui/views/focus/focus_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 12 matching lines...) Expand all
23 #include "ui/views/focus/widget_focus_manager.h" 23 #include "ui/views/focus/widget_focus_manager.h"
24 #include "ui/views/view.h" 24 #include "ui/views/view.h"
25 #include "ui/views/widget/root_view.h" 25 #include "ui/views/widget/root_view.h"
26 #include "ui/views/widget/widget.h" 26 #include "ui/views/widget/widget.h"
27 #include "ui/views/widget/widget_delegate.h" 27 #include "ui/views/widget/widget_delegate.h"
28 28
29 namespace views { 29 namespace views {
30 30
31 namespace { 31 namespace {
32 32
33 #if defined(OS_MACOSX) || defined(OS_CHROMEOS)
34 static const int kEventFlagsMask = ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN |
35 ui::EF_ALT_DOWN | ui::EF_COMMAND_DOWN;
36 #else
37 static const int kEventFlagsMask = ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN |
38 ui::EF_ALT_DOWN;
39 #endif
40
41 static inline int CalculateModifiers(const ui::KeyEvent& event) {
42 return event.flags() & kEventFlagsMask;
43 }
44
33 } // namespace 45 } // namespace
34 46
35 bool FocusManager::shortcut_handling_suspended_ = false; 47 bool FocusManager::shortcut_handling_suspended_ = false;
36 bool FocusManager::arrow_key_traversal_enabled_ = false; 48 bool FocusManager::arrow_key_traversal_enabled_ = false;
37 49
38 FocusManager::FocusManager(Widget* widget, FocusManagerDelegate* delegate) 50 FocusManager::FocusManager(Widget* widget, FocusManagerDelegate* delegate)
39 : widget_(widget), 51 : widget_(widget),
40 delegate_(delegate), 52 delegate_(delegate),
41 focused_view_(NULL), 53 focused_view_(NULL),
42 accelerator_manager_(new ui::AcceleratorManager), 54 accelerator_manager_(new ui::AcceleratorManager),
43 focus_change_reason_(kReasonDirectFocusChange), 55 focus_change_reason_(kReasonDirectFocusChange),
44 is_changing_focus_(false) { 56 is_changing_focus_(false) {
45 DCHECK(widget_); 57 DCHECK(widget_);
46 stored_focused_view_storage_id_ = 58 stored_focused_view_storage_id_ =
47 ViewStorage::GetInstance()->CreateStorageID(); 59 ViewStorage::GetInstance()->CreateStorageID();
48 } 60 }
49 61
50 FocusManager::~FocusManager() { 62 FocusManager::~FocusManager() {
51 } 63 }
52 64
53 bool FocusManager::OnKeyEvent(const ui::KeyEvent& event) { 65 bool FocusManager::OnKeyEvent(const ui::KeyEvent& event) {
54 const int key_code = event.key_code(); 66 const int key_code = event.key_code();
55 67
56 if (event.type() != ui::ET_KEY_PRESSED && event.type() != ui::ET_KEY_RELEASED) 68 if (event.type() != ui::ET_KEY_PRESSED && event.type() != ui::ET_KEY_RELEASED)
57 return false; 69 return false;
58 70
59 if (shortcut_handling_suspended()) 71 if (shortcut_handling_suspended())
60 return true; 72 return true;
61 73
62 int modifiers = ui::EF_NONE; 74 int modifiers = CalculateModifiers(event);
63 if (event.IsShiftDown())
64 modifiers |= ui::EF_SHIFT_DOWN;
65 if (event.IsControlDown())
66 modifiers |= ui::EF_CONTROL_DOWN;
67 if (event.IsAltDown())
68 modifiers |= ui::EF_ALT_DOWN;
69 #if defined(OS_MACOSX) || defined(OS_CHROMEOS)
70 if (event.IsCommandDown())
71 modifiers |= ui::EF_COMMAND_DOWN;
72 #endif
73 ui::Accelerator accelerator(event.key_code(), modifiers); 75 ui::Accelerator accelerator(event.key_code(), modifiers);
74 accelerator.set_type(event.type()); 76 accelerator.set_type(event.type());
75 accelerator.set_is_repeat(event.IsRepeat()); 77 accelerator.set_is_repeat(event.IsRepeat());
76 78
77 if (event.type() == ui::ET_KEY_PRESSED) { 79 if (event.type() == ui::ET_KEY_PRESSED) {
78 // If the focused view wants to process the key event as is, let it be. 80 // If the focused view wants to process the key event as is, let it be.
79 if (focused_view_ && focused_view_->SkipDefaultKeyEventProcessing(event) && 81 if (focused_view_ && focused_view_->SkipDefaultKeyEventProcessing(event) &&
80 !accelerator_manager_->HasPriorityHandler(accelerator)) 82 !accelerator_manager_->HasPriorityHandler(accelerator))
81 return true; 83 return true;
82 84
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 } 606 }
605 if (key_code == ui::VKEY_RIGHT || key_code == ui::VKEY_DOWN) { 607 if (key_code == ui::VKEY_RIGHT || key_code == ui::VKEY_DOWN) {
606 AdvanceFocus(false); 608 AdvanceFocus(false);
607 return true; 609 return true;
608 } 610 }
609 611
610 return false; 612 return false;
611 } 613 }
612 614
613 } // namespace views 615 } // namespace views
OLDNEW
« no previous file with comments | « ui/base/ui_base.gyp ('k') | ui/wm/core/accelerator_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698