| 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 |
| 11 #ifdef RootWindow | 11 #ifdef RootWindow |
| 12 #undef RootWindow | 12 #undef RootWindow |
| 13 #endif | 13 #endif |
| 14 #endif // defined(USE_X11) | 14 #endif // defined(USE_X11) |
| 15 | 15 |
| 16 #include "ash/accelerators/accelerator_controller.h" | 16 #include "ash/accelerators/accelerator_controller.h" |
| 17 #include "ash/shell.h" | 17 #include "ash/shell.h" |
| 18 #include "ash/wm/event_rewriter_event_filter.h" | |
| 19 #include "ui/aura/env.h" | 18 #include "ui/aura/env.h" |
| 20 #include "ui/aura/root_window.h" | 19 #include "ui/aura/root_window.h" |
| 21 #include "ui/base/accelerators/accelerator.h" | 20 #include "ui/base/accelerators/accelerator.h" |
| 22 #include "ui/events/event.h" | 21 #include "ui/events/event.h" |
| 23 #include "ui/events/event_constants.h" | 22 #include "ui/events/event_constants.h" |
| 24 #include "ui/events/event_utils.h" | 23 #include "ui/events/event_utils.h" |
| 25 #include "ui/views/controls/menu/menu_controller.h" | 24 #include "ui/views/controls/menu/menu_controller.h" |
| 26 | 25 |
| 27 namespace ash { | 26 namespace ash { |
| 28 namespace { | 27 namespace { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 } | 85 } |
| 87 | 86 |
| 88 uint32_t AcceleratorDispatcher::Dispatch(const base::NativeEvent& event) { | 87 uint32_t AcceleratorDispatcher::Dispatch(const base::NativeEvent& event) { |
| 89 if (!associated_window_) | 88 if (!associated_window_) |
| 90 return POST_DISPATCH_QUIT_LOOP; | 89 return POST_DISPATCH_QUIT_LOOP; |
| 91 | 90 |
| 92 if (!associated_window_->CanReceiveEvents()) | 91 if (!associated_window_->CanReceiveEvents()) |
| 93 return POST_DISPATCH_PERFORM_DEFAULT; | 92 return POST_DISPATCH_PERFORM_DEFAULT; |
| 94 | 93 |
| 95 if (IsKeyEvent(event)) { | 94 if (IsKeyEvent(event)) { |
| 96 // Modifiers can be changed by the user preference, so we need to rewrite | |
| 97 // the event explicitly. | |
| 98 ui::KeyEvent key_event(event, false); | 95 ui::KeyEvent key_event(event, false); |
| 99 ui::EventHandler* event_rewriter = | |
| 100 ash::Shell::GetInstance()->event_rewriter_filter(); | |
| 101 DCHECK(event_rewriter); | |
| 102 event_rewriter->OnKeyEvent(&key_event); | |
| 103 if (key_event.stopped_propagation()) | |
| 104 return POST_DISPATCH_NONE; | |
| 105 | |
| 106 if (IsPossibleAcceleratorNotForMenu(key_event)) { | 96 if (IsPossibleAcceleratorNotForMenu(key_event)) { |
| 107 if (views::MenuController* menu_controller = | 97 if (views::MenuController* menu_controller = |
| 108 views::MenuController::GetActiveInstance()) { | 98 views::MenuController::GetActiveInstance()) { |
| 109 menu_controller->CancelAll(); | 99 menu_controller->CancelAll(); |
| 110 #if defined(USE_X11) | 100 #if defined(USE_X11) |
| 111 XPutBackEvent(event->xany.display, event); | 101 XPutBackEvent(event->xany.display, event); |
| 112 #else | 102 #else |
| 113 NOTIMPLEMENTED() << " Repost NativeEvent here."; | 103 NOTIMPLEMENTED() << " Repost NativeEvent here."; |
| 114 #endif | 104 #endif |
| 115 return POST_DISPATCH_QUIT_LOOP; | 105 return POST_DISPATCH_QUIT_LOOP; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 131 return POST_DISPATCH_NONE; | 121 return POST_DISPATCH_NONE; |
| 132 } | 122 } |
| 133 | 123 |
| 134 return nested_dispatcher_->Dispatch(key_event.native_event()); | 124 return nested_dispatcher_->Dispatch(key_event.native_event()); |
| 135 } | 125 } |
| 136 | 126 |
| 137 return nested_dispatcher_->Dispatch(event); | 127 return nested_dispatcher_->Dispatch(event); |
| 138 } | 128 } |
| 139 | 129 |
| 140 } // namespace ash | 130 } // namespace ash |
| OLD | NEW |