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

Unified Diff: ui/aura/root_window.cc

Issue 11035050: Enable CursorManager::LockCursor to lock cursor visibility. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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
Index: ui/aura/root_window.cc
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc
index 4af5464b43db93f6d3b62347309ef64674b9e2e5..3b36d693430ba37e4c539fe2c7a171f6c2edaeb1 100644
--- a/ui/aura/root_window.cc
+++ b/ui/aura/root_window.cc
@@ -124,9 +124,6 @@ RootWindow::RootWindow(const CreateParams& params)
mouse_button_flags_(0),
touch_ids_down_(0),
last_cursor_(ui::kCursorNull),
- // TODO(ivankr): this currently tracks the default state in
- // RootWindowHostLinux. Other platforms do not implement ShowCursor().
- cursor_shown_(true),
mouse_pressed_handler_(NULL),
mouse_moved_handler_(NULL),
mouse_event_dispatch_target_(NULL),
@@ -249,15 +246,11 @@ void RootWindow::SetCursor(gfx::NativeCursor cursor) {
host_->SetCursor(cursor);
}
-void RootWindow::ShowCursor(bool show) {
+void RootWindow::OnCursorVisibilityChanged(bool 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);
- Env::GetInstance()->SetCursorShown(show);
- PostMouseMoveEventAfterWindowChange();
- }
+ Env::GetInstance()->SetCursorShown(show);
+ PostMouseMoveEventAfterWindowChange();
}
void RootWindow::MoveCursorTo(const gfx::Point& location_in_dip) {
@@ -530,19 +523,23 @@ void RootWindow::OnDeviceScaleFactorChanged(
float device_scale_factor) {
const bool cursor_is_in_bounds =
GetBoundsInScreen().Contains(Env::GetInstance()->last_mouse_location());
- if (cursor_is_in_bounds && cursor_shown_)
- ShowCursor(false);
+ bool cursor_visible = false;
+ client::CursorClient* cursor_client = client::GetCursorClient(this);
+ if (cursor_is_in_bounds && cursor_client) {
+ cursor_visible = cursor_client->IsCursorVisible();
+ if (cursor_visible)
+ cursor_client->ShowCursor(false);
+ }
host_->OnDeviceScaleFactorChanged(device_scale_factor);
Window::OnDeviceScaleFactorChanged(device_scale_factor);
// Update the device scale factor of the cursor client only when the last
// mouse location is on this root window.
if (cursor_is_in_bounds) {
- client::CursorClient* cursor_client = client::GetCursorClient(this);
if (cursor_client)
cursor_client->SetDeviceScaleFactor(device_scale_factor);
}
- if (cursor_is_in_bounds && cursor_shown_)
- ShowCursor(true);
+ if (cursor_is_in_bounds && cursor_client && cursor_visible)
+ cursor_client->ShowCursor(true);
}
////////////////////////////////////////////////////////////////////////////////

Powered by Google App Engine
This is Rietveld 408576698