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 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 ui::MouseEvent event(ui::ET_MOUSE_MOVED, | 1045 ui::MouseEvent event(ui::ET_MOUSE_MOVED, |
1039 orig_mouse_location, | 1046 orig_mouse_location, |
1040 orig_mouse_location, | 1047 orig_mouse_location, |
1041 ui::EF_IS_SYNTHESIZED); | 1048 ui::EF_IS_SYNTHESIZED); |
1042 event.set_system_location(Env::GetInstance()->last_mouse_location()); | 1049 event.set_system_location(Env::GetInstance()->last_mouse_location()); |
1043 OnHostMouseEvent(&event); | 1050 OnHostMouseEvent(&event); |
1044 #endif | 1051 #endif |
1045 } | 1052 } |
1046 | 1053 |
1047 } // namespace aura | 1054 } // namespace aura |
OLD | NEW |