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

Side by Side Diff: ash/wm/common/workspace/multi_window_resize_controller.h

Issue 1936223002: Refactors MultiWindowResizeController to use ash/wm/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nullptr Created 4 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_WM_WORKSPACE_MULTI_WINDOW_RESIZE_CONTROLLER_H_ 5 #ifndef ASH_WM_COMMON_WORKSPACE_MULTI_WINDOW_RESIZE_CONTROLLER_H_
6 #define ASH_WM_WORKSPACE_MULTI_WINDOW_RESIZE_CONTROLLER_H_ 6 #define ASH_WM_COMMON_WORKSPACE_MULTI_WINDOW_RESIZE_CONTROLLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/ash_export.h" 11 #include "ash/ash_export.h"
12 #include "ash/wm/common/wm_window_observer.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/timer/timer.h" 14 #include "base/timer/timer.h"
14 #include "ui/aura/window_observer.h"
15 #include "ui/gfx/geometry/rect.h" 15 #include "ui/gfx/geometry/rect.h"
16 #include "ui/views/mouse_watcher.h" 16 #include "ui/views/mouse_watcher.h"
17 17
18 namespace aura {
19 class Window;
20 }
21
22 namespace views { 18 namespace views {
23 class Widget; 19 class Widget;
24 } 20 }
25 21
26 namespace ash { 22 namespace ash {
27 class MultiWindowResizeControllerTest; 23 class MultiWindowResizeControllerTest;
28 class WorkspaceWindowResizer; 24 class WorkspaceWindowResizer;
29 25
30 // Two directions resizes happen in. 26 // Two directions resizes happen in.
31 enum Direction { 27 enum Direction {
32 TOP_BOTTOM, 28 TOP_BOTTOM,
33 LEFT_RIGHT, 29 LEFT_RIGHT,
34 }; 30 };
35 31
36 // MultiWindowResizeController is responsible for determining and showing a 32 // MultiWindowResizeController is responsible for determining and showing a
37 // widget that allows resizing multiple windows at the same time. 33 // widget that allows resizing multiple windows at the same time.
38 // MultiWindowResizeController is driven by WorkspaceEventFilter. 34 // MultiWindowResizeController is driven by WorkspaceEventFilter.
39 class ASH_EXPORT MultiWindowResizeController : 35 class ASH_EXPORT MultiWindowResizeController
40 public views::MouseWatcherListener, public aura::WindowObserver { 36 : public views::MouseWatcherListener,
37 public wm::WmWindowObserver {
41 public: 38 public:
42 MultiWindowResizeController(); 39 MultiWindowResizeController();
43 ~MultiWindowResizeController() override; 40 ~MultiWindowResizeController() override;
44 41
45 // If necessary, shows the resize widget. |window| is the window the mouse 42 // If necessary, shows the resize widget. |window| is the window the mouse
46 // is over, |component| the edge and |point| the location of the mouse. 43 // is over, |component| the edge and |point| the location of the mouse.
47 void Show(aura::Window* window, int component, const gfx::Point& point); 44 void Show(wm::WmWindow* window, int component, const gfx::Point& point);
48 45
49 // Hides the resize widget. 46 // Hides the resize widget.
50 void Hide(); 47 void Hide();
51 48
52 // MouseWatcherListenre overrides: 49 // MouseWatcherListenre overrides:
53 void MouseMovedOutOfHost() override; 50 void MouseMovedOutOfHost() override;
54 51
55 // WindowObserver overrides: 52 // WindowObserver overrides:
56 void OnWindowDestroying(aura::Window* window) override; 53 void OnWindowDestroying(wm::WmWindow* window) override;
57 54
58 private: 55 private:
59 friend class MultiWindowResizeControllerTest; 56 friend class MultiWindowResizeControllerTest;
60 57
61 // Used to track the two resizable windows and direction. 58 // Used to track the two resizable windows and direction.
62 struct ResizeWindows { 59 struct ResizeWindows {
63 ResizeWindows(); 60 ResizeWindows();
64 ResizeWindows(const ResizeWindows& other); 61 ResizeWindows(const ResizeWindows& other);
65 ~ResizeWindows(); 62 ~ResizeWindows();
66 63
67 // Returns true if |other| equals this ResizeWindows. This does *not* 64 // Returns true if |other| equals this ResizeWindows. This does *not*
68 // consider the windows in |other_windows|. 65 // consider the windows in |other_windows|.
69 bool Equals(const ResizeWindows& other) const; 66 bool Equals(const ResizeWindows& other) const;
70 67
71 // Returns true if this ResizeWindows is valid. 68 // Returns true if this ResizeWindows is valid.
72 bool is_valid() const { return window1 && window2; } 69 bool is_valid() const { return window1 && window2; }
73 70
74 // The left/top window to resize. 71 // The left/top window to resize.
75 aura::Window* window1; 72 wm::WmWindow* window1;
76 73
77 // Other window to resize. 74 // Other window to resize.
78 aura::Window* window2; 75 wm::WmWindow* window2;
79 76
80 // Direction 77 // Direction
81 Direction direction; 78 Direction direction;
82 79
83 // Windows after |window2| that are to be resized. Determined at the time 80 // Windows after |window2| that are to be resized. Determined at the time
84 // the resize starts. 81 // the resize starts.
85 std::vector<aura::Window*> other_windows; 82 std::vector<wm::WmWindow*> other_windows;
86 }; 83 };
87 84
88 class ResizeMouseWatcherHost; 85 class ResizeMouseWatcherHost;
89 class ResizeView; 86 class ResizeView;
90 87
91 void CreateMouseWatcher(); 88 void CreateMouseWatcher();
92 89
93 // Returns a ResizeWindows based on the specified arguments. Use is_valid() 90 // Returns a ResizeWindows based on the specified arguments. Use is_valid()
94 // to test if the return value is a valid multi window resize location. 91 // to test if the return value is a valid multi window resize location.
95 ResizeWindows DetermineWindows(aura::Window* window, 92 ResizeWindows DetermineWindows(wm::WmWindow* window,
96 int window_component, 93 int window_component,
97 const gfx::Point& point) const; 94 const gfx::Point& point) const;
98 95
99 // Variant of DetermineWindows() that uses the current location of the mouse 96 // Variant of DetermineWindows() that uses the current location of the mouse
100 // to determine the resize windows. 97 // to determine the resize windows.
101 ResizeWindows DetermineWindowsFromScreenPoint(aura::Window* window) const; 98 ResizeWindows DetermineWindowsFromScreenPoint(wm::WmWindow* window) const;
102 99
103 // Finds a window by edge (one of the constants HitTestCompat. 100 // Finds a window by edge (one of the constants HitTestCompat.
104 aura::Window* FindWindowByEdge(aura::Window* window_to_ignore, 101 wm::WmWindow* FindWindowByEdge(wm::WmWindow* window_to_ignore,
105 int edge_want, 102 int edge_want,
106 int x_in_parent, 103 int x_in_parent,
107 int y_in_parent) const; 104 int y_in_parent) const;
108 105
109 // Returns the first window touching |window|. 106 // Returns the first window touching |window|.
110 aura::Window* FindWindowTouching(aura::Window* window, 107 wm::WmWindow* FindWindowTouching(wm::WmWindow* window,
111 Direction direction) const; 108 Direction direction) const;
112 109
113 // Places any windows touching |start| into |others|. 110 // Places any windows touching |start| into |others|.
114 void FindWindowsTouching(aura::Window* start, 111 void FindWindowsTouching(wm::WmWindow* start,
115 Direction direction, 112 Direction direction,
116 std::vector<aura::Window*>* others) const; 113 std::vector<wm::WmWindow*>* others) const;
117 114
118 // Shows the resizer if the mouse is still at a valid location. This is called 115 // Shows the resizer if the mouse is still at a valid location. This is called
119 // from the |show_timer_|. 116 // from the |show_timer_|.
120 void ShowIfValidMouseLocation(); 117 void ShowIfValidMouseLocation();
121 118
122 // Shows the widget immediately. 119 // Shows the widget immediately.
123 void ShowNow(); 120 void ShowNow();
124 121
125 // Returns true if the widget is showing. 122 // Returns true if the widget is showing.
126 bool IsShowing() const; 123 bool IsShowing() const;
(...skipping 15 matching lines...) Expand all
142 const gfx::Point& location_in_parent) const; 139 const gfx::Point& location_in_parent) const;
143 140
144 // Returns true if |location_in_screen| is over the resize widget. 141 // Returns true if |location_in_screen| is over the resize widget.
145 bool IsOverResizeWidget(const gfx::Point& location_in_screen) const; 142 bool IsOverResizeWidget(const gfx::Point& location_in_screen) const;
146 143
147 // Returns true if |location_in_screen| is over the resize windows 144 // Returns true if |location_in_screen| is over the resize windows
148 // (or the resize widget itself). 145 // (or the resize widget itself).
149 bool IsOverWindows(const gfx::Point& location_in_screen) const; 146 bool IsOverWindows(const gfx::Point& location_in_screen) const;
150 147
151 // Returns true if |location_in_screen| is over |component| in |window|. 148 // Returns true if |location_in_screen| is over |component| in |window|.
152 bool IsOverComponent(aura::Window* window, 149 bool IsOverComponent(wm::WmWindow* window,
153 const gfx::Point& location_in_screen, 150 const gfx::Point& location_in_screen,
154 int component) const; 151 int component) const;
155 152
156 // Windows and direction to resize. 153 // Windows and direction to resize.
157 ResizeWindows windows_; 154 ResizeWindows windows_;
158 155
159 // Timer used before showing. 156 // Timer used before showing.
160 base::OneShotTimer show_timer_; 157 base::OneShotTimer show_timer_;
161 158
162 std::unique_ptr<views::Widget> resize_widget_; 159 std::unique_ptr<views::Widget> resize_widget_;
(...skipping 10 matching lines...) Expand all
173 // Used to detect whether the mouse is over the windows. While 170 // Used to detect whether the mouse is over the windows. While
174 // |resize_widget_| is non-NULL (ie the widget is showing) we ignore calls 171 // |resize_widget_| is non-NULL (ie the widget is showing) we ignore calls
175 // to Show(). 172 // to Show().
176 std::unique_ptr<views::MouseWatcher> mouse_watcher_; 173 std::unique_ptr<views::MouseWatcher> mouse_watcher_;
177 174
178 DISALLOW_COPY_AND_ASSIGN(MultiWindowResizeController); 175 DISALLOW_COPY_AND_ASSIGN(MultiWindowResizeController);
179 }; 176 };
180 177
181 } // namespace ash 178 } // namespace ash
182 179
183 #endif // ASH_WM_WORKSPACE_MULTI_WINDOW_RESIZE_CONTROLLER_H_ 180 #endif // ASH_WM_COMMON_WORKSPACE_MULTI_WINDOW_RESIZE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698