summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authoroshima <oshima@chromium.org>2015-08-04 19:35:39 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-05 02:37:05 +0000
commit81d7fbe3dc3551cb86e6ced46e35c8985ec931b8 (patch)
tree5df9a761b2d0dd7632f11ba8e796fb0078f45283 /ash
parent3d2e44fe0e7994b083504c249b654e20d76228e0 (diff)
downloadchromium_src-81d7fbe3dc3551cb86e6ced46e35c8985ec931b8.zip
chromium_src-81d7fbe3dc3551cb86e6ced46e35c8985ec931b8.tar.gz
chromium_src-81d7fbe3dc3551cb86e6ced46e35c8985ec931b8.tar.bz2
Unified desktop: update cursor when crossing displays using the mirroring display's info
BUG=514877 R=mukai@chromium.org TEST=manual. I'm still working on improve EventGenerator and will add test in a separate CL. Review URL: https://codereview.chromium.org/1264573005 Cr-Commit-Position: refs/heads/master@{#341846}
Diffstat (limited to 'ash')
-rw-r--r--ash/display/unified_mouse_warp_controller.cc29
-rw-r--r--ash/display/unified_mouse_warp_controller.h2
2 files changed, 29 insertions, 2 deletions
diff --git a/ash/display/unified_mouse_warp_controller.cc b/ash/display/unified_mouse_warp_controller.cc
index 13f58d3..7ee731485 100644
--- a/ash/display/unified_mouse_warp_controller.cc
+++ b/ash/display/unified_mouse_warp_controller.cc
@@ -12,6 +12,7 @@
#include "ash/display/window_tree_host_manager.h"
#include "ash/host/ash_window_tree_host.h"
#include "ash/shell.h"
+#include "ui/aura/client/cursor_client.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/layout.h"
@@ -49,8 +50,8 @@ aura::WindowTreeHost* FindMirroringWindowTreeHostFromScreenPoint(
} // namespace
UnifiedMouseWarpController::UnifiedMouseWarpController()
- : allow_non_native_event_(false) {
-}
+ : current_cursor_display_id_(gfx::Display::kInvalidDisplayID),
+ allow_non_native_event_(false) {}
UnifiedMouseWarpController::~UnifiedMouseWarpController() {
}
@@ -68,6 +69,26 @@ bool UnifiedMouseWarpController::WarpMouseCursor(ui::MouseEvent* event) {
// transform back to the host coordinates.
target->GetHost()->GetRootTransform().TransformPoint(&point_in_unified_host);
+ if (current_cursor_display_id_ != gfx::Display::kInvalidDisplayID) {
+ aura::client::CursorClient* cursor_client =
+ aura::client::GetCursorClient(target->GetRootWindow());
+ if (cursor_client) {
+ DisplayManager::DisplayList mirroring_display_list =
+ Shell::GetInstance()
+ ->display_manager()
+ ->software_mirroring_display_list();
+ int index = FindDisplayIndexContainingPoint(mirroring_display_list,
+ point_in_unified_host);
+ if (index >= 0) {
+ const gfx::Display& new_display = mirroring_display_list[index];
+ if (current_cursor_display_id_ != new_display.id()) {
+ cursor_client->SetDisplay(new_display);
+ current_cursor_display_id_ = gfx::Display::kInvalidDisplayID;
+ }
+ }
+ }
+ }
+
// A native event may not exist in unit test. Generate the native point
// from the screen point instead.
if (!event->HasNativeEvent()) {
@@ -144,6 +165,10 @@ bool UnifiedMouseWarpController::WarpMouseCursorInNativeCoords(
Shell::GetInstance()
->display_manager()
->software_mirroring_display_list();
+ // Wait updating the cursor until the cursor moves to the new display
+ // to avoid showing the wrong sized cursor at the source display.
+ current_cursor_display_id_ =
+ in_first_edge ? display_list[0].id() : display_list[1].id();
AshWindowTreeHost* target_ash_host =
GetMirroringAshWindowTreeHostForDisplayId(
in_first_edge ? display_list[1].id() : display_list[0].id());
diff --git a/ash/display/unified_mouse_warp_controller.h b/ash/display/unified_mouse_warp_controller.h
index 8fc749c..696dd9c2 100644
--- a/ash/display/unified_mouse_warp_controller.h
+++ b/ash/display/unified_mouse_warp_controller.h
@@ -53,6 +53,8 @@ class ASH_EXPORT UnifiedMouseWarpController : public MouseWarpController {
gfx::Rect first_edge_bounds_in_native_;
gfx::Rect second_edge_bounds_in_native_;
+ int64 current_cursor_display_id_;
+
bool allow_non_native_event_;
DISALLOW_COPY_AND_ASSIGN(UnifiedMouseWarpController);