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

Side by Side Diff: ash/common/wm/overview/scoped_transform_overview_window.h

Issue 2470343003: Use mirror layer for minimized windows in overview mode (Closed)
Patch Set: Use mirror layer for minimized windows in overview mode Created 4 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_COMMON_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_ 5 #ifndef ASH_COMMON_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_
6 #define ASH_COMMON_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_ 6 #define ASH_COMMON_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_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/common/wm/overview/overview_animation_type.h" 12 #include "ash/common/wm/overview/overview_animation_type.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "third_party/skia/include/core/SkColor.h" 15 #include "third_party/skia/include/core/SkColor.h"
16 #include "ui/events/event_handler.h"
16 #include "ui/gfx/geometry/size.h" 17 #include "ui/gfx/geometry/size.h"
17 #include "ui/gfx/transform.h" 18 #include "ui/gfx/transform.h"
18 19
19 class SkRegion; 20 class SkRegion;
20 21
21 namespace gfx { 22 namespace gfx {
22 class Rect; 23 class Rect;
23 } 24 }
24 25
26 namespace views {
27 class Widget;
28 }
29
25 namespace ash { 30 namespace ash {
26 31
27 class ScopedOverviewAnimationSettings; 32 class ScopedOverviewAnimationSettings;
28 class WmWindow; 33 class WmWindow;
29 34
30 // Manages a window, and it's transient children, in the overview mode. This 35 // Manages a window, and it's transient children, in the overview mode. This
31 // class allows transforming the windows with a helper to determine the best 36 // class allows transforming the windows with a helper to determine the best
32 // fit in certain bounds. The window's state is restored on destruction of this 37 // fit in certain bounds. The window's state is restored on destruction of this
33 // object. 38 // object.
34 class ASH_EXPORT ScopedTransformOverviewWindow { 39 class ASH_EXPORT ScopedTransformOverviewWindow : public ui::EventHandler {
35 public: 40 public:
36 class OverviewContentMask; 41 class OverviewContentMask;
37 using ScopedAnimationSettings = 42 using ScopedAnimationSettings =
38 std::vector<std::unique_ptr<ScopedOverviewAnimationSettings>>; 43 std::vector<std::unique_ptr<ScopedOverviewAnimationSettings>>;
39 44
40 // Calculates and returns an optimal scale ratio. With MD this is only 45 // Calculates and returns an optimal scale ratio. With MD this is only
41 // taking into account |size.height()| as the width can vary. Without MD this 46 // taking into account |size.height()| as the width can vary. Without MD this
42 // returns the scale that allows the item to fully fit within |size|. 47 // returns the scale that allows the item to fully fit within |size|.
43 static float GetItemScale(const gfx::Size& source, 48 static float GetItemScale(const gfx::Size& source,
44 const gfx::Size& target, 49 const gfx::Size& target,
45 int top_view_inset, 50 int top_view_inset,
46 int title_height); 51 int title_height);
47 52
48 // Returns |rect| having been shrunk to fit within |bounds| (preserving the 53 // Returns |rect| having been shrunk to fit within |bounds| (preserving the
49 // aspect ratio). Takes into account a window header that is |top_view_inset| 54 // aspect ratio). Takes into account a window header that is |top_view_inset|
50 // tall in the original window getting replaced by a window caption that is 55 // tall in the original window getting replaced by a window caption that is
51 // |title_height| tall in transformed window. 56 // |title_height| tall in transformed window.
52 static gfx::Rect ShrinkRectToFitPreservingAspectRatio(const gfx::Rect& rect, 57 static gfx::Rect ShrinkRectToFitPreservingAspectRatio(const gfx::Rect& rect,
53 const gfx::Rect& bounds, 58 const gfx::Rect& bounds,
54 int top_view_inset, 59 int top_view_inset,
55 int title_height); 60 int title_height);
56 61
57 // Returns the transform turning |src_rect| into |dst_rect|. 62 // Returns the transform turning |src_rect| into |dst_rect|.
58 static gfx::Transform GetTransformForRect(const gfx::Rect& src_rect, 63 static gfx::Transform GetTransformForRect(const gfx::Rect& src_rect,
59 const gfx::Rect& dst_rect); 64 const gfx::Rect& dst_rect);
60 65
61 explicit ScopedTransformOverviewWindow(WmWindow* window); 66 explicit ScopedTransformOverviewWindow(WmWindow* window);
62 ~ScopedTransformOverviewWindow(); 67 ~ScopedTransformOverviewWindow() override;
63 68
64 // Starts an animation sequence which will use animation settings specified by 69 // Starts an animation sequence which will use animation settings specified by
65 // |animation_type|. The |animation_settings| container is populated with 70 // |animation_type|. The |animation_settings| container is populated with
66 // scoped entities and the container should be destroyed at the end of the 71 // scoped entities and the container should be destroyed at the end of the
67 // animation sequence. 72 // animation sequence.
68 // 73 //
69 // Example: 74 // Example:
70 // ScopedTransformOverviewWindow overview_window(window); 75 // ScopedTransformOverviewWindow overview_window(window);
71 // ScopedTransformOverviewWindow::ScopedAnimationSettings scoped_settings; 76 // ScopedTransformOverviewWindow::ScopedAnimationSettings scoped_settings;
72 // overview_window.BeginScopedAnimation( 77 // overview_window.BeginScopedAnimation(
(...skipping 23 matching lines...) Expand all
96 // ancestors in which case returns SK_ColorTRANSPARENT. 101 // ancestors in which case returns SK_ColorTRANSPARENT.
97 SkColor GetTopColor() const; 102 SkColor GetTopColor() const;
98 103
99 // Returns TOP_VIEW_INSET property of |window_| unless there are transient 104 // Returns TOP_VIEW_INSET property of |window_| unless there are transient
100 // ancestors in which case returns 0. 105 // ancestors in which case returns 0.
101 int GetTopInset() const; 106 int GetTopInset() const;
102 107
103 // Restores and animates the managed window to it's non overview mode state. 108 // Restores and animates the managed window to it's non overview mode state.
104 void RestoreWindow(); 109 void RestoreWindow();
105 110
106 // Forces the managed window to be shown (ie not hidden or minimized) when
107 // calling RestoreWindow().
108 void ShowWindowOnExit();
109
110 // Informs the ScopedTransformOverviewWindow that the window being watched was 111 // Informs the ScopedTransformOverviewWindow that the window being watched was
111 // destroyed. This resets the internal window pointer. 112 // destroyed. This resets the internal window pointer.
112 void OnWindowDestroyed(); 113 void OnWindowDestroyed();
113 114
114 // Prepares for overview mode by doing any necessary actions before entering. 115 // Prepares for overview mode by doing any necessary actions before entering.
115 void PrepareForOverview(); 116 void PrepareForOverview();
116 117
117 // Applies the |transform| to the overview window and all of its transient 118 // Applies the |transform| to the overview window and all of its transient
118 // children. 119 // children.
119 void SetTransform(WmWindow* root_window, const gfx::Transform& transform); 120 void SetTransform(WmWindow* root_window, const gfx::Transform& transform);
120 121
121 // Set's the opacity of the managed windows. 122 // Set's the opacity of the managed windows.
122 void SetOpacity(float opacity); 123 void SetOpacity(float opacity);
123 124
124 // Hides the window header whose size is given in |TOP_VIEW_INSET| 125 // Hides the window header whose size is given in |TOP_VIEW_INSET|
125 // window property. 126 // window property.
126 void HideHeader(); 127 void HideHeader();
127 128
128 // Shows the window header that is hidden by HideHeader(). 129 // Shows the window header that is hidden by HideHeader().
129 void ShowHeader(); 130 void ShowHeader();
130 131
132 // Creates/Deletes a mirror window for minimized windows.
133 void UpdateMirrorWindowForMinimizedState();
134
131 WmWindow* window() const { return window_; } 135 WmWindow* window() const { return window_; }
132 136
133 // Closes the transient root of the window managed by |this|. 137 // Closes the transient root of the window managed by |this|.
134 void Close(); 138 void Close();
135 139
140 // Returns the window used to show the content in overview mdoe.
141 // For minmiezd window, this will be a window that hosts mirrored layers.
142 WmWindow* GetOverviewWindow() const;
143
144 // Returns the window created for minimized window, or nullptr
145 // if it does not exit.
146 WmWindow* GetOverviewWindowForMinimizedState() const;
147
148 // ui::EventHandler:
149 void OnGestureEvent(ui::GestureEvent* event) override;
150 void OnMouseEvent(ui::MouseEvent* event) override;
151
136 private: 152 private:
137 friend class WindowSelectorTest; 153 friend class WindowSelectorTest;
138 154
139 enum OriginalVisibility {
140 ORIGINALLY_VISIBLE,
141 ORIGINALLY_MINIMIZED,
142 ORIGINALLY_DOCKED_MINIMIZED,
143 };
144
145 // Shows the window if it was minimized.
146 void ShowWindowIfMinimized();
147
148 // Closes the window managed by |this|. 155 // Closes the window managed by |this|.
149 void CloseWidget(); 156 void CloseWidget();
150 157
158 void CreateMirrorWindowForMinimizedState();
159
151 // Makes Close() execute synchronously when used in tests. 160 // Makes Close() execute synchronously when used in tests.
152 static void SetImmediateCloseForTests(); 161 static void SetImmediateCloseForTests();
153 162
154 // A weak pointer to the real window in the overview. 163 // A weak pointer to the real window in the overview.
155 WmWindow* window_; 164 WmWindow* window_;
156 165
157 // Original window shape, if it was set on a window. 166 // Original window shape, if it was set on a window.
158 std::unique_ptr<SkRegion> original_window_shape_; 167 std::unique_ptr<SkRegion> original_window_shape_;
159 168
160 // True after the |original_window_shape_| has been set or after it has 169 // True after the |original_window_shape_| has been set or after it has
161 // been determined that window shape was not originally set on the |window_|. 170 // been determined that window shape was not originally set on the |window_|.
162 bool determined_original_window_shape_; 171 bool determined_original_window_shape_;
163 172
164 // Original visibility of |window_| upon entering overview mode that needs to
165 // be restored unless the window gets selected.
166 OriginalVisibility original_visibility_;
167
168 // Tracks if this window was ignored by the shelf. 173 // Tracks if this window was ignored by the shelf.
169 bool ignored_by_shelf_; 174 bool ignored_by_shelf_;
170 175
171 // True if the window has been transformed for overview mode. 176 // True if the window has been transformed for overview mode.
172 bool overview_started_; 177 bool overview_started_;
173 178
174 // The original transform of the window before entering overview mode. 179 // The original transform of the window before entering overview mode.
175 gfx::Transform original_transform_; 180 gfx::Transform original_transform_;
176 181
177 // The original opacity of the window before entering overview mode. 182 // A window that holds the content for minimized window.
178 float original_opacity_; 183 std::unique_ptr<views::Widget> minimized_;
varkha 2016/11/15 20:10:21 How about minimized_widget_? Longer but we often u
oshima 2016/11/16 14:58:27 Done.
179 184
180 base::WeakPtrFactory<ScopedTransformOverviewWindow> weak_ptr_factory_; 185 base::WeakPtrFactory<ScopedTransformOverviewWindow> weak_ptr_factory_;
181 186
182 DISALLOW_COPY_AND_ASSIGN(ScopedTransformOverviewWindow); 187 DISALLOW_COPY_AND_ASSIGN(ScopedTransformOverviewWindow);
183 }; 188 };
184 189
185 } // namespace ash 190 } // namespace ash
186 191
187 #endif // ASH_COMMON_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_ 192 #endif // ASH_COMMON_WM_OVERVIEW_SCOPED_TRANSFORM_OVERVIEW_WINDOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698