Avi Drissman | 8ba1bad | 2022-09-13 19:22:36 | [diff] [blame] | 1 | // Copyright 2019 The Chromium Authors |
Mikolaj Walczak | 297ece6 | 2019-10-11 02:55:40 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef COMPONENTS_EXO_CLIENT_CONTROLLED_ACCELERATORS_H_ |
| 6 | #define COMPONENTS_EXO_CLIENT_CONTROLLED_ACCELERATORS_H_ |
| 7 | |
Arthur Sonzogni | ae0e8917 | 2023-04-22 11:15:35 | [diff] [blame] | 8 | #include "base/memory/raw_ptr.h" |
Mikolaj Walczak | 297ece6 | 2019-10-11 02:55:40 | [diff] [blame] | 9 | #include "components/exo/client_controlled_shell_surface.h" |
| 10 | #include "ui/aura/window.h" |
| 11 | #include "ui/base/accelerators/accelerator.h" |
| 12 | #include "ui/views/focus/focus_manager.h" |
| 13 | |
| 14 | namespace exo { |
| 15 | |
| 16 | enum class ClientControlledAcceleratorAction { |
| 17 | ZOOM_IN, |
| 18 | ZOOM_OUT, |
| 19 | ZOOM_RESET, |
| 20 | }; |
| 21 | |
| 22 | class ClientControlledShellSurface; |
| 23 | |
| 24 | class ClientControlledAcceleratorTarget : public ui::AcceleratorTarget { |
| 25 | public: |
| 26 | explicit ClientControlledAcceleratorTarget( |
| 27 | ClientControlledShellSurface* surface); |
Peter Boström | 09c0182 | 2021-09-20 22:43:27 | [diff] [blame] | 28 | |
| 29 | ClientControlledAcceleratorTarget(const ClientControlledAcceleratorTarget&) = |
| 30 | delete; |
| 31 | ClientControlledAcceleratorTarget& operator=( |
| 32 | const ClientControlledAcceleratorTarget&) = delete; |
| 33 | |
Mikolaj Walczak | 297ece6 | 2019-10-11 02:55:40 | [diff] [blame] | 34 | ~ClientControlledAcceleratorTarget() override; |
| 35 | |
| 36 | void RegisterAccelerator(const ui::Accelerator& accelerator, |
| 37 | ClientControlledAcceleratorAction action); |
| 38 | void RegisterAccelerator(ui::Accelerator&& accelerator, |
| 39 | ClientControlledAcceleratorAction action); |
| 40 | |
| 41 | // ui::AcceleratorTarget interface implementation. |
| 42 | bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
| 43 | bool CanHandleAccelerators() const override; |
| 44 | |
| 45 | private: |
Bartek Nowierski | 5ecc98a | 2023-12-22 09:26:02 | [diff] [blame] | 46 | raw_ptr<ClientControlledShellSurface> surface_; |
Mikolaj Walczak | 297ece6 | 2019-10-11 02:55:40 | [diff] [blame] | 47 | std::map<ui::Accelerator, ClientControlledAcceleratorAction> accelerators_; |
Mikolaj Walczak | 297ece6 | 2019-10-11 02:55:40 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | } // namespace exo |
| 51 | |
| 52 | #endif // COMPONENTS_EXO_CLIENT_CONTROLLED_ACCELERATORS_H_ |