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

Side by Side Diff: ash/focus_cycler.cc

Issue 9406031: Makes it so the launcher only gets focus when using the keyboard. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to trunk Created 8 years, 10 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 | « ash/focus_cycler.h ('k') | ash/launcher/app_launcher_button.cc » ('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 "ash/focus_cycler.h" 5 #include "ash/focus_cycler.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_delegate.h" 8 #include "ash/shell_delegate.h"
9 #include "ui/views/widget/widget.h" 9 #include "ui/views/widget/widget.h"
10 #include "ui/views/focus/focus_search.h" 10 #include "ui/views/focus/focus_search.h"
11 #include "ui/aura/window.h" 11 #include "ui/aura/window.h"
12 #include "ui/aura/client/activation_client.h" 12 #include "ui/aura/client/activation_client.h"
13 13
14 #include "ui/views/accessible_pane_view.h" 14 #include "ui/views/accessible_pane_view.h"
15 15
16 namespace ash { 16 namespace ash {
17 17
18 namespace internal { 18 namespace internal {
19 19
20 FocusCycler::FocusCycler() { 20 FocusCycler::FocusCycler() : widget_activating_(NULL) {
21 } 21 }
22 22
23 FocusCycler::~FocusCycler() { 23 FocusCycler::~FocusCycler() {
24 } 24 }
25 25
26 void FocusCycler::AddWidget(views::Widget* widget) { 26 void FocusCycler::AddWidget(views::Widget* widget) {
27 widgets_.push_back(widget); 27 widgets_.push_back(widget);
28 28
29 widget->GetFocusManager()->RegisterAccelerator( 29 widget->GetFocusManager()->RegisterAccelerator(
30 ui::Accelerator(ui::VKEY_F2, false, true, false), this); 30 ui::Accelerator(ui::VKEY_F2, false, true, false), this);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 if (!windows.empty()) { 64 if (!windows.empty()) {
65 aura::client::GetActivationClient()->ActivateWindow(windows[0]); 65 aura::client::GetActivationClient()->ActivateWindow(windows[0]);
66 break; 66 break;
67 } 67 }
68 } else { 68 } else {
69 views::Widget* widget = widgets_[index]; 69 views::Widget* widget = widgets_[index];
70 70
71 views::AccessiblePaneView* view = 71 views::AccessiblePaneView* view =
72 static_cast<views::AccessiblePaneView*>(widget->GetContentsView()); 72 static_cast<views::AccessiblePaneView*>(widget->GetContentsView());
73 if (view->SetPaneFocusAndFocusDefault()) { 73 if (view->SetPaneFocusAndFocusDefault()) {
74 widget_activating_ = widget;
74 widget->Activate(); 75 widget->Activate();
76 widget_activating_ = NULL;
75 if (widget->IsActive()) 77 if (widget->IsActive())
76 break; 78 break;
77 } 79 }
78 } 80 }
79 } 81 }
80 } 82 }
81 83
82 bool FocusCycler::AcceleratorPressed(const ui::Accelerator& accelerator) { 84 bool FocusCycler::AcceleratorPressed(const ui::Accelerator& accelerator) {
83 switch (accelerator.key_code()) { 85 switch (accelerator.key_code()) {
84 case ui::VKEY_F1: 86 case ui::VKEY_F1:
85 RotateFocus(BACKWARD); 87 RotateFocus(BACKWARD);
86 return true; 88 return true;
87 case ui::VKEY_F2: 89 case ui::VKEY_F2:
88 RotateFocus(FORWARD); 90 RotateFocus(FORWARD);
89 return true; 91 return true;
90 default: 92 default:
91 return false; 93 return false;
92 } 94 }
93 } 95 }
94 96
95 bool FocusCycler::CanHandleAccelerators() const { 97 bool FocusCycler::CanHandleAccelerators() const {
96 return true; 98 return true;
97 } 99 }
98 100
99 } // namespace internal 101 } // namespace internal
100 102
101 } // namespace ash 103 } // namespace ash
OLDNEW
« no previous file with comments | « ash/focus_cycler.h ('k') | ash/launcher/app_launcher_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698