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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 if (dnd_client && dnd_client->IsDragDropInProgress()) | 224 if (dnd_client && dnd_client->IsDragDropInProgress()) |
225 cursor = dnd_client->GetDragCursor(); | 225 cursor = dnd_client->GetDragCursor(); |
226 | 226 |
227 last_cursor_ = cursor; | 227 last_cursor_ = cursor; |
228 // A lot of code seems to depend on NULL cursors actually showing an arrow, | 228 // A lot of code seems to depend on NULL cursors actually showing an arrow, |
229 // so just pass everything along to the host. | 229 // so just pass everything along to the host. |
230 host_->SetCursor(cursor); | 230 host_->SetCursor(cursor); |
231 } | 231 } |
232 | 232 |
233 void RootWindow::ShowCursor(bool show) { | 233 void RootWindow::ShowCursor(bool show) { |
234 cursor_shown_ = show; | 234 // Send entered / exited so that visual state can be updated to match |
235 host_->ShowCursor(show); | 235 // cursor state. |
236 if (show != cursor_shown_) { | |
237 cursor_shown_ = show; | |
238 host_->ShowCursor(show); | |
239 GetRootWindow()->SynthesizeMouseEvent(ui::ET_MOUSE_MOVED, show); | |
240 } | |
oshima
2012/08/06 03:24:24
I think it's better to change last_mouse_location
| |
236 } | 241 } |
237 | 242 |
238 void RootWindow::MoveCursorTo(const gfx::Point& location_in_dip) { | 243 void RootWindow::MoveCursorTo(const gfx::Point& location_in_dip) { |
239 gfx::Point location = location_in_dip; | 244 gfx::Point location = location_in_dip; |
240 layer()->transform().TransformPoint(location); | 245 layer()->transform().TransformPoint(location); |
241 host_->MoveCursorTo(ui::ConvertPointToPixel(layer(), location)); | 246 host_->MoveCursorTo(ui::ConvertPointToPixel(layer(), location)); |
242 SetLastMouseLocation(this, location_in_dip); | 247 SetLastMouseLocation(this, location_in_dip); |
243 } | 248 } |
244 | 249 |
245 bool RootWindow::ConfineCursorToWindow() { | 250 bool RootWindow::ConfineCursorToWindow() { |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1009 void RootWindow::PostMouseMoveEventAfterWindowChange() { | 1014 void RootWindow::PostMouseMoveEventAfterWindowChange() { |
1010 if (synthesize_mouse_move_) | 1015 if (synthesize_mouse_move_) |
1011 return; | 1016 return; |
1012 synthesize_mouse_move_ = true; | 1017 synthesize_mouse_move_ = true; |
1013 MessageLoop::current()->PostTask( | 1018 MessageLoop::current()->PostTask( |
1014 FROM_HERE, | 1019 FROM_HERE, |
1015 base::Bind(&RootWindow::SynthesizeMouseMoveEvent, | 1020 base::Bind(&RootWindow::SynthesizeMouseMoveEvent, |
1016 event_factory_.GetWeakPtr())); | 1021 event_factory_.GetWeakPtr())); |
1017 } | 1022 } |
1018 | 1023 |
1024 void RootWindow::SynthesizeMouseEvent(ui::EventType event_type, | |
1025 bool use_current_position) { | |
1026 #if !defined(OS_WIN) | |
1027 // Temporarily disabled for windows. See crbug.com/112222. | |
1028 gfx::Point previous_last_mouse_position = | |
1029 Env::GetInstance()->last_mouse_location(); | |
1030 | |
1031 gfx::Point3f point(use_current_position ? | |
1032 GetLastMouseLocationInRoot() : gfx::Point(-1, -1)); | |
oshima
2012/08/06 03:24:24
-1, -1 may still overlap a views' component. I'd s
| |
1033 ui::Transform transform = layer()->transform(); | |
1034 float scale = ui::GetDeviceScaleFactor(layer()); | |
1035 transform.ConcatScale(scale, scale); | |
1036 transform.TransformPoint(point); | |
1037 gfx::Point mouse_location = point.AsPoint(); | |
1038 | |
1039 // TODO(derat|oshima): Don't use mouse_button_flags_ as it's | |
1040 // currently broken. See/ crbug.com/107931. | |
1041 MouseEvent event(event_type, | |
1042 mouse_location, | |
1043 mouse_location, | |
1044 ui::EF_IS_SYNTHESIZED); | |
1045 OnHostMouseEvent(&event); | |
1046 SetLastMouseLocation(this, previous_last_mouse_position); | |
1047 #endif | |
1048 } | |
1049 | |
1019 void RootWindow::SynthesizeMouseMoveEvent() { | 1050 void RootWindow::SynthesizeMouseMoveEvent() { |
1020 if (!synthesize_mouse_move_) | 1051 if (!synthesize_mouse_move_) |
1021 return; | 1052 return; |
1022 synthesize_mouse_move_ = false; | 1053 synthesize_mouse_move_ = false; |
1023 #if !defined(OS_WIN) | 1054 SynthesizeMouseEvent(ui::ET_MOUSE_MOVED, true); |
1024 // Temporarily disabled for windows. See crbug.com/112222. | |
1025 gfx::Point3f point(GetLastMouseLocationInRoot()); | |
1026 ui::Transform transform = layer()->transform(); | |
1027 float scale = ui::GetDeviceScaleFactor(layer()); | |
1028 transform.ConcatScale(scale, scale); | |
1029 transform.TransformPoint(point); | |
1030 gfx::Point orig_mouse_location = point.AsPoint(); | |
1031 | |
1032 // TODO(derat|oshima): Don't use mouse_button_flags_ as it's | |
1033 // currently broken. See/ crbug.com/107931. | |
1034 MouseEvent event(ui::ET_MOUSE_MOVED, | |
1035 orig_mouse_location, | |
1036 orig_mouse_location, | |
1037 ui::EF_IS_SYNTHESIZED); | |
1038 OnHostMouseEvent(&event); | |
1039 #endif | |
1040 } | 1055 } |
1041 | 1056 |
1042 void RootWindow::UnlockCompositor() { | 1057 void RootWindow::UnlockCompositor() { |
1043 DCHECK(compositor_lock_); | 1058 DCHECK(compositor_lock_); |
1044 compositor_lock_ = NULL; | 1059 compositor_lock_ = NULL; |
1045 if (draw_on_compositor_unlock_) { | 1060 if (draw_on_compositor_unlock_) { |
1046 draw_on_compositor_unlock_ = false; | 1061 draw_on_compositor_unlock_ = false; |
1047 ScheduleDraw(); | 1062 ScheduleDraw(); |
1048 } | 1063 } |
1049 } | 1064 } |
1050 | 1065 |
1051 } // namespace aura | 1066 } // namespace aura |
OLD | NEW |