Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(512)

Unified Diff: ui/aura/root_window.cc

Issue 10829180: Move cursor when it's hidden so that UX can update correctly (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added test Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura/root_window.h ('k') | ui/aura/root_window_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/root_window.cc
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc
index d7fb311be6419908602e5bff51d1fb109d8a2c59..da96dd28a37978c3fc928fd003e3c5a3700283c6 100644
--- a/ui/aura/root_window.cc
+++ b/ui/aura/root_window.cc
@@ -231,8 +231,13 @@ void RootWindow::SetCursor(gfx::NativeCursor cursor) {
}
void RootWindow::ShowCursor(bool show) {
- cursor_shown_ = show;
- host_->ShowCursor(show);
+ // Send entered / exited so that visual state can be updated to match
+ // cursor state.
+ if (show != cursor_shown_) {
+ cursor_shown_ = show;
+ host_->ShowCursor(show);
+ GetRootWindow()->SynthesizeMouseEvent(ui::ET_MOUSE_MOVED, show);
+ }
oshima 2012/08/06 03:24:24 I think it's better to change last_mouse_location
}
void RootWindow::MoveCursorTo(const gfx::Point& location_in_dip) {
@@ -1016,29 +1021,39 @@ void RootWindow::PostMouseMoveEventAfterWindowChange() {
event_factory_.GetWeakPtr()));
}
-void RootWindow::SynthesizeMouseMoveEvent() {
- if (!synthesize_mouse_move_)
- return;
- synthesize_mouse_move_ = false;
+void RootWindow::SynthesizeMouseEvent(ui::EventType event_type,
+ bool use_current_position) {
#if !defined(OS_WIN)
// Temporarily disabled for windows. See crbug.com/112222.
- gfx::Point3f point(GetLastMouseLocationInRoot());
+ gfx::Point previous_last_mouse_position =
+ Env::GetInstance()->last_mouse_location();
+
+ gfx::Point3f point(use_current_position ?
+ GetLastMouseLocationInRoot() : gfx::Point(-1, -1));
oshima 2012/08/06 03:24:24 -1, -1 may still overlap a views' component. I'd s
ui::Transform transform = layer()->transform();
float scale = ui::GetDeviceScaleFactor(layer());
transform.ConcatScale(scale, scale);
transform.TransformPoint(point);
- gfx::Point orig_mouse_location = point.AsPoint();
+ gfx::Point mouse_location = point.AsPoint();
// TODO(derat|oshima): Don't use mouse_button_flags_ as it's
// currently broken. See/ crbug.com/107931.
- MouseEvent event(ui::ET_MOUSE_MOVED,
- orig_mouse_location,
- orig_mouse_location,
+ MouseEvent event(event_type,
+ mouse_location,
+ mouse_location,
ui::EF_IS_SYNTHESIZED);
OnHostMouseEvent(&event);
+ SetLastMouseLocation(this, previous_last_mouse_position);
#endif
}
+void RootWindow::SynthesizeMouseMoveEvent() {
+ if (!synthesize_mouse_move_)
+ return;
+ synthesize_mouse_move_ = false;
+ SynthesizeMouseEvent(ui::ET_MOUSE_MOVED, true);
+}
+
void RootWindow::UnlockCompositor() {
DCHECK(compositor_lock_);
compositor_lock_ = NULL;
« no previous file with comments | « ui/aura/root_window.h ('k') | ui/aura/root_window_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698