Commit 8ab613cf authored by oshima@chromium.org's avatar oshima@chromium.org

Use native coordinates to warp the cursor to another display.

This is roughly how this works.
- Takes the bounds of the edge indicator in screen coords
  and convert to native coords
- If the location of mouse in native coords moves into this
  bounds, we need to warp the mouse.
- Convert the current mouse location in screen coords to the
  destination window's host coords. Adjust so that the location is inside the host window's bounds.

No flag. I'll simply flip the flag if I need to disable this on branch.

BUG=321699,306632
TEST=TBD

Review URL: https://codereview.chromium.org/270863005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269758 0039d316-1c4b-4281-b951-d872f2087c98
parent bbd72ec9
...@@ -247,8 +247,6 @@ void DisplayController::Start() { ...@@ -247,8 +247,6 @@ void DisplayController::Start() {
new VirtualKeyboardWindowController); new VirtualKeyboardWindowController);
Shell::GetScreen()->AddObserver(this); Shell::GetScreen()->AddObserver(this);
Shell::GetInstance()->display_manager()->set_delegate(this); Shell::GetInstance()->display_manager()->set_delegate(this);
FOR_EACH_OBSERVER(Observer, observers_, OnDisplaysInitialized());
} }
void DisplayController::Shutdown() { void DisplayController::Shutdown() {
...@@ -294,6 +292,8 @@ void DisplayController::InitDisplays() { ...@@ -294,6 +292,8 @@ void DisplayController::InitDisplays() {
} }
} }
UpdateHostWindowNames(); UpdateHostWindowNames();
FOR_EACH_OBSERVER(Observer, observers_, OnDisplaysInitialized());
} }
void DisplayController::AddObserver(Observer* observer) { void DisplayController::AddObserver(Observer* observer) {
......
This diff is collapsed.
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define ASH_DISPLAY_MOUSE_CURSOR_EVENT_FILTER_H #define ASH_DISPLAY_MOUSE_CURSOR_EVENT_FILTER_H
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/display/display_controller.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
...@@ -18,13 +19,15 @@ class Window; ...@@ -18,13 +19,15 @@ class Window;
} }
namespace ash { namespace ash {
class DisplayController;
class SharedDisplayEdgeIndicator; class SharedDisplayEdgeIndicator;
// An event filter that controls mouse location in extended desktop // An event filter that controls mouse location in extended desktop
// environment. // environment.
class ASH_EXPORT MouseCursorEventFilter : public ui::EventHandler { class ASH_EXPORT MouseCursorEventFilter : public ui::EventHandler,
public DisplayController::Observer {
public: public:
static bool IsMouseWarpInNativeCoordsEnabled();
enum MouseWarpMode { enum MouseWarpMode {
WARP_ALWAYS, // Always warp the mouse when possible. WARP_ALWAYS, // Always warp the mouse when possible.
WARP_DRAG, // Used when dragging a window. Top and bottom WARP_DRAG, // Used when dragging a window. Top and bottom
...@@ -42,10 +45,14 @@ class ASH_EXPORT MouseCursorEventFilter : public ui::EventHandler { ...@@ -42,10 +45,14 @@ class ASH_EXPORT MouseCursorEventFilter : public ui::EventHandler {
// Shows/Hide the indicator for window dragging. The |from| // Shows/Hide the indicator for window dragging. The |from|
// is the window where the dragging started. // is the window where the dragging started.
void ShowSharedEdgeIndicator(const aura::Window* from); void ShowSharedEdgeIndicator(aura::Window* from);
void HideSharedEdgeIndicator(); void HideSharedEdgeIndicator();
// Overridden from ui::EventHandler: // DisplayController::Observer:
virtual void OnDisplaysInitialized() OVERRIDE;
virtual void OnDisplayConfigurationChanged() OVERRIDE;
// ui::EventHandler:
virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
private: private:
...@@ -59,20 +66,39 @@ class ASH_EXPORT MouseCursorEventFilter : public ui::EventHandler { ...@@ -59,20 +66,39 @@ class ASH_EXPORT MouseCursorEventFilter : public ui::EventHandler {
IndicatorBoundsTestOnLeft); IndicatorBoundsTestOnLeft);
FRIEND_TEST_ALL_PREFIXES(MouseCursorEventFilterTest, FRIEND_TEST_ALL_PREFIXES(MouseCursorEventFilterTest,
IndicatorBoundsTestOnTopBottom); IndicatorBoundsTestOnTopBottom);
FRIEND_TEST_ALL_PREFIXES(DragWindowResizerTest, WarpMousePointer); FRIEND_TEST_ALL_PREFIXES(MouseCursorEventFilterTest,
WarpMouseDifferentScaleDisplaysInNative);
void reset_was_mouse_warped_for_test() { was_mouse_warped_ = false; } FRIEND_TEST_ALL_PREFIXES(DragWindowResizerTest, WarpMousePointer);
// Warps the mouse cursor to an alternate root window when the // Warps the mouse cursor to an alternate root window when the
// |point_in_screen|, which is the location of the mouse cursor, // mouse location in |event|, hits the edge of the event target's root and
// hits or exceeds the edge of the |target_root| and the mouse cursor // the mouse cursor is considered to be in an alternate display.
// is considered to be in an alternate display. Returns true if // Returns true if/ the cursor was moved.
// the cursor was moved. bool WarpMouseCursorIfNecessary(ui::MouseEvent* event);
bool WarpMouseCursorIfNecessary(aura::Window* target_root,
const gfx::Point& point_in_screen); bool WarpMouseCursorInNativeCoords(const gfx::Point& point_in_native,
const gfx::Point& point_in_screen);
bool WarpMouseCursorInScreenCoords(aura::Window* target_root,
const gfx::Point& point_in_screen);
// Update the edge/indicator bounds based on the current
// display configuration.
void UpdateHorizontalEdgeBounds();
void UpdateVerticalEdgeBounds();
// Returns the source and destination window. When the
// mouse_warp_mode_ is WARP_DRAG, src_window is the root window
// where the drag starts. When the mouse_warp_mode_ is WARP_ALWAYS,
// the src_window is always the primary root window, because there
// is no difference between moving src to dst and moving dst to src.
void GetSrcAndDstRootWindows(aura::Window** src_window,
aura::Window** dst_window);
void reset_was_mouse_warped_for_test() { was_mouse_warped_ = false; }
void UpdateHorizontalIndicatorWindowBounds(); bool WarpMouseCursorIfNecessaryForTest(aura::Window* target_root,
void UpdateVerticalIndicatorWindowBounds(); const gfx::Point& point_in_screen);
MouseWarpMode mouse_warp_mode_; MouseWarpMode mouse_warp_mode_;
...@@ -85,8 +111,11 @@ class ASH_EXPORT MouseCursorEventFilter : public ui::EventHandler { ...@@ -85,8 +111,11 @@ class ASH_EXPORT MouseCursorEventFilter : public ui::EventHandler {
gfx::Rect src_indicator_bounds_; gfx::Rect src_indicator_bounds_;
gfx::Rect dst_indicator_bounds_; gfx::Rect dst_indicator_bounds_;
gfx::Rect src_edge_bounds_in_native_;
gfx::Rect dst_edge_bounds_in_native_;
// The root window in which the dragging started. // The root window in which the dragging started.
const aura::Window* drag_source_root_; aura::Window* drag_source_root_;
float scale_when_drag_started_; float scale_when_drag_started_;
......
...@@ -28,7 +28,7 @@ class MouseCursorEventFilterTest : public test::AshTestBase { ...@@ -28,7 +28,7 @@ class MouseCursorEventFilterTest : public test::AshTestBase {
bool WarpMouseCursorIfNecessary(aura::Window* target_root, bool WarpMouseCursorIfNecessary(aura::Window* target_root,
gfx::Point point_in_screen) { gfx::Point point_in_screen) {
bool is_warped = event_filter()->WarpMouseCursorIfNecessary( bool is_warped = event_filter()->WarpMouseCursorIfNecessaryForTest(
target_root, point_in_screen); target_root, point_in_screen);
event_filter()->reset_was_mouse_warped_for_test(); event_filter()->reset_was_mouse_warped_for_test();
return is_warped; return is_warped;
...@@ -43,7 +43,7 @@ class MouseCursorEventFilterTest : public test::AshTestBase { ...@@ -43,7 +43,7 @@ class MouseCursorEventFilterTest : public test::AshTestBase {
location, 0, 0); location, 0, 0);
ui::Event::DispatcherApi(&pressed).set_target(drag_source_root); ui::Event::DispatcherApi(&pressed).set_target(drag_source_root);
event_filter()->OnMouseEvent(&pressed); event_filter()->OnMouseEvent(&pressed);
bool is_warped = event_filter()->WarpMouseCursorIfNecessary( bool is_warped = event_filter()->WarpMouseCursorIfNecessaryForTest(
target_root, point_in_screen); target_root, point_in_screen);
event_filter()->reset_was_mouse_warped_for_test(); event_filter()->reset_was_mouse_warped_for_test();
...@@ -127,16 +127,19 @@ TEST_F(MouseCursorEventFilterTest, WarpMouseDifferentSizeDisplays) { ...@@ -127,16 +127,19 @@ TEST_F(MouseCursorEventFilterTest, WarpMouseDifferentSizeDisplays) {
aura::Env::GetInstance()->last_mouse_location().ToString()); aura::Env::GetInstance()->last_mouse_location().ToString());
// Touch the left edge of the secondary root window. Pointer should warp // Touch the left edge of the secondary root window. Pointer should warp
// because 1px left of (0, 499) is inside the primary root window. // because 1px left of (0, 480) is inside the primary root window.
EXPECT_TRUE(WarpMouseCursorIfNecessary(root_windows[1], EXPECT_TRUE(
gfx::Point(500, 499))); WarpMouseCursorIfNecessary(root_windows[1], gfx::Point(500, 480)));
EXPECT_EQ("498,499", // by 2px. EXPECT_EQ("498,480", // by 2px.
aura::Env::GetInstance()->last_mouse_location().ToString()); aura::Env::GetInstance()->last_mouse_location().ToString());
} }
// Verifies if the mouse pointer correctly moves between displays with // Verifies if the mouse pointer correctly moves between displays with
// different scale factors. // different scale factors.
TEST_F(MouseCursorEventFilterTest, WarpMouseDifferentScaleDisplays) { TEST_F(MouseCursorEventFilterTest, WarpMouseDifferentScaleDisplays) {
if (MouseCursorEventFilter::IsMouseWarpInNativeCoordsEnabled())
return;
if (!SupportsMultipleDisplays()) if (!SupportsMultipleDisplays())
return; return;
...@@ -179,7 +182,46 @@ TEST_F(MouseCursorEventFilterTest, WarpMouseDifferentScaleDisplays) { ...@@ -179,7 +182,46 @@ TEST_F(MouseCursorEventFilterTest, WarpMouseDifferentScaleDisplays) {
aura::Env::GetInstance()->last_mouse_location().ToString()); aura::Env::GetInstance()->last_mouse_location().ToString());
} }
// Verifies if the mouse pointer correctly moves between displays with
// different scale factors. In native coords mode, there is no
// difference between drag and move.
TEST_F(MouseCursorEventFilterTest, WarpMouseDifferentScaleDisplaysInNative) {
if (!MouseCursorEventFilter::IsMouseWarpInNativeCoordsEnabled())
return;
if (!SupportsMultipleDisplays())
return;
UpdateDisplay("500x500,600x600*2");
ASSERT_EQ(DisplayLayout::RIGHT,
Shell::GetInstance()
->display_manager()
->GetCurrentDisplayLayout()
.position);
aura::Window::Windows root_windows = Shell::GetAllRootWindows();
aura::Env::GetInstance()->set_last_mouse_location(gfx::Point(900, 123));
EXPECT_TRUE(event_filter()->WarpMouseCursorIfNecessaryForTest(
root_windows[0], gfx::Point(499, 123)));
EXPECT_EQ("500,123",
aura::Env::GetInstance()->last_mouse_location().ToString());
event_filter()->reset_was_mouse_warped_for_test();
// Touch the edge of 2nd display again and make sure it warps to
// 1st dislay.
EXPECT_TRUE(event_filter()->WarpMouseCursorIfNecessaryForTest(
root_windows[1], gfx::Point(500, 123)));
EXPECT_EQ("498,123",
aura::Env::GetInstance()->last_mouse_location().ToString());
}
TEST_F(MouseCursorEventFilterTest, DoNotWarpTwice) { TEST_F(MouseCursorEventFilterTest, DoNotWarpTwice) {
if (MouseCursorEventFilter::IsMouseWarpInNativeCoordsEnabled())
return;
if (!SupportsMultipleDisplays()) if (!SupportsMultipleDisplays())
return; return;
...@@ -189,20 +231,20 @@ TEST_F(MouseCursorEventFilterTest, DoNotWarpTwice) { ...@@ -189,20 +231,20 @@ TEST_F(MouseCursorEventFilterTest, DoNotWarpTwice) {
aura::Env::GetInstance()->set_last_mouse_location(gfx::Point(623, 123)); aura::Env::GetInstance()->set_last_mouse_location(gfx::Point(623, 123));
// Touch the right edge of the primary root window. Pointer should warp. // Touch the right edge of the primary root window. Pointer should warp.
EXPECT_TRUE(event_filter()->WarpMouseCursorIfNecessary(root_windows[0], EXPECT_TRUE(event_filter()->WarpMouseCursorIfNecessaryForTest(
gfx::Point(499, 11))); root_windows[0], gfx::Point(499, 11)));
EXPECT_EQ("501,11", // by 2px. EXPECT_EQ("501,11", // by 2px.
aura::Env::GetInstance()->last_mouse_location().ToString()); aura::Env::GetInstance()->last_mouse_location().ToString());
// Touch the left edge of the secondary root window immediately. This should // Touch the left edge of the secondary root window immediately. This should
// be ignored. // be ignored.
EXPECT_FALSE(event_filter()->WarpMouseCursorIfNecessary(root_windows[1], EXPECT_FALSE(event_filter()->WarpMouseCursorIfNecessaryForTest(
gfx::Point(500, 11))); root_windows[1], gfx::Point(500, 11)));
// Touch the left edge of the secondary root window again, pointer should // Touch the left edge of the secondary root window again, pointer should
// warp for this time. // warp for this time.
EXPECT_TRUE(event_filter()->WarpMouseCursorIfNecessary(root_windows[1], EXPECT_TRUE(event_filter()->WarpMouseCursorIfNecessaryForTest(
gfx::Point(500, 11))); root_windows[1], gfx::Point(500, 11)));
EXPECT_EQ("498,11", // by 2px. EXPECT_EQ("498,11", // by 2px.
aura::Env::GetInstance()->last_mouse_location().ToString()); aura::Env::GetInstance()->last_mouse_location().ToString());
} }
......
...@@ -47,6 +47,10 @@ void AshRemoteWindowTreeHostWin::SetRootWindowTransformer( ...@@ -47,6 +47,10 @@ void AshRemoteWindowTreeHostWin::SetRootWindowTransformer(
transformer_helper_.SetRootWindowTransformer(transformer.Pass()); transformer_helper_.SetRootWindowTransformer(transformer.Pass());
} }
gfx::Insets AshRemoteWindowTreeHostWin::GetHostInsets() const {
return gfx::Insets();
}
aura::WindowTreeHost* AshRemoteWindowTreeHostWin::AsWindowTreeHost() { aura::WindowTreeHost* AshRemoteWindowTreeHostWin::AsWindowTreeHost() {
return this; return this;
} }
......
...@@ -35,6 +35,7 @@ class ASH_EXPORT AshRemoteWindowTreeHostWin ...@@ -35,6 +35,7 @@ class ASH_EXPORT AshRemoteWindowTreeHostWin
virtual void UnConfineCursor() OVERRIDE; virtual void UnConfineCursor() OVERRIDE;
virtual void SetRootWindowTransformer( virtual void SetRootWindowTransformer(
scoped_ptr<RootWindowTransformer> transformer) OVERRIDE; scoped_ptr<RootWindowTransformer> transformer) OVERRIDE;
virtual gfx::Insets GetHostInsets() const OVERRIDE;
virtual aura::WindowTreeHost* AsWindowTreeHost() OVERRIDE; virtual aura::WindowTreeHost* AsWindowTreeHost() OVERRIDE;
// WindowTreeHostWin: // WindowTreeHostWin:
......
...@@ -14,6 +14,7 @@ class WindowTreeHost; ...@@ -14,6 +14,7 @@ class WindowTreeHost;
} }
namespace gfx { namespace gfx {
class Insets;
class Rect; class Rect;
} }
...@@ -41,6 +42,8 @@ class ASH_EXPORT AshWindowTreeHost { ...@@ -41,6 +42,8 @@ class ASH_EXPORT AshWindowTreeHost {
virtual void SetRootWindowTransformer( virtual void SetRootWindowTransformer(
scoped_ptr<RootWindowTransformer> transformer) = 0; scoped_ptr<RootWindowTransformer> transformer) = 0;
virtual gfx::Insets GetHostInsets() const = 0;
virtual aura::WindowTreeHost* AsWindowTreeHost() = 0; virtual aura::WindowTreeHost* AsWindowTreeHost() = 0;
}; };
......
...@@ -71,6 +71,9 @@ class ASH_EXPORT AshWindowTreeHostWin : public AshWindowTreeHost, ...@@ -71,6 +71,9 @@ class ASH_EXPORT AshWindowTreeHostWin : public AshWindowTreeHost,
scoped_ptr<RootWindowTransformer> transformer) { scoped_ptr<RootWindowTransformer> transformer) {
transformer_helper_.SetRootWindowTransformer(transformer.Pass()); transformer_helper_.SetRootWindowTransformer(transformer.Pass());
} }
virtual gfx::Insets GetHostInsets() const OVERRIDE {
return transformer_helper_.GetHostInsets();
}
virtual aura::WindowTreeHost* AsWindowTreeHost() OVERRIDE { return this; } virtual aura::WindowTreeHost* AsWindowTreeHost() OVERRIDE { return this; }
// WindowTreeHostWin: // WindowTreeHostWin:
......
...@@ -254,6 +254,10 @@ void AshWindowTreeHostX11::SetRootWindowTransformer( ...@@ -254,6 +254,10 @@ void AshWindowTreeHostX11::SetRootWindowTransformer(
} }
} }
gfx::Insets AshWindowTreeHostX11::GetHostInsets() const {
return transformer_helper_.GetHostInsets();
}
aura::WindowTreeHost* AshWindowTreeHostX11::AsWindowTreeHost() { return this; } aura::WindowTreeHost* AshWindowTreeHostX11::AsWindowTreeHost() { return this; }
void AshWindowTreeHostX11::SetBounds(const gfx::Rect& bounds) { void AshWindowTreeHostX11::SetBounds(const gfx::Rect& bounds) {
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
namespace ash { namespace ash {
class RootWindowTransformer; class RootWindowTransformer;
class MouseCursorEventFilter;
class ASH_EXPORT AshWindowTreeHostX11 : public AshWindowTreeHost, class ASH_EXPORT AshWindowTreeHostX11 : public AshWindowTreeHost,
public aura::WindowTreeHostX11, public aura::WindowTreeHostX11,
...@@ -29,6 +30,7 @@ class ASH_EXPORT AshWindowTreeHostX11 : public AshWindowTreeHost, ...@@ -29,6 +30,7 @@ class ASH_EXPORT AshWindowTreeHostX11 : public AshWindowTreeHost,
virtual void UnConfineCursor() OVERRIDE; virtual void UnConfineCursor() OVERRIDE;
virtual void SetRootWindowTransformer( virtual void SetRootWindowTransformer(
scoped_ptr<RootWindowTransformer> transformer) OVERRIDE; scoped_ptr<RootWindowTransformer> transformer) OVERRIDE;
virtual gfx::Insets GetHostInsets() const OVERRIDE;
virtual aura::WindowTreeHost* AsWindowTreeHost() OVERRIDE; virtual aura::WindowTreeHost* AsWindowTreeHost() OVERRIDE;
// aura::WindowTreehost: // aura::WindowTreehost:
......
...@@ -663,8 +663,7 @@ Shell::~Shell() { ...@@ -663,8 +663,7 @@ Shell::~Shell() {
RemovePostTargetHandler(toplevel_window_event_handler_.get()); RemovePostTargetHandler(toplevel_window_event_handler_.get());
RemovePreTargetHandler(system_gesture_filter_.get()); RemovePreTargetHandler(system_gesture_filter_.get());
RemovePreTargetHandler(keyboard_metrics_filter_.get()); RemovePreTargetHandler(keyboard_metrics_filter_.get());
if (mouse_cursor_filter_) RemovePreTargetHandler(mouse_cursor_filter_.get());
RemovePreTargetHandler(mouse_cursor_filter_.get());
// TooltipController is deleted with the Shell so removing its references. // TooltipController is deleted with the Shell so removing its references.
RemovePreTargetHandler(tooltip_controller_.get()); RemovePreTargetHandler(tooltip_controller_.get());
...@@ -755,6 +754,7 @@ Shell::~Shell() { ...@@ -755,6 +754,7 @@ Shell::~Shell() {
resolution_notification_controller_.reset(); resolution_notification_controller_.reset();
#endif #endif
desktop_background_controller_.reset(); desktop_background_controller_.reset();
mouse_cursor_filter_.reset();
// This also deletes all RootWindows. Note that we invoke Shutdown() on // This also deletes all RootWindows. Note that we invoke Shutdown() on
// DisplayController before resetting |display_controller_|, since destruction // DisplayController before resetting |display_controller_|, since destruction
......
...@@ -31,7 +31,7 @@ aura::Window* GetRootWindowMatching(const gfx::Rect& rect) { ...@@ -31,7 +31,7 @@ aura::Window* GetRootWindowMatching(const gfx::Rect& rect) {
GetRootWindowForDisplayId(display.id()); GetRootWindowForDisplayId(display.id());
} }
void ConvertPointToScreen(aura::Window* window, gfx::Point* point) { void ConvertPointToScreen(const aura::Window* window, gfx::Point* point) {
CHECK(window); CHECK(window);
CHECK(window->GetRootWindow()); CHECK(window->GetRootWindow());
CHECK(aura::client::GetScreenPositionClient(window->GetRootWindow())); CHECK(aura::client::GetScreenPositionClient(window->GetRootWindow()));
...@@ -39,7 +39,7 @@ void ConvertPointToScreen(aura::Window* window, gfx::Point* point) { ...@@ -39,7 +39,7 @@ void ConvertPointToScreen(aura::Window* window, gfx::Point* point) {
ConvertPointToScreen(window, point); ConvertPointToScreen(window, point);
} }
void ConvertPointFromScreen(aura::Window* window, void ConvertPointFromScreen(const aura::Window* window,
gfx::Point* point_in_screen) { gfx::Point* point_in_screen) {
aura::client::GetScreenPositionClient(window->GetRootWindow())-> aura::client::GetScreenPositionClient(window->GetRootWindow())->
ConvertPointFromScreen(window, point_in_screen); ConvertPointFromScreen(window, point_in_screen);
......
...@@ -30,11 +30,12 @@ ASH_EXPORT aura::Window* GetRootWindowMatching(const gfx::Rect& rect); ...@@ -30,11 +30,12 @@ ASH_EXPORT aura::Window* GetRootWindowMatching(const gfx::Rect& rect);
// Converts the |point| from a given |window|'s coordinates into the screen // Converts the |point| from a given |window|'s coordinates into the screen
// coordinates. // coordinates.
ASH_EXPORT void ConvertPointToScreen(aura::Window* window, gfx::Point* point); ASH_EXPORT void ConvertPointToScreen(const aura::Window* window,
gfx::Point* point);
// Converts the |point| from the screen coordinates to a given |window|'s // Converts the |point| from the screen coordinates to a given |window|'s
// coordinates. // coordinates.
ASH_EXPORT void ConvertPointFromScreen(aura::Window* window, ASH_EXPORT void ConvertPointFromScreen(const aura::Window* window,
gfx::Point* point_in_screen); gfx::Point* point_in_screen);
} // namespace wm } // namespace wm
......
...@@ -125,8 +125,8 @@ class DragWindowResizerTest : public test::AshTestBase { ...@@ -125,8 +125,8 @@ class DragWindowResizerTest : public test::AshTestBase {
const gfx::Point& point_in_screen) { const gfx::Point& point_in_screen) {
MouseCursorEventFilter* event_filter = MouseCursorEventFilter* event_filter =
Shell::GetInstance()->mouse_cursor_filter(); Shell::GetInstance()->mouse_cursor_filter();
bool is_warped = event_filter->WarpMouseCursorIfNecessary(target_root, bool is_warped = event_filter->WarpMouseCursorIfNecessaryForTest(
point_in_screen); target_root, point_in_screen);
event_filter->reset_was_mouse_warped_for_test(); event_filter->reset_was_mouse_warped_for_test();
return is_warped; return is_warped;
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "ash/wm/immersive_fullscreen_controller.h" #include "ash/wm/immersive_fullscreen_controller.h"
#include "ash/display/display_manager.h" #include "ash/display/display_manager.h"
#include "ash/display/mouse_cursor_event_filter.h"
#include "ash/root_window_controller.h" #include "ash/root_window_controller.h"
#include "ash/shelf/shelf_layout_manager.h" #include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_types.h" #include "ash/shelf/shelf_types.h"
...@@ -540,8 +541,12 @@ TEST_F(ImmersiveFullscreenControllerTest, MouseEventsVerticalDisplayLayout) { ...@@ -540,8 +541,12 @@ TEST_F(ImmersiveFullscreenControllerTest, MouseEventsVerticalDisplayLayout) {
// edge even though the mouse is warped to the secondary display. // edge even though the mouse is warped to the secondary display.
event_generator.MoveMouseTo(x, y_top_edge); event_generator.MoveMouseTo(x, y_top_edge);
EXPECT_TRUE(top_edge_hover_timer_running()); EXPECT_TRUE(top_edge_hover_timer_running());
EXPECT_NE(y_top_edge,
aura::Env::GetInstance()->last_mouse_location().y()); // TODO(oshima): Provide a test API to handle mouse warp more easily.
if (!MouseCursorEventFilter::IsMouseWarpInNativeCoordsEnabled()) {
EXPECT_NE(y_top_edge,
aura::Env::GetInstance()->last_mouse_location().y());
}
// The timer should continue running if the user overshoots the top edge // The timer should continue running if the user overshoots the top edge
// a bit. // a bit.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment