| 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" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // is called for *all* key events, where as this is only called for | 78 // is called for *all* key events, where as this is only called for |
| 79 // registered accelerators. This means the previous accelerator isn't the | 79 // registered accelerators. This means the previous accelerator isn't the |
| 80 // same as it was in ash. We need to figure out exactly what is needed of | 80 // same as it was in ash. We need to figure out exactly what is needed of |
| 81 // previous accelerator so that we can either register for the right set of | 81 // previous accelerator so that we can either register for the right set of |
| 82 // accelerators, or make WS send the previous accelerator. | 82 // accelerators, or make WS send the previous accelerator. |
| 83 // http://crbug.com/630683. | 83 // http://crbug.com/630683. |
| 84 accelerator_controller->accelerator_history()->StoreCurrentAccelerator( | 84 accelerator_controller->accelerator_history()->StoreCurrentAccelerator( |
| 85 accelerator); | 85 accelerator); |
| 86 WmWindow* target_window = WmShell::Get()->GetFocusedWindow(); | 86 WmWindow* target_window = WmShell::Get()->GetFocusedWindow(); |
| 87 if (!target_window) | 87 if (!target_window) |
| 88 target_window = WmShell::Get()->GetRootWindowForNewWindows(); | 88 target_window = WmShell::Get()->root_window_for_new_windows(); |
| 89 DCHECK(target_window); | 89 DCHECK(target_window); |
| 90 return router_->ProcessAccelerator(target_window, *(event.AsKeyEvent()), | 90 return router_->ProcessAccelerator(target_window, *(event.AsKeyEvent()), |
| 91 accelerator) | 91 accelerator) |
| 92 ? ui::mojom::EventResult::HANDLED | 92 ? ui::mojom::EventResult::HANDLED |
| 93 : ui::mojom::EventResult::UNHANDLED; | 93 : ui::mojom::EventResult::UNHANDLED; |
| 94 } | 94 } |
| 95 DCHECK_EQ(GetAcceleratorLocalId(id), ids.post_id); | 95 DCHECK_EQ(GetAcceleratorLocalId(id), ids.post_id); |
| 96 // NOTE: for post return value doesn't really matter. | 96 // NOTE: for post return value doesn't really matter. |
| 97 return WmShell::Get()->accelerator_controller()->Process(accelerator) | 97 return WmShell::Get()->accelerator_controller()->Process(accelerator) |
| 98 ? ui::mojom::EventResult::HANDLED | 98 ? ui::mojom::EventResult::HANDLED |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 // Common case is we never wrap once, so this is typically cheap. Additionally | 160 // Common case is we never wrap once, so this is typically cheap. Additionally |
| 161 // we expect there not to be too many accelerators. | 161 // we expect there not to be too many accelerators. |
| 162 while (ids_.count(next_id_) > 0) | 162 while (ids_.count(next_id_) > 0) |
| 163 ++next_id_; | 163 ++next_id_; |
| 164 ids_.insert(next_id_); | 164 ids_.insert(next_id_); |
| 165 return next_id_++; | 165 return next_id_++; |
| 166 } | 166 } |
| 167 | 167 |
| 168 } // namespace mus | 168 } // namespace mus |
| 169 } // namespace ash | 169 } // namespace ash |
| OLD | NEW |