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