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

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

Issue 2891183002: chromeos: removes WmWindow usage from MultiWindowResizeController (Closed)
Patch Set: feedback and merge Created 3 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
« no previous file with comments | « ash/root_window_controller.cc ('k') | ash/wm/workspace/multi_window_resize_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_WORKSPACE_MULTI_WINDOW_RESIZE_CONTROLLER_H_
6 #define ASH_WM_WORKSPACE_MULTI_WINDOW_RESIZE_CONTROLLER_H_ 6 #define ASH_WM_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 "base/macros.h" 12 #include "base/macros.h"
13 #include "base/timer/timer.h" 13 #include "base/timer/timer.h"
14 #include "ui/aura/window_observer.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 views { 18 namespace views {
19 class Widget; 19 class Widget;
20 } 20 }
21 21
22 namespace ash { 22 namespace ash {
23 class MultiWindowResizeControllerTest; 23 class MultiWindowResizeControllerTest;
24 class WmWindow;
25 class WorkspaceWindowResizer; 24 class WorkspaceWindowResizer;
26 25
27 // Two directions resizes happen in. 26 // Two directions resizes happen in.
28 enum Direction { 27 enum Direction {
29 TOP_BOTTOM, 28 TOP_BOTTOM,
30 LEFT_RIGHT, 29 LEFT_RIGHT,
31 }; 30 };
32 31
33 // MultiWindowResizeController is responsible for determining and showing a 32 // MultiWindowResizeController is responsible for determining and showing a
34 // widget that allows resizing multiple windows at the same time. 33 // widget that allows resizing multiple windows at the same time.
35 // MultiWindowResizeController is driven by WorkspaceEventFilter. 34 // MultiWindowResizeController is driven by WorkspaceEventFilter.
36 class ASH_EXPORT MultiWindowResizeController 35 class ASH_EXPORT MultiWindowResizeController
37 : public views::MouseWatcherListener, 36 : public views::MouseWatcherListener,
38 public aura::WindowObserver { 37 public aura::WindowObserver {
39 public: 38 public:
40 MultiWindowResizeController(); 39 MultiWindowResizeController();
41 ~MultiWindowResizeController() override; 40 ~MultiWindowResizeController() override;
42 41
43 // 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
44 // 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.
45 void Show(WmWindow* window, int component, const gfx::Point& point); 44 void Show(aura::Window* window, int component, const gfx::Point& point);
46 45
47 // Hides the resize widget. 46 // Hides the resize widget.
48 void Hide(); 47 void Hide();
49 48
50 // MouseWatcherListenre overrides: 49 // MouseWatcherListenre overrides:
51 void MouseMovedOutOfHost() override; 50 void MouseMovedOutOfHost() override;
52 51
53 // WindowObserver overrides: 52 // WindowObserver overrides:
54 void OnWindowDestroying(aura::Window* window) override; 53 void OnWindowDestroying(aura::Window* window) override;
55 54
56 private: 55 private:
57 friend class MultiWindowResizeControllerTest; 56 friend class MultiWindowResizeControllerTest;
58 57
59 // Used to track the two resizable windows and direction. 58 // Used to track the two resizable windows and direction.
60 struct ResizeWindows { 59 struct ResizeWindows {
61 ResizeWindows(); 60 ResizeWindows();
62 ResizeWindows(const ResizeWindows& other); 61 ResizeWindows(const ResizeWindows& other);
63 ~ResizeWindows(); 62 ~ResizeWindows();
64 63
65 // Returns true if |other| equals this ResizeWindows. This does *not* 64 // Returns true if |other| equals this ResizeWindows. This does *not*
66 // consider the windows in |other_windows|. 65 // consider the windows in |other_windows|.
67 bool Equals(const ResizeWindows& other) const; 66 bool Equals(const ResizeWindows& other) const;
68 67
69 // Returns true if this ResizeWindows is valid. 68 // Returns true if this ResizeWindows is valid.
70 bool is_valid() const { return window1 && window2; } 69 bool is_valid() const { return window1 && window2; }
71 70
72 // The left/top window to resize. 71 // The left/top window to resize.
73 WmWindow* window1; 72 aura::Window* window1;
74 73
75 // Other window to resize. 74 // Other window to resize.
76 WmWindow* window2; 75 aura::Window* window2;
77 76
78 // Direction 77 // Direction
79 Direction direction; 78 Direction direction;
80 79
81 // 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
82 // the resize starts. 81 // the resize starts.
83 std::vector<WmWindow*> other_windows; 82 std::vector<aura::Window*> other_windows;
84 }; 83 };
85 84
86 class ResizeMouseWatcherHost; 85 class ResizeMouseWatcherHost;
87 class ResizeView; 86 class ResizeView;
88 87
89 void CreateMouseWatcher(); 88 void CreateMouseWatcher();
90 89
91 // Returns a ResizeWindows based on the specified arguments. Use is_valid() 90 // Returns a ResizeWindows based on the specified arguments. Use is_valid()
92 // 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.
93 ResizeWindows DetermineWindows(WmWindow* window, 92 ResizeWindows DetermineWindows(aura::Window* window,
94 int window_component, 93 int window_component,
95 const gfx::Point& point) const; 94 const gfx::Point& point) const;
96 95
97 // Variant of DetermineWindows() that uses the current location of the mouse 96 // Variant of DetermineWindows() that uses the current location of the mouse
98 // to determine the resize windows. 97 // to determine the resize windows.
99 ResizeWindows DetermineWindowsFromScreenPoint(WmWindow* window) const; 98 ResizeWindows DetermineWindowsFromScreenPoint(aura::Window* window) const;
100 99
101 // Finds a window by edge (one of the constants HitTestCompat. 100 // Finds a window by edge (one of the constants HitTestCompat.
102 WmWindow* FindWindowByEdge(WmWindow* window_to_ignore, 101 aura::Window* FindWindowByEdge(aura::Window* window_to_ignore,
103 int edge_want, 102 int edge_want,
104 int x_in_parent, 103 int x_in_parent,
105 int y_in_parent) const; 104 int y_in_parent) const;
106 105
107 // Returns the first window touching |window|. 106 // Returns the first window touching |window|.
108 WmWindow* FindWindowTouching(WmWindow* window, Direction direction) const; 107 aura::Window* FindWindowTouching(aura::Window* window,
108 Direction direction) const;
109 109
110 // Places any windows touching |start| into |others|. 110 // Places any windows touching |start| into |others|.
111 void FindWindowsTouching(WmWindow* start, 111 void FindWindowsTouching(aura::Window* start,
112 Direction direction, 112 Direction direction,
113 std::vector<WmWindow*>* others) const; 113 std::vector<aura::Window*>* others) const;
114 114
115 // 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
116 // from the |show_timer_|. 116 // from the |show_timer_|.
117 void ShowIfValidMouseLocation(); 117 void ShowIfValidMouseLocation();
118 118
119 // Shows the widget immediately. 119 // Shows the widget immediately.
120 void ShowNow(); 120 void ShowNow();
121 121
122 // Returns true if the widget is showing. 122 // Returns true if the widget is showing.
123 bool IsShowing() const; 123 bool IsShowing() const;
(...skipping 15 matching lines...) Expand all
139 const gfx::Point& location_in_parent) const; 139 const gfx::Point& location_in_parent) const;
140 140
141 // Returns true if |location_in_screen| is over the resize widget. 141 // Returns true if |location_in_screen| is over the resize widget.
142 bool IsOverResizeWidget(const gfx::Point& location_in_screen) const; 142 bool IsOverResizeWidget(const gfx::Point& location_in_screen) const;
143 143
144 // Returns true if |location_in_screen| is over the resize windows 144 // Returns true if |location_in_screen| is over the resize windows
145 // (or the resize widget itself). 145 // (or the resize widget itself).
146 bool IsOverWindows(const gfx::Point& location_in_screen) const; 146 bool IsOverWindows(const gfx::Point& location_in_screen) const;
147 147
148 // Returns true if |location_in_screen| is over |component| in |window|. 148 // Returns true if |location_in_screen| is over |component| in |window|.
149 bool IsOverComponent(WmWindow* window, 149 bool IsOverComponent(aura::Window* window,
150 const gfx::Point& location_in_screen, 150 const gfx::Point& location_in_screen,
151 int component) const; 151 int component) const;
152 152
153 // Windows and direction to resize. 153 // Windows and direction to resize.
154 ResizeWindows windows_; 154 ResizeWindows windows_;
155 155
156 // Timer used before showing. 156 // Timer used before showing.
157 base::OneShotTimer show_timer_; 157 base::OneShotTimer show_timer_;
158 158
159 std::unique_ptr<views::Widget> resize_widget_; 159 std::unique_ptr<views::Widget> resize_widget_;
(...skipping 11 matching lines...) Expand all
171 // |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
172 // to Show(). 172 // to Show().
173 std::unique_ptr<views::MouseWatcher> mouse_watcher_; 173 std::unique_ptr<views::MouseWatcher> mouse_watcher_;
174 174
175 DISALLOW_COPY_AND_ASSIGN(MultiWindowResizeController); 175 DISALLOW_COPY_AND_ASSIGN(MultiWindowResizeController);
176 }; 176 };
177 177
178 } // namespace ash 178 } // namespace ash
179 179
180 #endif // ASH_WM_WORKSPACE_MULTI_WINDOW_RESIZE_CONTROLLER_H_ 180 #endif // ASH_WM_WORKSPACE_MULTI_WINDOW_RESIZE_CONTROLLER_H_
OLDNEW
« no previous file with comments | « ash/root_window_controller.cc ('k') | ash/wm/workspace/multi_window_resize_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698