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

Side by Side Diff: ui/aura/mus/window_port_mus.h

Issue 2517853002: Fixes bug in handling restacking because of transients (Closed)
Patch Set: merge 2 trunk Created 4 years 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 UI_AURA_MUS_WINDOW_PORT_MUS_H_ 5 #ifndef UI_AURA_MUS_WINDOW_PORT_MUS_H_
6 #define UI_AURA_MUS_WINDOW_PORT_MUS_H_ 6 #define UI_AURA_MUS_WINDOW_PORT_MUS_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // window_tree_client_->OnFooChanged(this, ...); 106 // window_tree_client_->OnFooChanged(this, ...);
107 enum ServerChangeType { 107 enum ServerChangeType {
108 ADD, 108 ADD,
109 ADD_TRANSIENT, 109 ADD_TRANSIENT,
110 BOUNDS, 110 BOUNDS,
111 DESTROY, 111 DESTROY,
112 PROPERTY, 112 PROPERTY,
113 REMOVE, 113 REMOVE,
114 REMOVE_TRANSIENT, 114 REMOVE_TRANSIENT,
115 REORDER, 115 REORDER,
116 // This is used when a REORDER *may* occur as the result of a transient
117 // child being added or removed. As there is no guarantee the move will
118 // actually happen (the window may be in place already) this change is not
119 // automatically removed. Instead the change is explicitly removed.
120 TRANSIENT_REORDER,
116 VISIBLE, 121 VISIBLE,
117 }; 122 };
118 123
119 // Contains data needed to identify a change from the server. 124 // Contains data needed to identify a change from the server.
120 struct ServerChangeData { 125 struct ServerChangeData {
121 // Applies to ADD, ADD_TRANSIENT, REMOVE, REMOVE_TRANSIENT and REORDER. 126 // Applies to ADD, ADD_TRANSIENT, REMOVE, REMOVE_TRANSIENT, REORDER and
127 // TRANSIENT_REORDER.
122 Id child_id; 128 Id child_id;
123 // Applies to BOUNDS. 129 // Applies to BOUNDS.
124 gfx::Rect bounds; 130 gfx::Rect bounds;
125 // Applies to VISIBLE. 131 // Applies to VISIBLE.
126 bool visible; 132 bool visible;
127 // Applies to PROPERTY. 133 // Applies to PROPERTY.
128 std::string property_name; 134 std::string property_name;
129 }; 135 };
130 136
131 // Used to identify a change the server. 137 // Used to identify a change the server.
132 struct ServerChange { 138 struct ServerChange {
133 ServerChangeType type; 139 ServerChangeType type;
134 // A unique id assigned to the change and used later on to identify it for 140 // A unique id assigned to the change and used later on to identify it for
135 // removal. 141 // removal.
136 ServerChangeIdType server_change_id; 142 ServerChangeIdType server_change_id;
137 ServerChangeData data; 143 ServerChangeData data;
138 }; 144 };
139 145
146 using ServerChanges = std::vector<ServerChange>;
147
140 // Convenience for adding/removing a ScopedChange. 148 // Convenience for adding/removing a ScopedChange.
141 class ScopedServerChange { 149 class ScopedServerChange {
142 public: 150 public:
143 ScopedServerChange(WindowPortMus* window_impl, 151 ScopedServerChange(WindowPortMus* window_impl,
144 const ServerChangeType type, 152 const ServerChangeType type,
145 const ServerChangeData& data) 153 const ServerChangeData& data)
146 : window_impl_(window_impl), 154 : window_impl_(window_impl),
147 server_change_id_(window_impl->ScheduleChange(type, data)) {} 155 server_change_id_(window_impl->ScheduleChange(type, data)) {}
148 156
149 ~ScopedServerChange() { window_impl_->RemoveChangeById(server_change_id_); } 157 ~ScopedServerChange() { window_impl_->RemoveChangeById(server_change_id_); }
(...skipping 18 matching lines...) Expand all
168 const ServerChangeData& data); 176 const ServerChangeData& data);
169 177
170 // Removes a ServerChange by id. 178 // Removes a ServerChange by id.
171 void RemoveChangeById(ServerChangeIdType change_id); 179 void RemoveChangeById(ServerChangeIdType change_id);
172 180
173 // If there is a schedule change matching |type| and |data| it is removed and 181 // If there is a schedule change matching |type| and |data| it is removed and
174 // true is returned. If no matching change is scheduled returns false. 182 // true is returned. If no matching change is scheduled returns false.
175 bool RemoveChangeByTypeAndData(const ServerChangeType type, 183 bool RemoveChangeByTypeAndData(const ServerChangeType type,
176 const ServerChangeData& data); 184 const ServerChangeData& data);
177 185
186 ServerChanges::iterator FindServerChangeByTypeAndData(
msw 2016/11/21 19:56:34 nit: nix 'Server' here or add to functions above?
sky 2016/11/21 21:31:43 Done.
187 const ServerChangeType type,
188 const ServerChangeData& data);
189
178 PropertyConverter* GetPropertyConverter(); 190 PropertyConverter* GetPropertyConverter();
179 191
180 // WindowMus: 192 // WindowMus:
181 Window* GetWindow() override; 193 Window* GetWindow() override;
182 void AddChildFromServer(WindowMus* window) override; 194 void AddChildFromServer(WindowMus* window) override;
183 void RemoveChildFromServer(WindowMus* child) override; 195 void RemoveChildFromServer(WindowMus* child) override;
184 void ReorderFromServer(WindowMus* child, 196 void ReorderFromServer(WindowMus* child,
185 WindowMus* relative, 197 WindowMus* relative,
186 ui::mojom::OrderDirection) override; 198 ui::mojom::OrderDirection) override;
187 void SetBoundsFromServer(const gfx::Rect& bounds) override; 199 void SetBoundsFromServer(const gfx::Rect& bounds) override;
188 void SetVisibleFromServer(bool visible) override; 200 void SetVisibleFromServer(bool visible) override;
189 void SetOpacityFromServer(float opacity) override; 201 void SetOpacityFromServer(float opacity) override;
190 void SetPredefinedCursorFromServer(ui::mojom::Cursor cursor) override; 202 void SetPredefinedCursorFromServer(ui::mojom::Cursor cursor) override;
191 void SetPropertyFromServer( 203 void SetPropertyFromServer(
192 const std::string& property_name, 204 const std::string& property_name,
193 const std::vector<uint8_t>* property_data) override; 205 const std::vector<uint8_t>* property_data) override;
194 void SetSurfaceIdFromServer( 206 void SetSurfaceIdFromServer(
195 std::unique_ptr<SurfaceInfo> surface_info) override; 207 std::unique_ptr<SurfaceInfo> surface_info) override;
196 void DestroyFromServer() override; 208 void DestroyFromServer() override;
197 void AddTransientChildFromServer(WindowMus* child) override; 209 void AddTransientChildFromServer(WindowMus* child) override;
198 void RemoveTransientChildFromServer(WindowMus* child) override; 210 void RemoveTransientChildFromServer(WindowMus* child) override;
199 ChangeSource OnTransientChildAdded(WindowMus* child) override; 211 ChangeSource OnTransientChildAdded(WindowMus* child) override;
200 ChangeSource OnTransientChildRemoved(WindowMus* child) override; 212 ChangeSource OnTransientChildRemoved(WindowMus* child) override;
201 std::unique_ptr<WindowMusChangeData> PrepareForServerBoundsChange( 213 std::unique_ptr<WindowMusChangeData> PrepareForServerBoundsChange(
202 const gfx::Rect& bounds) override; 214 const gfx::Rect& bounds) override;
215 void PrepareForTransientRestack(WindowMus* window) override;
msw 2016/11/21 19:56:34 nit: order these just after PrepareForServerVisibi
sky 2016/11/21 21:31:43 Done.
216 void OnTransientRestackDone(WindowMus* window) override;
203 std::unique_ptr<WindowMusChangeData> PrepareForServerVisibilityChange( 217 std::unique_ptr<WindowMusChangeData> PrepareForServerVisibilityChange(
204 bool value) override; 218 bool value) override;
205 void NotifyEmbeddedAppDisconnected() override; 219 void NotifyEmbeddedAppDisconnected() override;
206 220
207 // WindowPort: 221 // WindowPort:
208 void OnPreInit(Window* window) override; 222 void OnPreInit(Window* window) override;
209 void OnDeviceScaleFactorChanged(float device_scale_factor) override; 223 void OnDeviceScaleFactorChanged(float device_scale_factor) override;
210 void OnWillAddChild(Window* child) override; 224 void OnWillAddChild(Window* child) override;
211 void OnWillRemoveChild(Window* child) override; 225 void OnWillRemoveChild(Window* child) override;
212 void OnWillMoveChild(size_t current_index, size_t dest_index) override; 226 void OnWillMoveChild(size_t current_index, size_t dest_index) override;
213 void OnVisibilityChanged(bool visible) override; 227 void OnVisibilityChanged(bool visible) override;
214 void OnDidChangeBounds(const gfx::Rect& old_bounds, 228 void OnDidChangeBounds(const gfx::Rect& old_bounds,
215 const gfx::Rect& new_bounds) override; 229 const gfx::Rect& new_bounds) override;
216 std::unique_ptr<WindowPortPropertyData> OnWillChangeProperty( 230 std::unique_ptr<WindowPortPropertyData> OnWillChangeProperty(
217 const void* key) override; 231 const void* key) override;
218 void OnPropertyChanged(const void* key, 232 void OnPropertyChanged(const void* key,
219 std::unique_ptr<WindowPortPropertyData> data) override; 233 std::unique_ptr<WindowPortPropertyData> data) override;
220 234
221 WindowTreeClient* window_tree_client_; 235 WindowTreeClient* window_tree_client_;
222 236
223 Window* window_ = nullptr; 237 Window* window_ = nullptr;
224 238
225 ServerChangeIdType next_server_change_id_ = 0; 239 ServerChangeIdType next_server_change_id_ = 0;
226 std::vector<ServerChange> server_changes_; 240 ServerChanges server_changes_;
227 241
228 SurfaceIdHandler* surface_id_handler_; 242 SurfaceIdHandler* surface_id_handler_;
229 std::unique_ptr<SurfaceInfo> surface_info_; 243 std::unique_ptr<SurfaceInfo> surface_info_;
230 244
231 ui::mojom::Cursor predefined_cursor_ = ui::mojom::Cursor::CURSOR_NULL; 245 ui::mojom::Cursor predefined_cursor_ = ui::mojom::Cursor::CURSOR_NULL;
232 246
233 DISALLOW_COPY_AND_ASSIGN(WindowPortMus); 247 DISALLOW_COPY_AND_ASSIGN(WindowPortMus);
234 }; 248 };
235 249
236 } // namespace aura 250 } // namespace aura
237 251
238 #endif // UI_AURA_MUS_WINDOW_PORT_MUS_H_ 252 #endif // UI_AURA_MUS_WINDOW_PORT_MUS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698