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

Unified Diff: ash/display/display_controller.cc

Issue 902123002: Fix initial hiding and centering cursor on Ozone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 | « ash/display/display_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/display/display_controller.cc
diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc
index 7a3b6f9959daef8f7b0067eec767a425a89924be..132d68a47cec845d0e11f10751edf285517566d9 100644
--- a/ash/display/display_controller.cc
+++ b/ash/display/display_controller.cc
@@ -39,6 +39,7 @@
#include "ui/compositor/compositor_vsync_manager.h"
#include "ui/gfx/display.h"
#include "ui/gfx/screen.h"
+#include "ui/wm/core/coordinate_conversion.h"
#include "ui/wm/public/activation_client.h"
#if defined(OS_CHROMEOS)
@@ -569,18 +570,39 @@ void DisplayController::EnsurePointerInDisplays() {
if (closest_distance_squared < 0 ||
closest_distance_squared > distance_squared) {
aura::Window* root_window = GetRootWindowForDisplayId(display.id());
- aura::client::ScreenPositionClient* client =
- aura::client::GetScreenPositionClient(root_window);
- client->ConvertPointFromScreen(root_window, &center);
+ ::wm::ConvertPointFromScreen(root_window, &center);
root_window->GetHost()->ConvertPointToNativeScreen(&center);
dst_root_window = root_window;
target_location_in_native = center;
closest_distance_squared = distance_squared;
}
}
+
+ gfx::Point target_location_in_root = target_location_in_native;
dst_root_window->GetHost()->ConvertPointFromNativeScreen(
- &target_location_in_native);
- dst_root_window->MoveCursorTo(target_location_in_native);
+ &target_location_in_root);
+
+#if defined(USE_OZONE)
+ gfx::Point target_location_in_screen = target_location_in_root;
+ ::wm::ConvertPointToScreen(dst_root_window, &target_location_in_root);
Jun Mukai 2015/02/18 23:14:21 &target_location_in_screen?
pkotwicz 2015/02/19 01:01:17 Thanks for noticing!
+
+ // Do not move the cursor if the cursor's location did not change. This avoids
+ // moving (and showing) the cursor on startup.
+ // |cursor_location_in_native_coords_for_restore_| may refer to a different
+ // display than when it was set. This occurs when swapping the primary
+ // display. Ozone takes care of moving the cursor in this case.
+ if (target_location_in_native !=
+ cursor_location_in_native_coords_for_restore_ ||
+ target_location_in_screen !=
+ cursor_location_in_screen_coords_for_restore_) {
Jun Mukai 2015/02/18 23:14:21 EnsurePointerInDisplay ensures mouse left outside
pkotwicz 2015/02/19 01:01:17 In some cases we still need to call WindowTreeHost
Jun Mukai 2015/02/19 01:50:06 Aah, right. thanks.
+ dst_root_window->MoveCursorTo(target_location_in_root);
+ }
+#else
+ // X11 does not move the cursor if
+ // |cursor_location_in_native_coords_for_restore_| refers to a different
+ // display than when it was set.
+ dst_root_window->MoveCursorTo(target_location_in_root);
+#endif
}
bool DisplayController::UpdateWorkAreaOfDisplayNearestWindow(
@@ -713,14 +735,14 @@ void DisplayController::PreDisplayConfigurationChange(bool clear_focus) {
focus_activation_store_->Store(clear_focus);
gfx::Screen* screen = Shell::GetScreen();
gfx::Point point_in_screen = screen->GetCursorScreenPoint();
+ cursor_location_in_screen_coords_for_restore_ = point_in_screen;
+
+ gfx::Point point_in_native = point_in_screen;
gfx::Display display = screen->GetDisplayNearestPoint(point_in_screen);
aura::Window* root_window = GetRootWindowForDisplayId(display.id());
-
- aura::client::ScreenPositionClient* client =
- aura::client::GetScreenPositionClient(root_window);
- client->ConvertPointFromScreen(root_window, &point_in_screen);
- root_window->GetHost()->ConvertPointToNativeScreen(&point_in_screen);
- cursor_location_in_native_coords_for_restore_ = point_in_screen;
+ ::wm::ConvertPointFromScreen(root_window, &point_in_native);
+ root_window->GetHost()->ConvertPointToNativeScreen(&point_in_native);
+ cursor_location_in_native_coords_for_restore_ = point_in_native;
}
void DisplayController::PostDisplayConfigurationChange() {
« no previous file with comments | « ash/display/display_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698