OLD | NEW |
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/accelerators/accelerator_dispatcher.h" | 5 #include "ash/accelerators/accelerator_dispatcher.h" |
6 | 6 |
7 #if defined(USE_X11) | 7 #if defined(USE_X11) |
8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
9 | 9 |
10 // Xlib defines RootWindow | 10 // Xlib defines RootWindow |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 return false; | 63 return false; |
64 } | 64 } |
65 | 65 |
66 } // namespace | 66 } // namespace |
67 | 67 |
68 AcceleratorDispatcher::AcceleratorDispatcher( | 68 AcceleratorDispatcher::AcceleratorDispatcher( |
69 base::MessagePumpDispatcher* nested_dispatcher, | 69 base::MessagePumpDispatcher* nested_dispatcher, |
70 aura::Window* associated_window) | 70 aura::Window* associated_window) |
71 : nested_dispatcher_(nested_dispatcher), | 71 : nested_dispatcher_(nested_dispatcher), |
72 associated_window_(associated_window) { | 72 associated_window_(associated_window) { |
| 73 DCHECK(nested_dispatcher_); |
73 associated_window_->AddObserver(this); | 74 associated_window_->AddObserver(this); |
74 } | 75 } |
75 | 76 |
76 AcceleratorDispatcher::~AcceleratorDispatcher() { | 77 AcceleratorDispatcher::~AcceleratorDispatcher() { |
77 if (associated_window_) | 78 if (associated_window_) |
78 associated_window_->RemoveObserver(this); | 79 associated_window_->RemoveObserver(this); |
79 } | 80 } |
80 | 81 |
81 void AcceleratorDispatcher::OnWindowDestroying(aura::Window* window) { | 82 void AcceleratorDispatcher::OnWindowDestroying(aura::Window* window) { |
82 if (associated_window_ == window) | 83 if (associated_window_ == window) |
(...skipping 30 matching lines...) Expand all Loading... |
113 if (key_event.type() == ui::ET_KEY_RELEASED) | 114 if (key_event.type() == ui::ET_KEY_RELEASED) |
114 accelerator.set_type(ui::ET_KEY_RELEASED); | 115 accelerator.set_type(ui::ET_KEY_RELEASED); |
115 // Fill out context object so AcceleratorController will know what | 116 // Fill out context object so AcceleratorController will know what |
116 // was the previous accelerator or if the current accelerator is repeated. | 117 // was the previous accelerator or if the current accelerator is repeated. |
117 Shell::GetInstance()->accelerator_controller()->context()-> | 118 Shell::GetInstance()->accelerator_controller()->context()-> |
118 UpdateContext(accelerator); | 119 UpdateContext(accelerator); |
119 if (accelerator_controller->Process(accelerator)) | 120 if (accelerator_controller->Process(accelerator)) |
120 return POST_DISPATCH_NONE; | 121 return POST_DISPATCH_NONE; |
121 } | 122 } |
122 | 123 |
123 return nested_dispatcher_ | 124 return nested_dispatcher_->Dispatch(key_event.native_event()); |
124 ? nested_dispatcher_->Dispatch(key_event.native_event()) | |
125 : POST_DISPATCH_PERFORM_DEFAULT; | |
126 } | 125 } |
127 | 126 |
128 return nested_dispatcher_ ? nested_dispatcher_->Dispatch(event) | 127 return nested_dispatcher_->Dispatch(event); |
129 : POST_DISPATCH_PERFORM_DEFAULT; | |
130 } | 128 } |
131 | 129 |
132 } // namespace ash | 130 } // namespace ash |
OLD | NEW |