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 |
11 #undef RootWindow | 11 #undef RootWindow |
12 #endif | 12 #endif |
13 | 13 |
14 #include "ash/accelerators/accelerator_controller.h" | 14 #include "ash/accelerators/accelerator_controller.h" |
| 15 #include "ash/ime/event.h" |
15 #include "ash/shell.h" | 16 #include "ash/shell.h" |
16 #include "ui/aura/env.h" | 17 #include "ui/aura/env.h" |
17 #include "ui/aura/event.h" | 18 #include "ui/aura/event.h" |
18 #include "ui/aura/root_window.h" | 19 #include "ui/aura/root_window.h" |
19 #include "ui/base/accelerators/accelerator.h" | 20 #include "ui/base/accelerators/accelerator.h" |
20 #include "ui/base/events.h" | 21 #include "ui/base/events.h" |
21 | 22 |
22 namespace ash { | 23 namespace ash { |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
26 const int kModifierMask = (ui::EF_SHIFT_DOWN | | 27 const int kModifierMask = (ui::EF_SHIFT_DOWN | |
27 ui::EF_CONTROL_DOWN | | 28 ui::EF_CONTROL_DOWN | |
28 ui::EF_ALT_DOWN); | 29 ui::EF_ALT_DOWN); |
29 } // namespace | 30 } // namespace |
30 | 31 |
31 base::MessagePumpDispatcher::DispatchStatus AcceleratorDispatcher::Dispatch( | 32 base::MessagePumpDispatcher::DispatchStatus AcceleratorDispatcher::Dispatch( |
32 XEvent* xev) { | 33 XEvent* xev) { |
33 if (!associated_window_) | 34 if (!associated_window_) |
34 return EVENT_QUIT; | 35 return EVENT_QUIT; |
35 if (!ui::IsNoopEvent(xev) && !associated_window_->CanReceiveEvents()) | 36 if (!ui::IsNoopEvent(xev) && !associated_window_->CanReceiveEvents()) |
36 return aura::Env::GetInstance()->GetDispatcher()->Dispatch(xev); | 37 return aura::Env::GetInstance()->GetDispatcher()->Dispatch(xev); |
37 | 38 |
38 if (xev->type == KeyPress) { | 39 if (xev->type == KeyPress || xev->type == KeyRelease) { |
39 ash::AcceleratorController* accelerator_controller = | 40 ash::AcceleratorController* accelerator_controller = |
40 ash::Shell::GetInstance()->accelerator_controller(); | 41 ash::Shell::GetInstance()->accelerator_controller(); |
41 ui::Accelerator accelerator(ui::KeyboardCodeFromNative(xev), | 42 if (accelerator_controller) { |
42 ui::EventFlagsFromNative(xev) & kModifierMask); | 43 ui::Accelerator accelerator(ui::KeyboardCodeFromNative(xev), |
43 if (accelerator_controller && accelerator_controller->Process(accelerator)) | 44 ui::EventFlagsFromNative(xev) & kModifierMask); |
44 return EVENT_PROCESSED; | 45 if (accelerator_controller->Process(accelerator)) |
| 46 return EVENT_PROCESSED; |
| 47 |
| 48 accelerator.set_type(TranslatedKeyEvent(xev, false).type()); |
| 49 if (accelerator_controller->Process(accelerator)) |
| 50 return EVENT_PROCESSED; |
| 51 } |
45 } | 52 } |
46 return nested_dispatcher_->Dispatch(xev); | 53 return nested_dispatcher_->Dispatch(xev); |
47 } | 54 } |
48 | 55 |
49 } // namespace ash | 56 } // namespace ash |
OLD | NEW |