| 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 client::GetScreenPositionClient(root_window); | 62 client::GetScreenPositionClient(root_window); |
| 63 if (client) { | 63 if (client) { |
| 64 gfx::Point location_in_screen = location_in_root; | 64 gfx::Point location_in_screen = location_in_root; |
| 65 client->ConvertPointToScreen(root_window, &location_in_screen); | 65 client->ConvertPointToScreen(root_window, &location_in_screen); |
| 66 Env::GetInstance()->set_last_mouse_location(location_in_screen); | 66 Env::GetInstance()->set_last_mouse_location(location_in_screen); |
| 67 } else { | 67 } else { |
| 68 Env::GetInstance()->set_last_mouse_location(location_in_root); | 68 Env::GetInstance()->set_last_mouse_location(location_in_root); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 WindowTreeHost* CreateHost(RootWindow* root_window, | 72 RootWindowHost* CreateHost(RootWindow* root_window, |
| 73 const RootWindow::CreateParams& params) { | 73 const RootWindow::CreateParams& params) { |
| 74 WindowTreeHost* host = params.host ? | 74 RootWindowHost* host = params.host ? |
| 75 params.host : WindowTreeHost::Create(params.initial_bounds); | 75 params.host : RootWindowHost::Create(params.initial_bounds); |
| 76 host->set_delegate(root_window); | 76 host->set_delegate(root_window); |
| 77 return host; | 77 return host; |
| 78 } | 78 } |
| 79 | 79 |
| 80 } // namespace | 80 } // namespace |
| 81 | 81 |
| 82 RootWindow::CreateParams::CreateParams(const gfx::Rect& a_initial_bounds) | 82 RootWindow::CreateParams::CreateParams(const gfx::Rect& a_initial_bounds) |
| 83 : initial_bounds(a_initial_bounds), | 83 : initial_bounds(a_initial_bounds), |
| 84 host(NULL) { | 84 host(NULL) { |
| 85 } | 85 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 base::Bind(&RootWindow::DispatchHeldEventsAsync, | 162 base::Bind(&RootWindow::DispatchHeldEventsAsync, |
| 163 repost_event_factory_.GetWeakPtr())); | 163 repost_event_factory_.GetWeakPtr())); |
| 164 } else { | 164 } else { |
| 165 DCHECK(event.type() == ui::ET_GESTURE_TAP_DOWN); | 165 DCHECK(event.type() == ui::ET_GESTURE_TAP_DOWN); |
| 166 held_repostable_event_.reset(); | 166 held_repostable_event_.reset(); |
| 167 // TODO(rbyers): Reposing of gestures is tricky to get | 167 // TODO(rbyers): Reposing of gestures is tricky to get |
| 168 // right, so it's not yet supported. crbug.com/170987. | 168 // right, so it's not yet supported. crbug.com/170987. |
| 169 } | 169 } |
| 170 } | 170 } |
| 171 | 171 |
| 172 WindowTreeHostDelegate* RootWindow::AsWindowTreeHostDelegate() { | 172 RootWindowHostDelegate* RootWindow::AsRootWindowHostDelegate() { |
| 173 return this; | 173 return this; |
| 174 } | 174 } |
| 175 | 175 |
| 176 void RootWindow::SetHostSize(const gfx::Size& size_in_pixel) { | 176 void RootWindow::SetHostSize(const gfx::Size& size_in_pixel) { |
| 177 DispatchDetails details = DispatchHeldEvents(); | 177 DispatchDetails details = DispatchHeldEvents(); |
| 178 if (details.dispatcher_destroyed) | 178 if (details.dispatcher_destroyed) |
| 179 return; | 179 return; |
| 180 gfx::Rect bounds = host_->GetBounds(); | 180 gfx::Rect bounds = host_->GetBounds(); |
| 181 bounds.set_size(size_in_pixel); | 181 bounds.set_size(size_in_pixel); |
| 182 host_->SetBounds(bounds); | 182 host_->SetBounds(bounds); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 window->ContainsPointInRoot(GetLastMouseLocationInRoot()))) { | 314 window->ContainsPointInRoot(GetLastMouseLocationInRoot()))) { |
| 315 PostMouseMoveEventAfterWindowChange(); | 315 PostMouseMoveEventAfterWindowChange(); |
| 316 } | 316 } |
| 317 } | 317 } |
| 318 | 318 |
| 319 void RootWindow::OnKeyboardMappingChanged() { | 319 void RootWindow::OnKeyboardMappingChanged() { |
| 320 FOR_EACH_OBSERVER(RootWindowObserver, observers_, | 320 FOR_EACH_OBSERVER(RootWindowObserver, observers_, |
| 321 OnKeyboardMappingChanged(this)); | 321 OnKeyboardMappingChanged(this)); |
| 322 } | 322 } |
| 323 | 323 |
| 324 void RootWindow::OnWindowTreeHostCloseRequested() { | 324 void RootWindow::OnRootWindowHostCloseRequested() { |
| 325 FOR_EACH_OBSERVER(RootWindowObserver, observers_, | 325 FOR_EACH_OBSERVER(RootWindowObserver, observers_, |
| 326 OnWindowTreeHostCloseRequested(this)); | 326 OnRootWindowHostCloseRequested(this)); |
| 327 } | 327 } |
| 328 | 328 |
| 329 void RootWindow::AddRootWindowObserver(RootWindowObserver* observer) { | 329 void RootWindow::AddRootWindowObserver(RootWindowObserver* observer) { |
| 330 observers_.AddObserver(observer); | 330 observers_.AddObserver(observer); |
| 331 } | 331 } |
| 332 | 332 |
| 333 void RootWindow::RemoveRootWindowObserver(RootWindowObserver* observer) { | 333 void RootWindow::RemoveRootWindowObserver(RootWindowObserver* observer) { |
| 334 observers_.RemoveObserver(observer); | 334 observers_.RemoveObserver(observer); |
| 335 } | 335 } |
| 336 | 336 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 | 582 |
| 583 void RootWindow::OnLayerAnimationScheduled( | 583 void RootWindow::OnLayerAnimationScheduled( |
| 584 ui::LayerAnimationSequence* animation) { | 584 ui::LayerAnimationSequence* animation) { |
| 585 } | 585 } |
| 586 | 586 |
| 587 void RootWindow::OnLayerAnimationAborted( | 587 void RootWindow::OnLayerAnimationAborted( |
| 588 ui::LayerAnimationSequence* animation) { | 588 ui::LayerAnimationSequence* animation) { |
| 589 } | 589 } |
| 590 | 590 |
| 591 //////////////////////////////////////////////////////////////////////////////// | 591 //////////////////////////////////////////////////////////////////////////////// |
| 592 // RootWindow, WindowTreeHostDelegate implementation: | 592 // RootWindow, RootWindowHostDelegate implementation: |
| 593 | 593 |
| 594 bool RootWindow::OnHostKeyEvent(ui::KeyEvent* event) { | 594 bool RootWindow::OnHostKeyEvent(ui::KeyEvent* event) { |
| 595 DispatchDetails details = DispatchHeldEvents(); | 595 DispatchDetails details = DispatchHeldEvents(); |
| 596 if (details.dispatcher_destroyed) | 596 if (details.dispatcher_destroyed) |
| 597 return false; | 597 return false; |
| 598 if (event->key_code() == ui::VKEY_UNKNOWN) | 598 if (event->key_code() == ui::VKEY_UNKNOWN) |
| 599 return false; | 599 return false; |
| 600 client::EventClient* client = client::GetEventClient(window()); | 600 client::EventClient* client = client::GetEventClient(window()); |
| 601 Window* focused_window = client::GetFocusClient(window())->GetFocusedWindow(); | 601 Window* focused_window = client::GetFocusClient(window())->GetFocusedWindow(); |
| 602 if (client && !client->CanProcessEventsWithinSubtree(focused_window)) { | 602 if (client && !client->CanProcessEventsWithinSubtree(focused_window)) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 void RootWindow::OnHostLostMouseGrab() { | 689 void RootWindow::OnHostLostMouseGrab() { |
| 690 mouse_pressed_handler_ = NULL; | 690 mouse_pressed_handler_ = NULL; |
| 691 mouse_moved_handler_ = NULL; | 691 mouse_moved_handler_ = NULL; |
| 692 } | 692 } |
| 693 | 693 |
| 694 void RootWindow::OnHostMoved(const gfx::Point& origin) { | 694 void RootWindow::OnHostMoved(const gfx::Point& origin) { |
| 695 TRACE_EVENT1("ui", "RootWindow::OnHostMoved", | 695 TRACE_EVENT1("ui", "RootWindow::OnHostMoved", |
| 696 "origin", origin.ToString()); | 696 "origin", origin.ToString()); |
| 697 | 697 |
| 698 FOR_EACH_OBSERVER(RootWindowObserver, observers_, | 698 FOR_EACH_OBSERVER(RootWindowObserver, observers_, |
| 699 OnWindowTreeHostMoved(this, origin)); | 699 OnRootWindowHostMoved(this, origin)); |
| 700 } | 700 } |
| 701 | 701 |
| 702 void RootWindow::OnHostResized(const gfx::Size& size) { | 702 void RootWindow::OnHostResized(const gfx::Size& size) { |
| 703 TRACE_EVENT1("ui", "RootWindow::OnHostResized", | 703 TRACE_EVENT1("ui", "RootWindow::OnHostResized", |
| 704 "size", size.ToString()); | 704 "size", size.ToString()); |
| 705 | 705 |
| 706 DispatchDetails details = DispatchHeldEvents(); | 706 DispatchDetails details = DispatchHeldEvents(); |
| 707 if (details.dispatcher_destroyed) | 707 if (details.dispatcher_destroyed) |
| 708 return; | 708 return; |
| 709 | 709 |
| 710 FOR_EACH_OBSERVER(RootWindowObserver, observers_, | 710 FOR_EACH_OBSERVER(RootWindowObserver, observers_, |
| 711 OnWindowTreeHostResized(this)); | 711 OnRootWindowHostResized(this)); |
| 712 } | 712 } |
| 713 | 713 |
| 714 RootWindow* RootWindow::AsRootWindow() { | 714 RootWindow* RootWindow::AsRootWindow() { |
| 715 return this; | 715 return this; |
| 716 } | 716 } |
| 717 | 717 |
| 718 const RootWindow* RootWindow::AsRootWindow() const { | 718 const RootWindow* RootWindow::AsRootWindow() const { |
| 719 return this; | 719 return this; |
| 720 } | 720 } |
| 721 | 721 |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 991 return OnHostMouseEventImpl(&event); | 991 return OnHostMouseEventImpl(&event); |
| 992 } | 992 } |
| 993 | 993 |
| 994 void RootWindow::SynthesizeMouseMoveEventAsync() { | 994 void RootWindow::SynthesizeMouseMoveEventAsync() { |
| 995 DispatchDetails details = SynthesizeMouseMoveEvent(); | 995 DispatchDetails details = SynthesizeMouseMoveEvent(); |
| 996 if (details.dispatcher_destroyed) | 996 if (details.dispatcher_destroyed) |
| 997 return; | 997 return; |
| 998 } | 998 } |
| 999 | 999 |
| 1000 } // namespace aura | 1000 } // namespace aura |
| OLD | NEW |