| 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 #ifndef SERVICES_UI_WS_WINDOW_MANAGER_STATE_H_ | 5 #ifndef SERVICES_UI_WS_WINDOW_MANAGER_STATE_H_ |
| 6 #define SERVICES_UI_WS_WINDOW_MANAGER_STATE_H_ | 6 #define SERVICES_UI_WS_WINDOW_MANAGER_STATE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <vector> |
| 11 | 12 |
| 12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 13 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
| 14 #include "services/ui/public/interfaces/display.mojom.h" | 15 #include "services/ui/public/interfaces/display.mojom.h" |
| 15 #include "services/ui/ws/event_dispatcher.h" | 16 #include "services/ui/ws/event_dispatcher.h" |
| 16 #include "services/ui/ws/event_dispatcher_delegate.h" | 17 #include "services/ui/ws/event_dispatcher_delegate.h" |
| 17 #include "services/ui/ws/user_id.h" | 18 #include "services/ui/ws/user_id.h" |
| 18 #include "services/ui/ws/window_server.h" | 19 #include "services/ui/ws/window_server.h" |
| 19 | 20 |
| 20 namespace ui { | 21 namespace ui { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 void OnEventAck(mojom::WindowTree* tree, mojom::EventResult result); | 81 void OnEventAck(mojom::WindowTree* tree, mojom::EventResult result); |
| 81 | 82 |
| 82 // Called when the WindowManager acks an accelerator. | 83 // Called when the WindowManager acks an accelerator. |
| 83 void OnAcceleratorAck(mojom::EventResult result); | 84 void OnAcceleratorAck(mojom::EventResult result); |
| 84 | 85 |
| 85 private: | 86 private: |
| 86 class ProcessedEventTarget; | 87 class ProcessedEventTarget; |
| 87 friend class Display; | 88 friend class Display; |
| 88 friend class test::WindowManagerStateTestApi; | 89 friend class test::WindowManagerStateTestApi; |
| 89 | 90 |
| 91 enum class DebugAcceleratorType { |
| 92 PRINT_WINDOWS, |
| 93 }; |
| 94 |
| 95 struct DebugAccelerator { |
| 96 DebugAcceleratorType type; |
| 97 ui::KeyboardCode key_code; |
| 98 int event_flags; |
| 99 }; |
| 100 |
| 90 enum class EventDispatchPhase { | 101 enum class EventDispatchPhase { |
| 91 // Not actively dispatching. | 102 // Not actively dispatching. |
| 92 NONE, | 103 NONE, |
| 93 | 104 |
| 94 // A PRE_TARGET accelerator has been encountered and we're awaiting the ack. | 105 // A PRE_TARGET accelerator has been encountered and we're awaiting the ack. |
| 95 PRE_TARGET_ACCELERATOR, | 106 PRE_TARGET_ACCELERATOR, |
| 96 | 107 |
| 97 // Dispatching to the target, awaiting the ack. | 108 // Dispatching to the target, awaiting the ack. |
| 98 TARGET, | 109 TARGET, |
| 99 }; | 110 }; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 124 void SetAllRootWindowsVisible(bool value); | 135 void SetAllRootWindowsVisible(bool value); |
| 125 | 136 |
| 126 // Returns the ServerWindow that is the root of the WindowManager for | 137 // Returns the ServerWindow that is the root of the WindowManager for |
| 127 // |window|. |window| corresponds to the root of a Display. | 138 // |window|. |window| corresponds to the root of a Display. |
| 128 ServerWindow* GetWindowManagerRoot(ServerWindow* window); | 139 ServerWindow* GetWindowManagerRoot(ServerWindow* window); |
| 129 | 140 |
| 130 // Called if the client doesn't ack an event in the appropriate amount of | 141 // Called if the client doesn't ack an event in the appropriate amount of |
| 131 // time. | 142 // time. |
| 132 void OnEventAckTimeout(ClientSpecificId client_id); | 143 void OnEventAckTimeout(ClientSpecificId client_id); |
| 133 | 144 |
| 145 // Implemenation of processing an event with a match phase of all. This |
| 146 // handles debug accelerators and forwards to EventDispatcher. |
| 147 void ProcessEventImpl(const ui::Event& event); |
| 148 |
| 134 // Schedules an event to be processed later. | 149 // Schedules an event to be processed later. |
| 135 void QueueEvent(const ui::Event& event, | 150 void QueueEvent(const ui::Event& event, |
| 136 std::unique_ptr<ProcessedEventTarget> processed_event_target); | 151 std::unique_ptr<ProcessedEventTarget> processed_event_target); |
| 137 | 152 |
| 138 // Processes the next valid event in |event_queue_|. If the event has already | 153 // Processes the next valid event in |event_queue_|. If the event has already |
| 139 // been processed it is dispatched, otherwise the event is passed to the | 154 // been processed it is dispatched, otherwise the event is passed to the |
| 140 // EventDispatcher for processing. | 155 // EventDispatcher for processing. |
| 141 void ProcessNextEventFromQueue(); | 156 void ProcessNextEventFromQueue(); |
| 142 | 157 |
| 143 // Dispatches the event to the appropriate client and starts the ack timer. | 158 // Dispatches the event to the appropriate client and starts the ack timer. |
| 144 void DispatchInputEventToWindowImpl(ServerWindow* target, | 159 void DispatchInputEventToWindowImpl(ServerWindow* target, |
| 145 ClientSpecificId client_id, | 160 ClientSpecificId client_id, |
| 146 const ui::Event& event, | 161 const ui::Event& event, |
| 147 base::WeakPtr<Accelerator> accelerator); | 162 base::WeakPtr<Accelerator> accelerator); |
| 148 | 163 |
| 149 // Registers accelerators used internally for debugging. | 164 // Registers accelerators used internally for debugging. |
| 150 void AddDebugAccelerators(); | 165 void AddDebugAccelerators(); |
| 151 | 166 |
| 152 // Returns true if the accelerator was handled. | 167 // Finds the debug accelerator for |event| and if one is found calls |
| 153 bool HandleDebugAccelerator(uint32_t accelerator_id); | 168 // HandleDebugAccelerator(). |
| 169 void ProcessDebugAccelerator(const ui::Event& event); |
| 170 |
| 171 // Runs the specified debug accelerator. |
| 172 void HandleDebugAccelerator(DebugAcceleratorType type); |
| 154 | 173 |
| 155 // Called when waiting for an event or accelerator to be processed by |tree|. | 174 // Called when waiting for an event or accelerator to be processed by |tree|. |
| 156 void ScheduleInputEventTimeout(WindowTree* tree); | 175 void ScheduleInputEventTimeout(WindowTree* tree); |
| 157 | 176 |
| 158 // EventDispatcherDelegate: | 177 // EventDispatcherDelegate: |
| 159 void OnAccelerator(uint32_t accelerator_id, | 178 void OnAccelerator(uint32_t accelerator_id, |
| 160 const ui::Event& event, | 179 const ui::Event& event, |
| 161 AcceleratorPhase phase) override; | 180 AcceleratorPhase phase) override; |
| 162 void SetFocusedWindowFromEventDispatcher(ServerWindow* window) override; | 181 void SetFocusedWindowFromEventDispatcher(ServerWindow* window) override; |
| 163 ServerWindow* GetFocusedWindowForEventDispatcher() override; | 182 ServerWindow* GetFocusedWindowForEventDispatcher() override; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 184 | 203 |
| 185 EventDispatchPhase event_dispatch_phase_ = EventDispatchPhase::NONE; | 204 EventDispatchPhase event_dispatch_phase_ = EventDispatchPhase::NONE; |
| 186 // The tree we're waiting to process the current accelerator or event. | 205 // The tree we're waiting to process the current accelerator or event. |
| 187 mojom::WindowTree* tree_awaiting_input_ack_ = nullptr; | 206 mojom::WindowTree* tree_awaiting_input_ack_ = nullptr; |
| 188 // The event we're awaiting an accelerator or input ack from. | 207 // The event we're awaiting an accelerator or input ack from. |
| 189 std::unique_ptr<ui::Event> event_awaiting_input_ack_; | 208 std::unique_ptr<ui::Event> event_awaiting_input_ack_; |
| 190 base::WeakPtr<Accelerator> post_target_accelerator_; | 209 base::WeakPtr<Accelerator> post_target_accelerator_; |
| 191 std::queue<std::unique_ptr<QueuedEvent>> event_queue_; | 210 std::queue<std::unique_ptr<QueuedEvent>> event_queue_; |
| 192 base::OneShotTimer event_ack_timer_; | 211 base::OneShotTimer event_ack_timer_; |
| 193 | 212 |
| 213 std::vector<DebugAccelerator> debug_accelerators_; |
| 214 |
| 194 EventDispatcher event_dispatcher_; | 215 EventDispatcher event_dispatcher_; |
| 195 | 216 |
| 196 // PlatformDisplay that currently has capture. | 217 // PlatformDisplay that currently has capture. |
| 197 PlatformDisplay* platform_display_with_capture_ = nullptr; | 218 PlatformDisplay* platform_display_with_capture_ = nullptr; |
| 198 | 219 |
| 199 base::WeakPtrFactory<WindowManagerState> weak_factory_; | 220 base::WeakPtrFactory<WindowManagerState> weak_factory_; |
| 200 | 221 |
| 201 DISALLOW_COPY_AND_ASSIGN(WindowManagerState); | 222 DISALLOW_COPY_AND_ASSIGN(WindowManagerState); |
| 202 }; | 223 }; |
| 203 | 224 |
| 204 } // namespace ws | 225 } // namespace ws |
| 205 } // namespace ui | 226 } // namespace ui |
| 206 | 227 |
| 207 #endif // SERVICES_UI_WS_WINDOW_MANAGER_STATE_H_ | 228 #endif // SERVICES_UI_WS_WINDOW_MANAGER_STATE_H_ |
| OLD | NEW |