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

Side by Side Diff: ash/display/extended_mouse_warp_controller.h

Issue 1601383002: Support moving the cursor and dragging windows to 3+ displays. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Fix windows build warnings, change method placement in cc file, remove/add comments Created 4 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ASH_DISPLAY_EXTENDED_MOUSE_WARP_CONTROLLER_H 5 #ifndef ASH_DISPLAY_EXTENDED_MOUSE_WARP_CONTROLLER_H
6 #define ASH_DISPLAY_EXTENDED_MOUSE_WARP_CONTROLLER_H 6 #define ASH_DISPLAY_EXTENDED_MOUSE_WARP_CONTROLLER_H
7 7
8 #include "ash/display/mouse_warp_controller.h" 8 #include "ash/display/mouse_warp_controller.h"
9 9
10 #include <vector>
11
12 #include "ash/display/display_layout.h"
10 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
11 #include "base/macros.h" 14 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
13 #include "ui/gfx/geometry/rect.h" 16 #include "ui/gfx/geometry/rect.h"
14 17
15 namespace aura { 18 namespace aura {
16 class Window; 19 class Window;
17 } 20 }
18 21
19 namespace gfx { 22 namespace gfx {
20 class Point; 23 class Point;
24 class Display;
21 } 25 }
22 26
23 namespace ash { 27 namespace ash {
24 namespace test { 28 namespace test {
25 class DisplayManagerTestApi; 29 class DisplayManagerTestApi;
26 } 30 }
27 class SharedDisplayEdgeIndicator; 31 class SharedDisplayEdgeIndicator;
28 32
29 // A MouseWarpController used in extended display mode. 33 // A MouseWarpController used in extended display mode.
30 class ASH_EXPORT ExtendedMouseWarpController : public MouseWarpController { 34 class ASH_EXPORT ExtendedMouseWarpController : public MouseWarpController {
31 public: 35 public:
32 explicit ExtendedMouseWarpController(aura::Window* drag_source); 36 explicit ExtendedMouseWarpController(aura::Window* drag_source);
33 ~ExtendedMouseWarpController() override; 37 ~ExtendedMouseWarpController() override;
34 38
35 // MouseWarpController: 39 // MouseWarpController:
36 bool WarpMouseCursor(ui::MouseEvent* event) override; 40 bool WarpMouseCursor(ui::MouseEvent* event) override;
37 void SetEnabled(bool enable) override; 41 void SetEnabled(bool enable) override;
38 42
39 private: 43 private:
40 friend class test::DisplayManagerTestApi; 44 friend class test::DisplayManagerTestApi;
41 FRIEND_TEST_ALL_PREFIXES(ExtendedMouseWarpControllerTest, 45 FRIEND_TEST_ALL_PREFIXES(ExtendedMouseWarpControllerTest,
42 IndicatorBoundsTestOnRight); 46 IndicatorBoundsTestOnRight);
43 FRIEND_TEST_ALL_PREFIXES(ExtendedMouseWarpControllerTest, 47 FRIEND_TEST_ALL_PREFIXES(ExtendedMouseWarpControllerTest,
44 IndicatorBoundsTestOnLeft); 48 IndicatorBoundsTestOnLeft);
45 FRIEND_TEST_ALL_PREFIXES(ExtendedMouseWarpControllerTest, 49 FRIEND_TEST_ALL_PREFIXES(ExtendedMouseWarpControllerTest,
46 IndicatorBoundsTestOnTopBottom); 50 IndicatorBoundsTestOnTopBottom);
47 51
52 struct WarpRegion {
oshima 2016/01/20 18:35:55 can you move the definition to .cc?
jdufault 2016/01/20 23:37:16 Tests need access to the definition. I've added a
53 public:
54 WarpRegion(int64_t a_display_id,
55 int64_t b_display_id,
56 const gfx::Rect& a_indicator_bounds,
57 const gfx::Rect& b_indicator_bounds);
58 ~WarpRegion();
59
60 // If the mouse cursor is in |a_edge_bounds_in_native|, then it will be
61 // moved to |b_display_id|. Similarily, if the cursor is in
62 // |b_edge_bounds_in_native|, then it will be moved to |a_display_id|.
63
64 // The id for the displays. Used for warping the cursor.
65 int64_t a_display_id;
66 int64_t b_display_id;
67
68 gfx::Rect a_edge_bounds_in_native;
69 gfx::Rect b_edge_bounds_in_native;
70
71 // The bounds for warp hole windows. These are kept in the instance for
72 // testing.
73 gfx::Rect a_indicator_bounds;
74 gfx::Rect b_indicator_bounds;
75
76 // Shows the area where a window can be dragged in to/out from another
77 // display.
78 scoped_ptr<SharedDisplayEdgeIndicator> shared_display_edge_indicator;
79
80 private:
81 DISALLOW_COPY_AND_ASSIGN(WarpRegion);
82 };
83
84 std::vector<scoped_ptr<WarpRegion>> warp_regions_;
85
86 // Registers the WarpRegion; also displays a drag indicator on the screen if
87 // |drag_source| is true.
88 void AddWarpRegion(scoped_ptr<WarpRegion> region, bool drag_source);
89
48 // Warps the mouse cursor to an alternate root window when the 90 // Warps the mouse cursor to an alternate root window when the
49 // mouse location in |event|, hits the edge of the event target's root and 91 // mouse location in |event|, hits the edge of the event target's root and
50 // the mouse cursor is considered to be in an alternate display. 92 // the mouse cursor is considered to be in an alternate display.
51 // If |update_mouse_location_now| is true, 93 // If |update_mouse_location_now| is true,
52 // Returns true if/ the cursor was moved. 94 // Returns true if/ the cursor was moved.
53 bool WarpMouseCursorInNativeCoords(const gfx::Point& point_in_native, 95 bool WarpMouseCursorInNativeCoords(const gfx::Point& point_in_native,
54 const gfx::Point& point_in_screen, 96 const gfx::Point& point_in_screen,
55 bool update_mouse_location_now); 97 bool update_mouse_location_now);
56 98
57 // Update the edge/indicator bounds based on the current 99 // Update the edge/indicator bounds based on the current
58 // display configuration. 100 // display configuration.
59 void UpdateHorizontalEdgeBounds(); 101 scoped_ptr<WarpRegion> CreateHorizontalEdgeBounds(
60 void UpdateVerticalEdgeBounds(); 102 const gfx::Display& a,
61 103 const gfx::Display& b,
62 // Returns the source and destination window. When |src_window| is 104 DisplayLayout::Position position);
63 // |drag_soruce_root_| when it is set. Otherwise, the |src_window| 105 scoped_ptr<WarpRegion> CreateVerticalEdgeBounds(
64 // is always the primary root window, because there is no difference 106 const gfx::Display& a,
65 // between moving src to dst and moving dst to src. 107 const gfx::Display& b,
66 void GetSrcAndDstRootWindows(aura::Window** src_window, 108 DisplayLayout::Position position);
67 aura::Window** dst_window);
68 109
69 void allow_non_native_event_for_test() { allow_non_native_event_ = true; } 110 void allow_non_native_event_for_test() { allow_non_native_event_ = true; }
70 111
71 // The bounds for warp hole windows. |dst_indicator_bounds_| is kept
72 // in the instance for testing.
73 gfx::Rect src_indicator_bounds_;
74 gfx::Rect dst_indicator_bounds_;
75
76 gfx::Rect src_edge_bounds_in_native_;
77 gfx::Rect dst_edge_bounds_in_native_;
78
79 // The root window in which the dragging started. 112 // The root window in which the dragging started.
80 aura::Window* drag_source_root_; 113 aura::Window* drag_source_root_;
81 114
82 bool enabled_; 115 bool enabled_;
83 116
84 // Shows the area where a window can be dragged in to/out from
85 // another display.
86 scoped_ptr<SharedDisplayEdgeIndicator> shared_display_edge_indicator_;
87
88 bool allow_non_native_event_; 117 bool allow_non_native_event_;
89 118
90 DISALLOW_COPY_AND_ASSIGN(ExtendedMouseWarpController); 119 DISALLOW_COPY_AND_ASSIGN(ExtendedMouseWarpController);
91 }; 120 };
92 121
93 } // namespace ash 122 } // namespace ash
94 123
95 #endif // ASH_DISPLAY_EXTENDED_MOUSE_WARP_CONTROLLER_H 124 #endif // ASH_DISPLAY_EXTENDED_MOUSE_WARP_CONTROLLER_H
OLDNEW
« no previous file with comments | « no previous file | ash/display/extended_mouse_warp_controller.cc » ('j') | ash/display/extended_mouse_warp_controller.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698