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

Side by Side Diff: ui/aura/root_window.cc

Issue 10545129: aura:Delay call to DispatchHeldMouseMove from RootWindow::ReleaseMouseMoves (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « ui/aura/root_window.h ('k') | ui/aura/root_window_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/aura/root_window.h" 5 #include "ui/aura/root_window.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 last_cursor_(ui::kCursorNull), 123 last_cursor_(ui::kCursorNull),
124 mouse_pressed_handler_(NULL), 124 mouse_pressed_handler_(NULL),
125 mouse_moved_handler_(NULL), 125 mouse_moved_handler_(NULL),
126 ALLOW_THIS_IN_INITIALIZER_LIST( 126 ALLOW_THIS_IN_INITIALIZER_LIST(
127 gesture_recognizer_(ui::GestureRecognizer::Create(this))), 127 gesture_recognizer_(ui::GestureRecognizer::Create(this))),
128 synthesize_mouse_move_(false), 128 synthesize_mouse_move_(false),
129 waiting_on_compositing_end_(false), 129 waiting_on_compositing_end_(false),
130 draw_on_compositing_end_(false), 130 draw_on_compositing_end_(false),
131 defer_draw_scheduling_(false), 131 defer_draw_scheduling_(false),
132 mouse_move_hold_count_(0), 132 mouse_move_hold_count_(0),
133 ALLOW_THIS_IN_INITIALIZER_LIST(held_mouse_event_factory_(this)),
133 compositor_lock_(NULL), 134 compositor_lock_(NULL),
134 draw_on_compositor_unlock_(false) { 135 draw_on_compositor_unlock_(false) {
135 SetName("RootWindow"); 136 SetName("RootWindow");
136 137
137 compositor_.reset(new ui::Compositor(this, host_->GetAcceleratedWidget())); 138 compositor_.reset(new ui::Compositor(this, host_->GetAcceleratedWidget()));
138 DCHECK(compositor_.get()); 139 DCHECK(compositor_.get());
139 compositor_->AddObserver(this); 140 compositor_->AddObserver(this);
140 } 141 }
141 142
142 RootWindow::~RootWindow() { 143 RootWindow::~RootWindow() {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 compositor_->last_started_frame() + 1); 244 compositor_->last_started_frame() + 1);
244 245
245 compositor_->Draw(false); 246 compositor_->Draw(false);
246 } 247 }
247 248
248 void RootWindow::ScheduleFullDraw() { 249 void RootWindow::ScheduleFullDraw() {
249 compositor_->ScheduleFullDraw(); 250 compositor_->ScheduleFullDraw();
250 } 251 }
251 252
252 bool RootWindow::DispatchMouseEvent(MouseEvent* event) { 253 bool RootWindow::DispatchMouseEvent(MouseEvent* event) {
253 if (mouse_move_hold_count_) { 254 if (event->type() == ui::ET_MOUSE_DRAGGED ||
254 if (event->type() == ui::ET_MOUSE_DRAGGED || 255 (event->flags() & ui::EF_IS_SYNTHESIZED)) {
255 (event->flags() & ui::EF_IS_SYNTHESIZED)) { 256 if (mouse_move_hold_count_) {
256 held_mouse_move_.reset(new MouseEvent(*event, NULL, NULL)); 257 held_mouse_move_.reset(new MouseEvent(*event, NULL, NULL));
257 return true; 258 return true;
258 } else { 259 } else {
259 DispatchHeldMouseMove(); 260 // We may have a held event for a period between the time
261 // mouse_move_hold_count_ fell to 0 and the DispatchHeldMouseMove
262 // executes. Since we're going to dispatch the new event directly below,
263 // we can reset the old one.
264 held_mouse_move_.reset();
260 } 265 }
261 } 266 }
267 DispatchHeldMouseMove();
262 return DispatchMouseEventImpl(event); 268 return DispatchMouseEventImpl(event);
263 } 269 }
264 270
265 bool RootWindow::DispatchKeyEvent(KeyEvent* event) { 271 bool RootWindow::DispatchKeyEvent(KeyEvent* event) {
266 DispatchHeldMouseMove(); 272 DispatchHeldMouseMove();
267 KeyEvent translated_event(*event); 273 KeyEvent translated_event(*event);
268 if (translated_event.key_code() == ui::VKEY_UNKNOWN) 274 if (translated_event.key_code() == ui::VKEY_UNKNOWN)
269 return false; 275 return false;
270 client::EventClient* client = client::GetEventClient(GetRootWindow()); 276 client::EventClient* client = client::GetEventClient(GetRootWindow());
271 Window* focused_window = focus_manager_->GetFocusedWindow(); 277 Window* focused_window = focus_manager_->GetFocusedWindow();
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 return host_->GetAcceleratedWidget(); 484 return host_->GetAcceleratedWidget();
479 } 485 }
480 486
481 #if !defined(NDEBUG) 487 #if !defined(NDEBUG)
482 void RootWindow::ToggleFullScreen() { 488 void RootWindow::ToggleFullScreen() {
483 host_->ToggleFullScreen(); 489 host_->ToggleFullScreen();
484 } 490 }
485 #endif 491 #endif
486 492
487 void RootWindow::HoldMouseMoves() { 493 void RootWindow::HoldMouseMoves() {
494 if (!mouse_move_hold_count_)
495 held_mouse_event_factory_.InvalidateWeakPtrs();
488 ++mouse_move_hold_count_; 496 ++mouse_move_hold_count_;
489 } 497 }
490 498
491 void RootWindow::ReleaseMouseMoves() { 499 void RootWindow::ReleaseMouseMoves() {
492 --mouse_move_hold_count_; 500 --mouse_move_hold_count_;
493 DCHECK_GE(mouse_move_hold_count_, 0); 501 DCHECK_GE(mouse_move_hold_count_, 0);
494 if (!mouse_move_hold_count_) 502 if (!mouse_move_hold_count_ && held_mouse_move_.get()) {
495 DispatchHeldMouseMove(); 503 // We don't want to call DispatchHeldMouseMove directly, because this might
504 // be called from a deep stack while another event, in which case
505 // dispatching another one may not be safe/expected.
506 // Instead we post a task, that we may cancel if HoldMouseMoves is called
507 // again before it executes.
508 MessageLoop::current()->PostTask(
509 FROM_HERE,
510 base::Bind(&RootWindow::DispatchHeldMouseMove,
511 held_mouse_event_factory_.GetWeakPtr()));
512 }
496 } 513 }
497 514
498 scoped_refptr<CompositorLock> RootWindow::GetCompositorLock() { 515 scoped_refptr<CompositorLock> RootWindow::GetCompositorLock() {
499 if (!compositor_lock_) 516 if (!compositor_lock_)
500 compositor_lock_ = new CompositorLock(this); 517 compositor_lock_ = new CompositorLock(this);
501 return compositor_lock_; 518 return compositor_lock_;
502 } 519 }
503 520
504 void RootWindow::SetFocusWhenShown(bool focused) { 521 void RootWindow::SetFocusWhenShown(bool focused) {
505 host_->SetFocusWhenShown(focused); 522 host_->SetFocusWhenShown(focused);
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 void RootWindow::UnlockCompositor() { 1033 void RootWindow::UnlockCompositor() {
1017 DCHECK(compositor_lock_); 1034 DCHECK(compositor_lock_);
1018 compositor_lock_ = NULL; 1035 compositor_lock_ = NULL;
1019 if (draw_on_compositor_unlock_) { 1036 if (draw_on_compositor_unlock_) {
1020 draw_on_compositor_unlock_ = false; 1037 draw_on_compositor_unlock_ = false;
1021 ScheduleDraw(); 1038 ScheduleDraw();
1022 } 1039 }
1023 } 1040 }
1024 1041
1025 } // namespace aura 1042 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/root_window.h ('k') | ui/aura/root_window_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698