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 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
8 | 8 |
9 // Xlib defines RootWindow | 9 // Xlib defines RootWindow |
10 #ifdef RootWindow | 10 #ifdef RootWindow |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 const int kModifierMask = (ui::EF_SHIFT_DOWN | | 24 const int kModifierMask = (ui::EF_SHIFT_DOWN | |
25 ui::EF_CONTROL_DOWN | | 25 ui::EF_CONTROL_DOWN | |
26 ui::EF_ALT_DOWN); | 26 ui::EF_ALT_DOWN); |
27 } // namespace | 27 } // namespace |
28 | 28 |
29 base::MessagePumpDispatcher::DispatchStatus AcceleratorDispatcher::Dispatch( | 29 base::MessagePumpDispatcher::DispatchStatus AcceleratorDispatcher::Dispatch( |
30 XEvent* xev) { | 30 XEvent* xev) { |
| 31 if (!associated_window_) |
| 32 return EVENT_QUIT; |
31 if (!associated_window_->CanReceiveEvents()) | 33 if (!associated_window_->CanReceiveEvents()) |
32 return aura::RootWindow::GetInstance()->GetDispatcher()->Dispatch(xev); | 34 return aura::RootWindow::GetInstance()->GetDispatcher()->Dispatch(xev); |
33 | 35 |
34 if (xev->type == KeyPress) { | 36 if (xev->type == KeyPress) { |
35 ash::AcceleratorController* accelerator_controller = | 37 ash::AcceleratorController* accelerator_controller = |
36 ash::Shell::GetInstance()->accelerator_controller(); | 38 ash::Shell::GetInstance()->accelerator_controller(); |
37 ui::Accelerator accelerator(ui::KeyboardCodeFromNative(xev), | 39 ui::Accelerator accelerator(ui::KeyboardCodeFromNative(xev), |
38 ui::EventFlagsFromNative(xev) & kModifierMask); | 40 ui::EventFlagsFromNative(xev) & kModifierMask); |
39 if (accelerator_controller && accelerator_controller->Process(accelerator)) | 41 if (accelerator_controller && accelerator_controller->Process(accelerator)) |
40 return EVENT_PROCESSED; | 42 return EVENT_PROCESSED; |
41 } | 43 } |
42 return nested_dispatcher_->Dispatch(xev); | 44 return nested_dispatcher_->Dispatch(xev); |
43 } | 45 } |
44 | 46 |
45 } // namespace ash | 47 } // namespace ash |
OLD | NEW |