| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/mus/accelerators/accelerator_controller_registrar.h" | 5 #include "ash/mus/accelerators/accelerator_controller_registrar.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "ash/common/accelerators/accelerator_controller.h" | 9 #include "ash/common/accelerators/accelerator_controller.h" |
| 10 #include "ash/common/accelerators/accelerator_router.h" | 10 #include "ash/common/accelerators/accelerator_router.h" |
| 11 #include "ash/common/wm/window_cycle_controller.h" | 11 #include "ash/common/wm/window_cycle_controller.h" |
| 12 #include "ash/common/wm_shell.h" | 12 #include "ash/common/wm_window.h" |
| 13 #include "ash/mus/accelerators/accelerator_ids.h" | 13 #include "ash/mus/accelerators/accelerator_ids.h" |
| 14 #include "ash/mus/window_manager.h" | 14 #include "ash/mus/window_manager.h" |
| 15 #include "ash/public/interfaces/event_properties.mojom.h" | 15 #include "ash/public/interfaces/event_properties.mojom.h" |
| 16 #include "ash/shell.h" | 16 #include "ash/shell.h" |
| 17 #include "ash/wm/window_util.h" |
| 17 #include "base/logging.h" | 18 #include "base/logging.h" |
| 18 #include "services/ui/common/accelerator_util.h" | 19 #include "services/ui/common/accelerator_util.h" |
| 19 #include "services/ui/public/cpp/property_type_converters.h" | 20 #include "services/ui/public/cpp/property_type_converters.h" |
| 20 #include "ui/base/accelerators/accelerator.h" | 21 #include "ui/base/accelerators/accelerator.h" |
| 21 #include "ui/base/accelerators/accelerator_history.h" | 22 #include "ui/base/accelerators/accelerator_history.h" |
| 22 | 23 |
| 23 namespace ash { | 24 namespace ash { |
| 24 namespace mus { | 25 namespace mus { |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // is called for *all* key events, where as this is only called for | 85 // is called for *all* key events, where as this is only called for |
| 85 // registered accelerators. This means the previous accelerator isn't the | 86 // registered accelerators. This means the previous accelerator isn't the |
| 86 // same as it was in ash. We need to figure out exactly what is needed of | 87 // same as it was in ash. We need to figure out exactly what is needed of |
| 87 // previous accelerator so that we can either register for the right set of | 88 // previous accelerator so that we can either register for the right set of |
| 88 // accelerators, or make WS send the previous accelerator. | 89 // accelerators, or make WS send the previous accelerator. |
| 89 // http://crbug.com/630683. | 90 // http://crbug.com/630683. |
| 90 accelerator_controller->accelerator_history()->StoreCurrentAccelerator( | 91 accelerator_controller->accelerator_history()->StoreCurrentAccelerator( |
| 91 accelerator); | 92 accelerator); |
| 92 if (HandleWindowCycleAccelerator(accelerator)) | 93 if (HandleWindowCycleAccelerator(accelerator)) |
| 93 return ui::mojom::EventResult::HANDLED; | 94 return ui::mojom::EventResult::HANDLED; |
| 94 WmWindow* target_window = WmShell::Get()->GetFocusedWindow(); | 95 WmWindow* target_window = WmWindow::Get(wm::GetFocusedWindow()); |
| 95 if (!target_window) | 96 if (!target_window) |
| 96 target_window = Shell::GetWmRootWindowForNewWindows(); | 97 target_window = Shell::GetWmRootWindowForNewWindows(); |
| 97 DCHECK(target_window); | 98 DCHECK(target_window); |
| 98 if (router_->ProcessAccelerator(target_window, *(event.AsKeyEvent()), | 99 if (router_->ProcessAccelerator(target_window, *(event.AsKeyEvent()), |
| 99 accelerator)) { | 100 accelerator)) { |
| 100 return ui::mojom::EventResult::HANDLED; | 101 return ui::mojom::EventResult::HANDLED; |
| 101 } | 102 } |
| 102 if (accelerator_controller->IsActionForAcceleratorEnabled(accelerator)) { | 103 if (accelerator_controller->IsActionForAcceleratorEnabled(accelerator)) { |
| 103 // We do have an accelerator for the key. Set a property so that the real | 104 // We do have an accelerator for the key. Set a property so that the real |
| 104 // target knows we have an accelerator. | 105 // target knows we have an accelerator. |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 if (accelerator == window_cycle_cancel_accelerator_) { | 217 if (accelerator == window_cycle_cancel_accelerator_) { |
| 217 window_cycle_controller->CancelCycling(); | 218 window_cycle_controller->CancelCycling(); |
| 218 return true; | 219 return true; |
| 219 } | 220 } |
| 220 | 221 |
| 221 return false; | 222 return false; |
| 222 } | 223 } |
| 223 | 224 |
| 224 } // namespace mus | 225 } // namespace mus |
| 225 } // namespace ash | 226 } // namespace ash |
| OLD | NEW |