| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 float GetDeviceScaleFactorFromDisplay(Window* window) { | 61 float GetDeviceScaleFactorFromDisplay(Window* window) { |
| 62 return gfx::Screen::GetScreenFor(window)-> | 62 return gfx::Screen::GetScreenFor(window)-> |
| 63 GetDisplayNearestWindow(window).device_scale_factor(); | 63 GetDisplayNearestWindow(window).device_scale_factor(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 Window* ConsumerToWindow(ui::GestureConsumer* consumer) { | 66 Window* ConsumerToWindow(ui::GestureConsumer* consumer) { |
| 67 return consumer && !consumer->ignores_events() ? | 67 return consumer && !consumer->ignores_events() ? |
| 68 static_cast<Window*>(consumer) : NULL; | 68 static_cast<Window*>(consumer) : NULL; |
| 69 } | 69 } |
| 70 | 70 |
| 71 void SetLastMouseLocation(const Window* root_window, | 71 void SetLastMouseLocation(const RootWindow* root_window, |
| 72 const gfx::Point& location) { | 72 const gfx::Point& location_in_root) { |
| 73 Env::GetInstance()->SetLastMouseLocation(*root_window, location); | 73 client::ScreenPositionClient* client = |
| 74 client::GetScreenPositionClient(root_window); |
| 75 if (client) { |
| 76 gfx::Point location_in_screen = location_in_root; |
| 77 client->ConvertPointToScreen(root_window, &location_in_screen); |
| 78 Env::GetInstance()->set_last_mouse_location(location_in_screen); |
| 79 } else { |
| 80 Env::GetInstance()->set_last_mouse_location(location_in_root); |
| 81 } |
| 74 } | 82 } |
| 75 | 83 |
| 76 RootWindowHost* CreateHost(RootWindow* root_window, | 84 RootWindowHost* CreateHost(RootWindow* root_window, |
| 77 const RootWindow::CreateParams& params) { | 85 const RootWindow::CreateParams& params) { |
| 78 RootWindowHost* host = params.host ? | 86 RootWindowHost* host = params.host ? |
| 79 params.host : RootWindowHost::Create(params.initial_bounds); | 87 params.host : RootWindowHost::Create(params.initial_bounds); |
| 80 host->SetDelegate(root_window); | 88 host->SetDelegate(root_window); |
| 81 return host; | 89 return host; |
| 82 } | 90 } |
| 83 | 91 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 return host_->GetBounds().origin(); | 206 return host_->GetBounds().origin(); |
| 199 } | 207 } |
| 200 | 208 |
| 201 void RootWindow::SetCursor(gfx::NativeCursor cursor) { | 209 void RootWindow::SetCursor(gfx::NativeCursor cursor) { |
| 202 last_cursor_ = cursor; | 210 last_cursor_ = cursor; |
| 203 // A lot of code seems to depend on NULL cursors actually showing an arrow, | 211 // A lot of code seems to depend on NULL cursors actually showing an arrow, |
| 204 // so just pass everything along to the host. | 212 // so just pass everything along to the host. |
| 205 host_->SetCursor(cursor); | 213 host_->SetCursor(cursor); |
| 206 } | 214 } |
| 207 | 215 |
| 208 void RootWindow::OnCursorVisibilityChanged(bool show) { | 216 void RootWindow::OnCursorEnableStateChanged(bool enabled) { |
| 209 // Send entered / exited so that visual state can be updated to match | 217 // Send entered / exited so that visual state can be updated to match |
| 210 // cursor state. | 218 // cursor state. |
| 211 Env::GetInstance()->SetCursorShown(show); | |
| 212 PostMouseMoveEventAfterWindowChange(); | 219 PostMouseMoveEventAfterWindowChange(); |
| 213 } | 220 } |
| 214 | 221 |
| 215 void RootWindow::MoveCursorTo(const gfx::Point& location_in_dip) { | 222 void RootWindow::MoveCursorTo(const gfx::Point& location_in_dip) { |
| 216 gfx::Point location = location_in_dip; | 223 gfx::Point location = location_in_dip; |
| 217 layer()->transform().TransformPoint(location); | 224 layer()->transform().TransformPoint(location); |
| 218 host_->MoveCursorTo(ui::ConvertPointToPixel(layer(), location)); | 225 host_->MoveCursorTo(ui::ConvertPointToPixel(layer(), location)); |
| 219 SetLastMouseLocation(this, location_in_dip); | 226 SetLastMouseLocation(this, location_in_dip); |
| 220 client::CursorClient* cursor_client = client::GetCursorClient(this); | 227 client::CursorClient* cursor_client = client::GetCursorClient(this); |
| 221 if (cursor_client) | 228 if (cursor_client) |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 } | 567 } |
| 561 | 568 |
| 562 void RootWindow::SetNativeCapture() { | 569 void RootWindow::SetNativeCapture() { |
| 563 host_->SetCapture(); | 570 host_->SetCapture(); |
| 564 } | 571 } |
| 565 | 572 |
| 566 void RootWindow::ReleaseNativeCapture() { | 573 void RootWindow::ReleaseNativeCapture() { |
| 567 host_->ReleaseCapture(); | 574 host_->ReleaseCapture(); |
| 568 } | 575 } |
| 569 | 576 |
| 570 gfx::Point RootWindow::QueryMouseLocationForTest() const { | 577 bool RootWindow::QueryMouseLocationForTest(gfx::Point* point) const { |
| 571 gfx::Point point; | 578 return host_->QueryMouseLocation(point); |
| 572 host_->QueryMouseLocation(&point); | |
| 573 return point; | |
| 574 } | 579 } |
| 575 | 580 |
| 576 //////////////////////////////////////////////////////////////////////////////// | 581 //////////////////////////////////////////////////////////////////////////////// |
| 577 // RootWindow, private: | 582 // RootWindow, private: |
| 578 | 583 |
| 579 void RootWindow::TransformEventForDeviceScaleFactor(ui::LocatedEvent* event) { | 584 void RootWindow::TransformEventForDeviceScaleFactor(ui::LocatedEvent* event) { |
| 580 float scale = ui::GetDeviceScaleFactor(layer()); | 585 float scale = ui::GetDeviceScaleFactor(layer()); |
| 581 gfx::Transform transform; | 586 gfx::Transform transform; |
| 582 transform.Scale(scale, scale); | 587 transform.Scale(scale, scale); |
| 583 transform *= layer()->transform(); | 588 transform *= layer()->transform(); |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 ui::MouseEvent event(ui::ET_MOUSE_MOVED, | 992 ui::MouseEvent event(ui::ET_MOUSE_MOVED, |
| 988 orig_mouse_location, | 993 orig_mouse_location, |
| 989 orig_mouse_location, | 994 orig_mouse_location, |
| 990 ui::EF_IS_SYNTHESIZED); | 995 ui::EF_IS_SYNTHESIZED); |
| 991 event.set_system_location(Env::GetInstance()->last_mouse_location()); | 996 event.set_system_location(Env::GetInstance()->last_mouse_location()); |
| 992 OnHostMouseEvent(&event); | 997 OnHostMouseEvent(&event); |
| 993 #endif | 998 #endif |
| 994 } | 999 } |
| 995 | 1000 |
| 996 } // namespace aura | 1001 } // namespace aura |
| OLD | NEW |