Chromium Code Reviews| 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 if (event_ack_timer_.IsRunning()) { | 219 if (event_ack_timer_.IsRunning()) { |
| 220 if (!event_queue_.empty() && !event_queue_.back()->processed_target && | 220 if (!event_queue_.empty() && !event_queue_.back()->processed_target && |
| 221 EventsCanBeCoalesced(*event_queue_.back()->event, event)) { | 221 EventsCanBeCoalesced(*event_queue_.back()->event, event)) { |
| 222 event_queue_.back()->event = CoalesceEvents( | 222 event_queue_.back()->event = CoalesceEvents( |
| 223 std::move(event_queue_.back()->event), ui::Event::Clone(event)); | 223 std::move(event_queue_.back()->event), ui::Event::Clone(event)); |
| 224 return; | 224 return; |
| 225 } | 225 } |
| 226 QueueEvent(event, nullptr); | 226 QueueEvent(event, nullptr); |
| 227 return; | 227 return; |
| 228 } | 228 } |
| 229 | |
| 230 // Only send events to any event observers after the previous event was acked, | |
| 231 // to maintain ordering with events sent via normal dispatch. | |
| 232 // TODO(jamescook): If the event dispatcher finds a target window, and that | |
| 233 // window's window tree has an event observer that matches the event, just | |
| 234 // send the event once via normal dispatch and let the client library trigger | |
| 235 // its event observer mechanism. http://crbug.com/605580 | |
| 236 window_server()->SendToEventObservers(event); | |
|
sky
2016/04/21 17:23:03
This comment doesn't match with the code. This fun
James Cook
2016/04/22 18:22:54
This code is gone.
| |
| 237 | |
| 229 event_dispatcher_.ProcessEvent(event); | 238 event_dispatcher_.ProcessEvent(event); |
| 230 } | 239 } |
| 231 | 240 |
| 232 void WindowManagerState::OnEventAck(mojom::WindowTree* tree, | 241 void WindowManagerState::OnEventAck(mojom::WindowTree* tree, |
| 233 mojom::EventResult result) { | 242 mojom::EventResult result) { |
| 234 if (tree_awaiting_input_ack_ != tree) { | 243 if (tree_awaiting_input_ack_ != tree) { |
| 235 // TODO(sad): The ack must have arrived after the timeout. We should do | 244 // TODO(sad): The ack must have arrived after the timeout. We should do |
| 236 // something here, and in OnEventAckTimeout(). | 245 // something here, and in OnEventAckTimeout(). |
| 237 return; | 246 return; |
| 238 } | 247 } |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 267 void WindowManagerState::ProcessNextEventFromQueue() { | 276 void WindowManagerState::ProcessNextEventFromQueue() { |
| 268 // Loop through |event_queue_| stopping after dispatching the first valid | 277 // Loop through |event_queue_| stopping after dispatching the first valid |
| 269 // event. | 278 // event. |
| 270 while (!event_queue_.empty()) { | 279 while (!event_queue_.empty()) { |
| 271 scoped_ptr<QueuedEvent> queued_event = std::move(event_queue_.front()); | 280 scoped_ptr<QueuedEvent> queued_event = std::move(event_queue_.front()); |
| 272 event_queue_.pop(); | 281 event_queue_.pop(); |
| 273 if (!queued_event->processed_target) { | 282 if (!queued_event->processed_target) { |
| 274 event_dispatcher_.ProcessEvent(*queued_event->event); | 283 event_dispatcher_.ProcessEvent(*queued_event->event); |
| 275 return; | 284 return; |
| 276 } | 285 } |
| 286 | |
| 287 // If the event has a target it was already sent to observers before its | |
| 288 // initial processing. | |
| 289 window_server()->SendToEventObservers(*queued_event->event); | |
| 290 | |
| 277 if (queued_event->processed_target->IsValid()) { | 291 if (queued_event->processed_target->IsValid()) { |
| 278 DispatchInputEventToWindowImpl( | 292 DispatchInputEventToWindowImpl( |
| 279 queued_event->processed_target->window(), | 293 queued_event->processed_target->window(), |
| 280 queued_event->processed_target->in_nonclient_area(), | 294 queued_event->processed_target->in_nonclient_area(), |
| 281 *queued_event->event, queued_event->processed_target->accelerator()); | 295 *queued_event->event, queued_event->processed_target->accelerator()); |
| 282 return; | 296 return; |
| 283 } | 297 } |
| 284 } | 298 } |
| 285 } | 299 } |
| 286 | 300 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 | 392 |
| 379 base::WeakPtr<Accelerator> weak_accelerator; | 393 base::WeakPtr<Accelerator> weak_accelerator; |
| 380 if (accelerator) | 394 if (accelerator) |
| 381 weak_accelerator = accelerator->GetWeakPtr(); | 395 weak_accelerator = accelerator->GetWeakPtr(); |
| 382 DispatchInputEventToWindowImpl(target, in_nonclient_area, event, | 396 DispatchInputEventToWindowImpl(target, in_nonclient_area, event, |
| 383 weak_accelerator); | 397 weak_accelerator); |
| 384 } | 398 } |
| 385 | 399 |
| 386 } // namespace ws | 400 } // namespace ws |
| 387 } // namespace mus | 401 } // namespace mus |
| OLD | NEW |