| 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_shell.h" | 11 #include "ash/common/wm_shell.h" |
| 12 #include "ash/mus/accelerators/accelerator_ids.h" | 12 #include "ash/mus/accelerators/accelerator_ids.h" |
| 13 #include "ash/mus/window_manager.h" | 13 #include "ash/mus/window_manager.h" |
| 14 #include "ash/shell.h" |
| 14 #include "base/logging.h" | 15 #include "base/logging.h" |
| 15 #include "services/ui/common/accelerator_util.h" | 16 #include "services/ui/common/accelerator_util.h" |
| 16 #include "ui/base/accelerators/accelerator_history.h" | 17 #include "ui/base/accelerators/accelerator_history.h" |
| 17 | 18 |
| 18 namespace ash { | 19 namespace ash { |
| 19 namespace mus { | 20 namespace mus { |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 // Callback from registering the accelerators. | 23 // Callback from registering the accelerators. |
| 23 void OnAcceleratorsAdded(const std::vector<ui::Accelerator>& accelerators, | 24 void OnAcceleratorsAdded(const std::vector<ui::Accelerator>& accelerators, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 // is called for *all* key events, where as this is only called for | 77 // is called for *all* key events, where as this is only called for |
| 77 // registered accelerators. This means the previous accelerator isn't the | 78 // registered accelerators. This means the previous accelerator isn't the |
| 78 // same as it was in ash. We need to figure out exactly what is needed of | 79 // same as it was in ash. We need to figure out exactly what is needed of |
| 79 // previous accelerator so that we can either register for the right set of | 80 // previous accelerator so that we can either register for the right set of |
| 80 // accelerators, or make WS send the previous accelerator. | 81 // accelerators, or make WS send the previous accelerator. |
| 81 // http://crbug.com/630683. | 82 // http://crbug.com/630683. |
| 82 accelerator_controller->accelerator_history()->StoreCurrentAccelerator( | 83 accelerator_controller->accelerator_history()->StoreCurrentAccelerator( |
| 83 accelerator); | 84 accelerator); |
| 84 WmWindow* target_window = WmShell::Get()->GetFocusedWindow(); | 85 WmWindow* target_window = WmShell::Get()->GetFocusedWindow(); |
| 85 if (!target_window) | 86 if (!target_window) |
| 86 target_window = WmShell::Get()->GetRootWindowForNewWindows(); | 87 target_window = Shell::GetWmRootWindowForNewWindows(); |
| 87 DCHECK(target_window); | 88 DCHECK(target_window); |
| 88 return router_->ProcessAccelerator(target_window, *(event.AsKeyEvent()), | 89 return router_->ProcessAccelerator(target_window, *(event.AsKeyEvent()), |
| 89 accelerator) | 90 accelerator) |
| 90 ? ui::mojom::EventResult::HANDLED | 91 ? ui::mojom::EventResult::HANDLED |
| 91 : ui::mojom::EventResult::UNHANDLED; | 92 : ui::mojom::EventResult::UNHANDLED; |
| 92 } | 93 } |
| 93 DCHECK_EQ(GetAcceleratorLocalId(id), ids.post_id); | 94 DCHECK_EQ(GetAcceleratorLocalId(id), ids.post_id); |
| 94 // NOTE: for post return value doesn't really matter. | 95 // NOTE: for post return value doesn't really matter. |
| 95 return WmShell::Get()->accelerator_controller()->Process(accelerator) | 96 return WmShell::Get()->accelerator_controller()->Process(accelerator) |
| 96 ? ui::mojom::EventResult::HANDLED | 97 ? ui::mojom::EventResult::HANDLED |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 // Common case is we never wrap once, so this is typically cheap. Additionally | 175 // Common case is we never wrap once, so this is typically cheap. Additionally |
| 175 // we expect there not to be too many accelerators. | 176 // we expect there not to be too many accelerators. |
| 176 while (ids_.count(next_id_) > 0) | 177 while (ids_.count(next_id_) > 0) |
| 177 ++next_id_; | 178 ++next_id_; |
| 178 ids_.insert(next_id_); | 179 ids_.insert(next_id_); |
| 179 return next_id_++; | 180 return next_id_++; |
| 180 } | 181 } |
| 181 | 182 |
| 182 } // namespace mus | 183 } // namespace mus |
| 183 } // namespace ash | 184 } // namespace ash |
| OLD | NEW |