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 "components/mus/ws/window_manager_state.h" | 5 #include "components/mus/ws/window_manager_state.h" |
6 | 6 |
7 #include "base/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
8 #include "components/mus/ws/accelerator.h" | 8 #include "components/mus/ws/accelerator.h" |
9 #include "components/mus/ws/display_manager.h" | 9 #include "components/mus/ws/display_manager.h" |
10 #include "components/mus/ws/platform_display.h" | 10 #include "components/mus/ws/platform_display.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 display_ptr->frame_decoration_values = frame_decoration_values_.Clone(); | 153 display_ptr->frame_decoration_values = frame_decoration_values_.Clone(); |
154 return display_ptr; | 154 return display_ptr; |
155 } | 155 } |
156 | 156 |
157 void WindowManagerState::OnWillDestroyTree(WindowTree* tree) { | 157 void WindowManagerState::OnWillDestroyTree(WindowTree* tree) { |
158 if (tree_awaiting_input_ack_ != tree) | 158 if (tree_awaiting_input_ack_ != tree) |
159 return; | 159 return; |
160 // The WindowTree is dying. So it's not going to ack the event. | 160 // The WindowTree is dying. So it's not going to ack the event. |
161 // If the dying tree matches the root |tree_| marked as handled so we don't | 161 // If the dying tree matches the root |tree_| marked as handled so we don't |
162 // notify it of accelerators. | 162 // notify it of accelerators. |
163 OnEventAck(tree_awaiting_input_ack_, tree == tree_); | 163 OnEventAck(tree_awaiting_input_ack_, tree == tree_ |
| 164 ? mojom::EventResult::HANDLED |
| 165 : mojom::EventResult::UNHANDLED); |
164 } | 166 } |
165 | 167 |
166 WindowManagerState::WindowManagerState(Display* display, | 168 WindowManagerState::WindowManagerState(Display* display, |
167 PlatformDisplay* platform_display, | 169 PlatformDisplay* platform_display, |
168 cc::SurfaceId surface_id, | 170 cc::SurfaceId surface_id, |
169 bool is_user_id_valid, | 171 bool is_user_id_valid, |
170 const UserId& user_id) | 172 const UserId& user_id) |
171 : display_(display), | 173 : display_(display), |
172 platform_display_(platform_display), | 174 platform_display_(platform_display), |
173 is_user_id_valid_(is_user_id_valid), | 175 is_user_id_valid_(is_user_id_valid), |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 event_queue_.back()->event = CoalesceEvents( | 222 event_queue_.back()->event = CoalesceEvents( |
221 std::move(event_queue_.back()->event), ui::Event::Clone(event)); | 223 std::move(event_queue_.back()->event), ui::Event::Clone(event)); |
222 return; | 224 return; |
223 } | 225 } |
224 QueueEvent(event, nullptr); | 226 QueueEvent(event, nullptr); |
225 return; | 227 return; |
226 } | 228 } |
227 event_dispatcher_.ProcessEvent(event); | 229 event_dispatcher_.ProcessEvent(event); |
228 } | 230 } |
229 | 231 |
230 void WindowManagerState::OnEventAck(mojom::WindowTree* tree, bool handled) { | 232 void WindowManagerState::OnEventAck(mojom::WindowTree* tree, |
| 233 mojom::EventResult result) { |
231 if (tree_awaiting_input_ack_ != tree) { | 234 if (tree_awaiting_input_ack_ != tree) { |
232 // TODO(sad): The ack must have arrived after the timeout. We should do | 235 // TODO(sad): The ack must have arrived after the timeout. We should do |
233 // something here, and in OnEventAckTimeout(). | 236 // something here, and in OnEventAckTimeout(). |
234 return; | 237 return; |
235 } | 238 } |
236 tree_awaiting_input_ack_ = nullptr; | 239 tree_awaiting_input_ack_ = nullptr; |
237 event_ack_timer_.Stop(); | 240 event_ack_timer_.Stop(); |
238 | 241 |
239 if (!handled && post_target_accelerator_) | 242 if (result == mojom::EventResult::UNHANDLED && post_target_accelerator_) |
240 OnAccelerator(post_target_accelerator_->id(), *event_awaiting_input_ack_); | 243 OnAccelerator(post_target_accelerator_->id(), *event_awaiting_input_ack_); |
241 | 244 |
242 ProcessNextEventFromQueue(); | 245 ProcessNextEventFromQueue(); |
243 } | 246 } |
244 | 247 |
245 WindowServer* WindowManagerState::window_server() { | 248 WindowServer* WindowManagerState::window_server() { |
246 return display_->window_server(); | 249 return display_->window_server(); |
247 } | 250 } |
248 | 251 |
249 void WindowManagerState::OnEventAckTimeout() { | 252 void WindowManagerState::OnEventAckTimeout() { |
250 // TODO(sad): Figure out what we should do. | 253 // TODO(sad): Figure out what we should do. |
251 NOTIMPLEMENTED() << "Event ACK timed out."; | 254 NOTIMPLEMENTED() << "Event ACK timed out."; |
252 OnEventAck(tree_awaiting_input_ack_, false); | 255 OnEventAck(tree_awaiting_input_ack_, mojom::EventResult::UNHANDLED); |
253 } | 256 } |
254 | 257 |
255 void WindowManagerState::QueueEvent( | 258 void WindowManagerState::QueueEvent( |
256 const ui::Event& event, | 259 const ui::Event& event, |
257 scoped_ptr<ProcessedEventTarget> processed_event_target) { | 260 scoped_ptr<ProcessedEventTarget> processed_event_target) { |
258 scoped_ptr<QueuedEvent> queued_event(new QueuedEvent); | 261 scoped_ptr<QueuedEvent> queued_event(new QueuedEvent); |
259 queued_event->event = ui::Event::Clone(event); | 262 queued_event->event = ui::Event::Clone(event); |
260 queued_event->processed_target = std::move(processed_event_target); | 263 queued_event->processed_target = std::move(processed_event_target); |
261 event_queue_.push(std::move(queued_event)); | 264 event_queue_.push(std::move(queued_event)); |
262 } | 265 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 | 378 |
376 base::WeakPtr<Accelerator> weak_accelerator; | 379 base::WeakPtr<Accelerator> weak_accelerator; |
377 if (accelerator) | 380 if (accelerator) |
378 weak_accelerator = accelerator->GetWeakPtr(); | 381 weak_accelerator = accelerator->GetWeakPtr(); |
379 DispatchInputEventToWindowImpl(target, in_nonclient_area, event, | 382 DispatchInputEventToWindowImpl(target, in_nonclient_area, event, |
380 weak_accelerator); | 383 weak_accelerator); |
381 } | 384 } |
382 | 385 |
383 } // namespace ws | 386 } // namespace ws |
384 } // namespace mus | 387 } // namespace mus |
OLD | NEW |