OLD | NEW |
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/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 218 |
219 void RootWindow::RepostEvent(const ui::LocatedEvent& event) { | 219 void RootWindow::RepostEvent(const ui::LocatedEvent& event) { |
220 // We allow for only one outstanding repostable event. This is used | 220 // We allow for only one outstanding repostable event. This is used |
221 // in exiting context menus. A dropped repost request is allowed. | 221 // in exiting context menus. A dropped repost request is allowed. |
222 if (event.type() == ui::ET_MOUSE_PRESSED) { | 222 if (event.type() == ui::ET_MOUSE_PRESSED) { |
223 held_repostable_event_.reset( | 223 held_repostable_event_.reset( |
224 new ui::MouseEvent( | 224 new ui::MouseEvent( |
225 static_cast<const ui::MouseEvent&>(event), | 225 static_cast<const ui::MouseEvent&>(event), |
226 static_cast<aura::Window*>(event.target()), | 226 static_cast<aura::Window*>(event.target()), |
227 static_cast<aura::Window*>(this))); | 227 static_cast<aura::Window*>(this))); |
228 MessageLoop::current()->PostTask( | 228 base::MessageLoop::current()->PostTask( |
229 FROM_HERE, | 229 FROM_HERE, |
230 base::Bind(&RootWindow::DispatchHeldEvents, | 230 base::Bind(&RootWindow::DispatchHeldEvents, |
231 repostable_event_factory_.GetWeakPtr())); | 231 repostable_event_factory_.GetWeakPtr())); |
232 } else { | 232 } else { |
233 DCHECK(event.type() == ui::ET_GESTURE_TAP_DOWN); | 233 DCHECK(event.type() == ui::ET_GESTURE_TAP_DOWN); |
234 held_repostable_event_.reset(); | 234 held_repostable_event_.reset(); |
235 // TODO(sschmitz): add similar code for gesture events. | 235 // TODO(sschmitz): add similar code for gesture events. |
236 } | 236 } |
237 } | 237 } |
238 | 238 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 | 464 |
465 void RootWindow::ReleaseMouseMoves() { | 465 void RootWindow::ReleaseMouseMoves() { |
466 --mouse_move_hold_count_; | 466 --mouse_move_hold_count_; |
467 DCHECK_GE(mouse_move_hold_count_, 0); | 467 DCHECK_GE(mouse_move_hold_count_, 0); |
468 if (!mouse_move_hold_count_ && held_mouse_move_) { | 468 if (!mouse_move_hold_count_ && held_mouse_move_) { |
469 // We don't want to call DispatchHeldEvents directly, because this might | 469 // We don't want to call DispatchHeldEvents directly, because this might |
470 // be called from a deep stack while another event, in which case | 470 // be called from a deep stack while another event, in which case |
471 // dispatching another one may not be safe/expected. | 471 // dispatching another one may not be safe/expected. |
472 // Instead we post a task, that we may cancel if HoldMouseMoves is called | 472 // Instead we post a task, that we may cancel if HoldMouseMoves is called |
473 // again before it executes. | 473 // again before it executes. |
474 MessageLoop::current()->PostTask( | 474 base::MessageLoop::current()->PostTask( |
475 FROM_HERE, | 475 FROM_HERE, |
476 base::Bind(&RootWindow::DispatchHeldEvents, | 476 base::Bind(&RootWindow::DispatchHeldEvents, |
477 held_event_factory_.GetWeakPtr())); | 477 held_event_factory_.GetWeakPtr())); |
478 } | 478 } |
479 TRACE_EVENT_ASYNC_END0("ui", "RootWindow::HoldMouseMoves", this); | 479 TRACE_EVENT_ASYNC_END0("ui", "RootWindow::HoldMouseMoves", this); |
480 } | 480 } |
481 | 481 |
482 void RootWindow::SetFocusWhenShown(bool focused) { | 482 void RootWindow::SetFocusWhenShown(bool focused) { |
483 host_->SetFocusWhenShown(focused); | 483 host_->SetFocusWhenShown(focused); |
484 } | 484 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 Env::GetInstance(); | 545 Env::GetInstance(); |
546 } | 546 } |
547 | 547 |
548 //////////////////////////////////////////////////////////////////////////////// | 548 //////////////////////////////////////////////////////////////////////////////// |
549 // RootWindow, ui::CompositorDelegate implementation: | 549 // RootWindow, ui::CompositorDelegate implementation: |
550 | 550 |
551 void RootWindow::ScheduleDraw() { | 551 void RootWindow::ScheduleDraw() { |
552 DCHECK(!ui::Compositor::WasInitializedWithThread()); | 552 DCHECK(!ui::Compositor::WasInitializedWithThread()); |
553 if (!defer_draw_scheduling_) { | 553 if (!defer_draw_scheduling_) { |
554 defer_draw_scheduling_ = true; | 554 defer_draw_scheduling_ = true; |
555 MessageLoop::current()->PostTask( | 555 base::MessageLoop::current()->PostTask( |
556 FROM_HERE, | 556 FROM_HERE, |
557 base::Bind(&RootWindow::Draw, schedule_paint_factory_.GetWeakPtr())); | 557 base::Bind(&RootWindow::Draw, schedule_paint_factory_.GetWeakPtr())); |
558 } | 558 } |
559 } | 559 } |
560 | 560 |
561 //////////////////////////////////////////////////////////////////////////////// | 561 //////////////////////////////////////////////////////////////////////////////// |
562 // RootWindow, ui::CompositorObserver implementation: | 562 // RootWindow, ui::CompositorObserver implementation: |
563 | 563 |
564 void RootWindow::OnCompositingDidCommit(ui::Compositor*) { | 564 void RootWindow::OnCompositingDidCommit(ui::Compositor*) { |
565 } | 565 } |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 if (!synthesize_mouse_move_) | 1135 if (!synthesize_mouse_move_) |
1136 DispatchMouseEventImpl(held_mouse_move_.get()); | 1136 DispatchMouseEventImpl(held_mouse_move_.get()); |
1137 held_mouse_move_.reset(); | 1137 held_mouse_move_.reset(); |
1138 } | 1138 } |
1139 } | 1139 } |
1140 | 1140 |
1141 void RootWindow::PostMouseMoveEventAfterWindowChange() { | 1141 void RootWindow::PostMouseMoveEventAfterWindowChange() { |
1142 if (synthesize_mouse_move_) | 1142 if (synthesize_mouse_move_) |
1143 return; | 1143 return; |
1144 synthesize_mouse_move_ = true; | 1144 synthesize_mouse_move_ = true; |
1145 MessageLoop::current()->PostTask( | 1145 base::MessageLoop::current()->PostTask( |
1146 FROM_HERE, | 1146 FROM_HERE, |
1147 base::Bind(&RootWindow::SynthesizeMouseMoveEvent, | 1147 base::Bind(&RootWindow::SynthesizeMouseMoveEvent, |
1148 event_factory_.GetWeakPtr())); | 1148 event_factory_.GetWeakPtr())); |
1149 } | 1149 } |
1150 | 1150 |
1151 void RootWindow::SynthesizeMouseMoveEvent() { | 1151 void RootWindow::SynthesizeMouseMoveEvent() { |
1152 if (!synthesize_mouse_move_) | 1152 if (!synthesize_mouse_move_) |
1153 return; | 1153 return; |
1154 synthesize_mouse_move_ = false; | 1154 synthesize_mouse_move_ = false; |
1155 gfx::Point root_mouse_location = GetLastMouseLocationInRoot(); | 1155 gfx::Point root_mouse_location = GetLastMouseLocationInRoot(); |
(...skipping 20 matching lines...) Expand all Loading... |
1176 } | 1176 } |
1177 | 1177 |
1178 gfx::Transform RootWindow::GetInverseRootTransform() const { | 1178 gfx::Transform RootWindow::GetInverseRootTransform() const { |
1179 float scale = ui::GetDeviceScaleFactor(layer()); | 1179 float scale = ui::GetDeviceScaleFactor(layer()); |
1180 gfx::Transform transform; | 1180 gfx::Transform transform; |
1181 transform.Scale(1.0f / scale, 1.0f / scale); | 1181 transform.Scale(1.0f / scale, 1.0f / scale); |
1182 return transformer_->GetInverseTransform() * transform; | 1182 return transformer_->GetInverseTransform() * transform; |
1183 } | 1183 } |
1184 | 1184 |
1185 } // namespace aura | 1185 } // namespace aura |
OLD | NEW |