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

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: add test 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
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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 bool RootWindow::DispatchMouseEvent(MouseEvent* event) { 253 bool RootWindow::DispatchMouseEvent(MouseEvent* event) {
253 if (mouse_move_hold_count_) { 254 if (mouse_move_hold_count_) {
254 if (event->type() == ui::ET_MOUSE_DRAGGED || 255 if (event->type() == ui::ET_MOUSE_DRAGGED ||
255 (event->flags() & ui::EF_IS_SYNTHESIZED)) { 256 (event->flags() & ui::EF_IS_SYNTHESIZED)) {
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 DispatchHeldMouseMove();
260 } 261 }
261 } 262 }
262 return DispatchMouseEventImpl(event); 263 return DispatchMouseEventImpl(event);
sky 2012/06/12 03:57:47 Should this reset held_mouse_move_ now? I'm thinki
piman 2012/06/12 04:42:05 We wouldn't want to drop it, but we'd need to disp
piman 2012/06/12 19:49:49 I changed the logic a little bit here, I think thi
263 } 264 }
264 265
265 bool RootWindow::DispatchKeyEvent(KeyEvent* event) { 266 bool RootWindow::DispatchKeyEvent(KeyEvent* event) {
266 DispatchHeldMouseMove(); 267 DispatchHeldMouseMove();
267 KeyEvent translated_event(*event); 268 KeyEvent translated_event(*event);
268 if (translated_event.key_code() == ui::VKEY_UNKNOWN) 269 if (translated_event.key_code() == ui::VKEY_UNKNOWN)
269 return false; 270 return false;
270 client::EventClient* client = client::GetEventClient(GetRootWindow()); 271 client::EventClient* client = client::GetEventClient(GetRootWindow());
271 Window* focused_window = focus_manager_->GetFocusedWindow(); 272 Window* focused_window = focus_manager_->GetFocusedWindow();
272 if (client && !client->CanProcessEventsWithinSubtree(focused_window)) { 273 if (client && !client->CanProcessEventsWithinSubtree(focused_window)) {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 return host_->GetAcceleratedWidget(); 479 return host_->GetAcceleratedWidget();
479 } 480 }
480 481
481 #if !defined(NDEBUG) 482 #if !defined(NDEBUG)
482 void RootWindow::ToggleFullScreen() { 483 void RootWindow::ToggleFullScreen() {
483 host_->ToggleFullScreen(); 484 host_->ToggleFullScreen();
484 } 485 }
485 #endif 486 #endif
486 487
487 void RootWindow::HoldMouseMoves() { 488 void RootWindow::HoldMouseMoves() {
489 if (!mouse_move_hold_count_)
490 held_mouse_event_factory_.InvalidateWeakPtrs();
jonathan.backer 2012/06/12 17:32:38 Why are we invalidating? It happens all the time w
488 ++mouse_move_hold_count_; 491 ++mouse_move_hold_count_;
489 } 492 }
490 493
491 void RootWindow::ReleaseMouseMoves() { 494 void RootWindow::ReleaseMouseMoves() {
492 --mouse_move_hold_count_; 495 --mouse_move_hold_count_;
493 DCHECK_GE(mouse_move_hold_count_, 0); 496 DCHECK_GE(mouse_move_hold_count_, 0);
494 if (!mouse_move_hold_count_) 497 if (!mouse_move_hold_count_ && held_mouse_move_.get()) {
495 DispatchHeldMouseMove(); 498 MessageLoop::current()->PostTask(
sky 2012/06/12 03:57:47 Add a comment as to why we don't process immediate
piman 2012/06/12 19:49:49 Done.
499 FROM_HERE,
500 base::Bind(&RootWindow::DispatchHeldMouseMove,
501 held_mouse_event_factory_.GetWeakPtr()));
502 }
496 } 503 }
497 504
498 scoped_refptr<CompositorLock> RootWindow::GetCompositorLock() { 505 scoped_refptr<CompositorLock> RootWindow::GetCompositorLock() {
499 if (!compositor_lock_) 506 if (!compositor_lock_)
500 compositor_lock_ = new CompositorLock(this); 507 compositor_lock_ = new CompositorLock(this);
501 return compositor_lock_; 508 return compositor_lock_;
502 } 509 }
503 510
504 void RootWindow::SetFocusWhenShown(bool focused) { 511 void RootWindow::SetFocusWhenShown(bool focused) {
505 host_->SetFocusWhenShown(focused); 512 host_->SetFocusWhenShown(focused);
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 void RootWindow::UnlockCompositor() { 1023 void RootWindow::UnlockCompositor() {
1017 DCHECK(compositor_lock_); 1024 DCHECK(compositor_lock_);
1018 compositor_lock_ = NULL; 1025 compositor_lock_ = NULL;
1019 if (draw_on_compositor_unlock_) { 1026 if (draw_on_compositor_unlock_) {
1020 draw_on_compositor_unlock_ = false; 1027 draw_on_compositor_unlock_ = false;
1021 ScheduleDraw(); 1028 ScheduleDraw();
1022 } 1029 }
1023 } 1030 }
1024 1031
1025 } // namespace aura 1032 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698