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

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

Issue 10825254: Remove views::KeyEvent, replacing uses of it with ui::KeyEvent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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/focus/focus_manager.h ('k') | ui/views/focus/focus_manager_unittest_win.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 "ui/views/focus/focus_manager.h" 5 #include "ui/views/focus/focus_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "ui/base/accelerators/accelerator.h" 12 #include "ui/base/accelerators/accelerator.h"
13 #include "ui/base/event.h"
13 #include "ui/base/keycodes/keyboard_codes.h" 14 #include "ui/base/keycodes/keyboard_codes.h"
14 #include "ui/views/focus/focus_manager_delegate.h" 15 #include "ui/views/focus/focus_manager_delegate.h"
15 #include "ui/views/focus/focus_search.h" 16 #include "ui/views/focus/focus_search.h"
16 #include "ui/views/focus/view_storage.h" 17 #include "ui/views/focus/view_storage.h"
17 #include "ui/views/focus/widget_focus_manager.h" 18 #include "ui/views/focus/widget_focus_manager.h"
18 #include "ui/views/view.h" 19 #include "ui/views/view.h"
19 #include "ui/views/widget/root_view.h" 20 #include "ui/views/widget/root_view.h"
20 #include "ui/views/widget/widget.h" 21 #include "ui/views/widget/widget.h"
21 22
22 namespace views { 23 namespace views {
(...skipping 11 matching lines...) Expand all
34 #endif 35 #endif
35 is_changing_focus_(false) { 36 is_changing_focus_(false) {
36 DCHECK(widget_); 37 DCHECK(widget_);
37 stored_focused_view_storage_id_ = 38 stored_focused_view_storage_id_ =
38 ViewStorage::GetInstance()->CreateStorageID(); 39 ViewStorage::GetInstance()->CreateStorageID();
39 } 40 }
40 41
41 FocusManager::~FocusManager() { 42 FocusManager::~FocusManager() {
42 } 43 }
43 44
44 bool FocusManager::OnKeyEvent(const KeyEvent& event) { 45 bool FocusManager::OnKeyEvent(const ui::KeyEvent& event) {
45 const int key_code = event.key_code(); 46 const int key_code = event.key_code();
46 47
47 #if defined(USE_X11) 48 #if defined(USE_X11)
48 // TODO(ben): beng believes that this should be done in 49 // TODO(ben): beng believes that this should be done in
49 // RootWindowHosLinux for aura/linux. 50 // RootWindowHosLinux for aura/linux.
50 51
51 // Always reset |should_handle_menu_key_release_| unless we are handling a 52 // Always reset |should_handle_menu_key_release_| unless we are handling a
52 // VKEY_MENU key release event. It ensures that VKEY_MENU accelerator can only 53 // VKEY_MENU key release event. It ensures that VKEY_MENU accelerator can only
53 // be activated when handling a VKEY_MENU key release event which is preceded 54 // be activated when handling a VKEY_MENU key release event which is preceded
54 // by an un-handled VKEY_MENU key press event. 55 // by an un-handled VKEY_MENU key press event.
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 } 437 }
437 438
438 bool FocusManager::ProcessAccelerator(const ui::Accelerator& accelerator) { 439 bool FocusManager::ProcessAccelerator(const ui::Accelerator& accelerator) {
439 if (accelerator_manager_->Process(accelerator)) 440 if (accelerator_manager_->Process(accelerator))
440 return true; 441 return true;
441 if (delegate_.get()) 442 if (delegate_.get())
442 return delegate_->ProcessAccelerator(accelerator); 443 return delegate_->ProcessAccelerator(accelerator);
443 return false; 444 return false;
444 } 445 }
445 446
446 void FocusManager::MaybeResetMenuKeyState(const KeyEvent& key) { 447 void FocusManager::MaybeResetMenuKeyState(const ui::KeyEvent& key) {
447 #if defined(USE_X11) 448 #if defined(USE_X11)
448 // Always reset |should_handle_menu_key_release_| unless we are handling a 449 // Always reset |should_handle_menu_key_release_| unless we are handling a
449 // VKEY_MENU key release event. It ensures that VKEY_MENU accelerator can only 450 // VKEY_MENU key release event. It ensures that VKEY_MENU accelerator can only
450 // be activated when handling a VKEY_MENU key release event which is preceded 451 // be activated when handling a VKEY_MENU key release event which is preceded
451 // by an unhandled VKEY_MENU key press event. See also HandleKeyboardEvent(). 452 // by an unhandled VKEY_MENU key press event. See also HandleKeyboardEvent().
452 if (key.key_code() != ui::VKEY_MENU || key.type() != ui::ET_KEY_RELEASED) 453 if (key.key_code() != ui::VKEY_MENU || key.type() != ui::ET_KEY_RELEASED)
453 should_handle_menu_key_release_ = false; 454 should_handle_menu_key_release_ = false;
454 #endif 455 #endif
455 } 456 }
456 457
457 ui::AcceleratorTarget* FocusManager::GetCurrentTargetForAccelerator( 458 ui::AcceleratorTarget* FocusManager::GetCurrentTargetForAccelerator(
458 const ui::Accelerator& accelerator) const { 459 const ui::Accelerator& accelerator) const {
459 ui::AcceleratorTarget* target = 460 ui::AcceleratorTarget* target =
460 accelerator_manager_->GetCurrentTarget(accelerator); 461 accelerator_manager_->GetCurrentTarget(accelerator);
461 if (!target && delegate_.get()) 462 if (!target && delegate_.get())
462 target = delegate_->GetCurrentTargetForAccelerator(accelerator); 463 target = delegate_->GetCurrentTargetForAccelerator(accelerator);
463 return target; 464 return target;
464 } 465 }
465 466
466 bool FocusManager::HasPriorityHandler( 467 bool FocusManager::HasPriorityHandler(
467 const ui::Accelerator& accelerator) const { 468 const ui::Accelerator& accelerator) const {
468 return accelerator_manager_->HasPriorityHandler(accelerator); 469 return accelerator_manager_->HasPriorityHandler(accelerator);
469 } 470 }
470 471
471 // static 472 // static
472 bool FocusManager::IsTabTraversalKeyEvent(const KeyEvent& key_event) { 473 bool FocusManager::IsTabTraversalKeyEvent(const ui::KeyEvent& key_event) {
473 return key_event.key_code() == ui::VKEY_TAB && !key_event.IsControlDown(); 474 return key_event.key_code() == ui::VKEY_TAB && !key_event.IsControlDown();
474 } 475 }
475 476
476 void FocusManager::ViewRemoved(View* removed) { 477 void FocusManager::ViewRemoved(View* removed) {
477 // If the view being removed contains (or is) the focused view, 478 // If the view being removed contains (or is) the focused view,
478 // clear the focus. However, it's not safe to call ClearFocus() 479 // clear the focus. However, it's not safe to call ClearFocus()
479 // (and in turn ClearNativeFocus()) here because ViewRemoved() can 480 // (and in turn ClearNativeFocus()) here because ViewRemoved() can
480 // be called while the top level widget is being destroyed. 481 // be called while the top level widget is being destroyed.
481 if (focused_view_ && removed->Contains(focused_view_)) 482 if (focused_view_ && removed->Contains(focused_view_))
482 SetFocusedView(NULL); 483 SetFocusedView(NULL);
483 } 484 }
484 485
485 void FocusManager::AddFocusChangeListener(FocusChangeListener* listener) { 486 void FocusManager::AddFocusChangeListener(FocusChangeListener* listener) {
486 focus_change_listeners_.AddObserver(listener); 487 focus_change_listeners_.AddObserver(listener);
487 } 488 }
488 489
489 void FocusManager::RemoveFocusChangeListener(FocusChangeListener* listener) { 490 void FocusManager::RemoveFocusChangeListener(FocusChangeListener* listener) {
490 focus_change_listeners_.RemoveObserver(listener); 491 focus_change_listeners_.RemoveObserver(listener);
491 } 492 }
492 493
493 } // namespace views 494 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/focus/focus_manager.h ('k') | ui/views/focus/focus_manager_unittest_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698