Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: services/ui/ws/window_manager_state.h

Issue 2125883003: Adds ability for pre-target accelerators to not consume events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 void Deactivate(); 72 void Deactivate();
73 73
74 // Processes an event from PlatformDisplay. 74 // Processes an event from PlatformDisplay.
75 void ProcessEvent(const ui::Event& event); 75 void ProcessEvent(const ui::Event& event);
76 76
77 // Called when the ack from an event dispatched to WindowTree |tree| is 77 // Called when the ack from an event dispatched to WindowTree |tree| is
78 // received. 78 // received.
79 // TODO(sky): make this private and use a callback. 79 // TODO(sky): make this private and use a callback.
80 void OnEventAck(mojom::WindowTree* tree, mojom::EventResult result); 80 void OnEventAck(mojom::WindowTree* tree, mojom::EventResult result);
81 81
82 // Called when the WindowManager acks an accelerator.
83 void OnAcceleratorAck(mojom::EventResult result);
84
82 private: 85 private:
83 class ProcessedEventTarget; 86 class ProcessedEventTarget;
84 friend class Display; 87 friend class Display;
85 friend class test::WindowManagerStateTestApi; 88 friend class test::WindowManagerStateTestApi;
86 89
90 enum class EventDispatchPhase {
91 // Not actively dispatching.
92 NONE,
93
94 // A PRE_TARGET accelerator has been encountered and we're awaiting the ack.
95 PRE_TARGET_ACCELERATOR,
96
97 // Dispatching to the target, awaiting the ack.
98 TARGET,
99 };
100
87 // There are two types of events that may be queued, both occur only when 101 // There are two types of events that may be queued, both occur only when
88 // waiting for an ack from a client. 102 // waiting for an ack from a client.
89 // . We get an event from the PlatformDisplay. This results in |event| being 103 // . We get an event from the PlatformDisplay. This results in |event| being
90 // set, but |processed_target| is null. 104 // set, but |processed_target| is null.
91 // . We get an event from the EventDispatcher. In this case both |event| and 105 // . We get an event from the EventDispatcher. In this case both |event| and
92 // |processed_target| are valid. 106 // |processed_target| are valid.
93 // The second case happens if EventDispatcher generates more than one event 107 // The second case happens if EventDispatcher generates more than one event
94 // at a time. 108 // at a time.
95 struct QueuedEvent { 109 struct QueuedEvent {
96 QueuedEvent(); 110 QueuedEvent();
97 ~QueuedEvent(); 111 ~QueuedEvent();
98 112
99 std::unique_ptr<ui::Event> event; 113 std::unique_ptr<ui::Event> event;
100 std::unique_ptr<ProcessedEventTarget> processed_target; 114 std::unique_ptr<ProcessedEventTarget> processed_target;
101 }; 115 };
102 116
103 const WindowServer* window_server() const; 117 const WindowServer* window_server() const;
104 WindowServer* window_server(); 118 WindowServer* window_server();
105 119
106 DisplayManager* display_manager(); 120 DisplayManager* display_manager();
107 const DisplayManager* display_manager() const; 121 const DisplayManager* display_manager() const;
108 122
109 // Sets the visibility of all window manager roots windows to |value|. 123 // Sets the visibility of all window manager roots windows to |value|.
110 void SetAllRootWindowsVisible(bool value); 124 void SetAllRootWindowsVisible(bool value);
111 125
112 // Returns the ServerWindow that is the root of the WindowManager for 126 // Returns the ServerWindow that is the root of the WindowManager for
113 // |window|. |window| corresponds to the root of a Display. 127 // |window|. |window| corresponds to the root of a Display.
114 ServerWindow* GetWindowManagerRoot(ServerWindow* window); 128 ServerWindow* GetWindowManagerRoot(ServerWindow* window);
115 129
130 // Called if the client doesn't ack an event in the appropriate amount of
131 // time.
116 void OnEventAckTimeout(ClientSpecificId client_id); 132 void OnEventAckTimeout(ClientSpecificId client_id);
117 133
118 // Schedules an event to be processed later. 134 // Schedules an event to be processed later.
119 void QueueEvent(const ui::Event& event, 135 void QueueEvent(const ui::Event& event,
120 std::unique_ptr<ProcessedEventTarget> processed_event_target); 136 std::unique_ptr<ProcessedEventTarget> processed_event_target);
121 137
122 // Processes the next valid event in |event_queue_|. If the event has already 138 // Processes the next valid event in |event_queue_|. If the event has already
123 // been processed it is dispatched, otherwise the event is passed to the 139 // been processed it is dispatched, otherwise the event is passed to the
124 // EventDispatcher for processing. 140 // EventDispatcher for processing.
125 void ProcessNextEventFromQueue(); 141 void ProcessNextEventFromQueue();
126 142
127 // Dispatches the event to the appropriate client and starts the ack timer. 143 // Dispatches the event to the appropriate client and starts the ack timer.
128 void DispatchInputEventToWindowImpl(ServerWindow* target, 144 void DispatchInputEventToWindowImpl(ServerWindow* target,
129 ClientSpecificId client_id, 145 ClientSpecificId client_id,
130 const ui::Event& event, 146 const ui::Event& event,
131 base::WeakPtr<Accelerator> accelerator); 147 base::WeakPtr<Accelerator> accelerator);
132 148
133 // Registers accelerators used internally for debugging. 149 // Registers accelerators used internally for debugging.
134 void AddDebugAccelerators(); 150 void AddDebugAccelerators();
135 151
136 // Returns true if the accelerator was handled. 152 // Returns true if the accelerator was handled.
137 bool HandleDebugAccelerator(uint32_t accelerator_id); 153 bool HandleDebugAccelerator(uint32_t accelerator_id);
138 154
155 // Called when waiting for an event or accelerator to be processed by |tree|.
156 void ScheduleInputEventTimeout(WindowTree* tree);
157
139 // EventDispatcherDelegate: 158 // EventDispatcherDelegate:
140 void OnAccelerator(uint32_t accelerator_id, const ui::Event& event) override; 159 void OnAccelerator(uint32_t accelerator_id,
160 const ui::Event& event,
161 AcceleratorPhase phase) override;
141 void SetFocusedWindowFromEventDispatcher(ServerWindow* window) override; 162 void SetFocusedWindowFromEventDispatcher(ServerWindow* window) override;
142 ServerWindow* GetFocusedWindowForEventDispatcher() override; 163 ServerWindow* GetFocusedWindowForEventDispatcher() override;
143 void SetNativeCapture(ServerWindow* window) override; 164 void SetNativeCapture(ServerWindow* window) override;
144 void ReleaseNativeCapture() override; 165 void ReleaseNativeCapture() override;
145 void OnServerWindowCaptureLost(ServerWindow* window) override; 166 void OnServerWindowCaptureLost(ServerWindow* window) override;
146 void OnMouseCursorLocationChanged(const gfx::Point& point) override; 167 void OnMouseCursorLocationChanged(const gfx::Point& point) override;
147 void DispatchInputEventToWindow(ServerWindow* target, 168 void DispatchInputEventToWindow(ServerWindow* target,
148 ClientSpecificId client_id, 169 ClientSpecificId client_id,
149 const ui::Event& event, 170 const ui::Event& event,
150 Accelerator* accelerator) override; 171 Accelerator* accelerator) override;
151 ClientSpecificId GetEventTargetClientId(const ServerWindow* window, 172 ClientSpecificId GetEventTargetClientId(const ServerWindow* window,
152 bool in_nonclient_area) override; 173 bool in_nonclient_area) override;
153 ServerWindow* GetRootWindowContaining(const gfx::Point& location) override; 174 ServerWindow* GetRootWindowContaining(const gfx::Point& location) override;
154 void OnEventTargetNotFound(const ui::Event& event) override; 175 void OnEventTargetNotFound(const ui::Event& event) override;
155 176
156 // The single WindowTree this WindowManagerState is associated with. 177 // The single WindowTree this WindowManagerState is associated with.
157 // |window_tree_| owns this. 178 // |window_tree_| owns this.
158 WindowTree* window_tree_; 179 WindowTree* window_tree_;
159 180
160 // Set to true the first time SetFrameDecorationValues() is called. 181 // Set to true the first time SetFrameDecorationValues() is called.
161 bool got_frame_decoration_values_ = false; 182 bool got_frame_decoration_values_ = false;
162 mojom::FrameDecorationValuesPtr frame_decoration_values_; 183 mojom::FrameDecorationValuesPtr frame_decoration_values_;
163 184
185 EventDispatchPhase event_dispatch_phase_ = EventDispatchPhase::NONE;
186 // The tree we're waiting to process the current accelerator or event.
164 mojom::WindowTree* tree_awaiting_input_ack_ = nullptr; 187 mojom::WindowTree* tree_awaiting_input_ack_ = nullptr;
188 // The event we're awaiting an accelerator or input ack from.
165 std::unique_ptr<ui::Event> event_awaiting_input_ack_; 189 std::unique_ptr<ui::Event> event_awaiting_input_ack_;
166 base::WeakPtr<Accelerator> post_target_accelerator_; 190 base::WeakPtr<Accelerator> post_target_accelerator_;
167 std::queue<std::unique_ptr<QueuedEvent>> event_queue_; 191 std::queue<std::unique_ptr<QueuedEvent>> event_queue_;
168 base::OneShotTimer event_ack_timer_; 192 base::OneShotTimer event_ack_timer_;
169 193
170 EventDispatcher event_dispatcher_; 194 EventDispatcher event_dispatcher_;
171 195
172 // PlatformDisplay that currently has capture. 196 // PlatformDisplay that currently has capture.
173 PlatformDisplay* platform_display_with_capture_ = nullptr; 197 PlatformDisplay* platform_display_with_capture_ = nullptr;
174 198
175 base::WeakPtrFactory<WindowManagerState> weak_factory_; 199 base::WeakPtrFactory<WindowManagerState> weak_factory_;
176 200
177 DISALLOW_COPY_AND_ASSIGN(WindowManagerState); 201 DISALLOW_COPY_AND_ASSIGN(WindowManagerState);
178 }; 202 };
179 203
180 } // namespace ws 204 } // namespace ws
181 } // namespace ui 205 } // namespace ui
182 206
183 #endif // SERVICES_UI_WS_WINDOW_MANAGER_STATE_H_ 207 #endif // SERVICES_UI_WS_WINDOW_MANAGER_STATE_H_
OLDNEW
« no previous file with comments | « services/ui/ws/window_manager_client_unittest.cc ('k') | services/ui/ws/window_manager_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698