Commit fb0a4212 authored by jdufault's avatar jdufault Committed by Commit bot

Support moving the cursor and dragging windows to 3+ displays.

BUG=573289

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

Cr-Commit-Position: refs/heads/master@{#370794}
parent 67979c2e
......@@ -7,6 +7,9 @@
#include "ash/display/mouse_warp_controller.h"
#include <vector>
#include "ash/display/display_layout.h"
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
......@@ -18,6 +21,7 @@ class Window;
namespace gfx {
class Point;
class Display;
}
namespace ash {
......@@ -44,6 +48,47 @@ class ASH_EXPORT ExtendedMouseWarpController : public MouseWarpController {
IndicatorBoundsTestOnLeft);
FRIEND_TEST_ALL_PREFIXES(ExtendedMouseWarpControllerTest,
IndicatorBoundsTestOnTopBottom);
FRIEND_TEST_ALL_PREFIXES(ExtendedMouseWarpControllerTest,
IndicatorBoundsTestThreeDisplays);
// Defined in header file because tests need access.
struct WarpRegion {
public:
WarpRegion(int64_t a_display_id,
int64_t b_display_id,
const gfx::Rect& a_indicator_bounds,
const gfx::Rect& b_indicator_bounds);
~WarpRegion();
// If the mouse cursor is in |a_edge_bounds_in_native|, then it will be
// moved to |b_display_id|. Similarily, if the cursor is in
// |b_edge_bounds_in_native|, then it will be moved to |a_display_id|.
// The id for the displays. Used for warping the cursor.
int64_t a_display_id;
int64_t b_display_id;
gfx::Rect a_edge_bounds_in_native;
gfx::Rect b_edge_bounds_in_native;
// The bounds for warp hole windows. These are kept in the instance for
// testing.
gfx::Rect a_indicator_bounds;
gfx::Rect b_indicator_bounds;
// Shows the area where a window can be dragged in to/out from another
// display.
scoped_ptr<SharedDisplayEdgeIndicator> shared_display_edge_indicator;
private:
DISALLOW_COPY_AND_ASSIGN(WarpRegion);
};
std::vector<scoped_ptr<WarpRegion>> warp_regions_;
// Registers the WarpRegion; also displays a drag indicator on the screen if
// |drag_source| is true.
void AddWarpRegion(scoped_ptr<WarpRegion> region, bool drag_source);
// Warps the mouse cursor to an alternate root window when the
// mouse location in |event|, hits the edge of the event target's root and
......@@ -56,35 +101,22 @@ class ASH_EXPORT ExtendedMouseWarpController : public MouseWarpController {
// Update the edge/indicator bounds based on the current
// display configuration.
void UpdateHorizontalEdgeBounds();
void UpdateVerticalEdgeBounds();
// Returns the source and destination window. When |src_window| is
// |drag_soruce_root_| when it is set. Otherwise, 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);
scoped_ptr<WarpRegion> CreateHorizontalEdgeBounds(
const gfx::Display& a,
const gfx::Display& b,
DisplayLayout::Position position);
scoped_ptr<WarpRegion> CreateVerticalEdgeBounds(
const gfx::Display& a,
const gfx::Display& b,
DisplayLayout::Position position);
void allow_non_native_event_for_test() { allow_non_native_event_ = true; }
// The bounds for warp hole windows. |dst_indicator_bounds_| is kept
// in the instance for testing.
gfx::Rect src_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.
aura::Window* drag_source_root_;
bool enabled_;
// Shows the area where a window can be dragged in to/out from
// another display.
scoped_ptr<SharedDisplayEdgeIndicator> shared_display_edge_indicator_;
bool allow_non_native_event_;
DISALLOW_COPY_AND_ASSIGN(ExtendedMouseWarpController);
......
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