OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "services/ui/ws/server_window.h" | 5 #include "services/ui/ws/server_window.h" |
6 | 6 |
7 #include <inttypes.h> | 7 #include <inttypes.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
23 | 23 |
24 ServerWindow::ServerWindow(ServerWindowDelegate* delegate, | 24 ServerWindow::ServerWindow(ServerWindowDelegate* delegate, |
25 const WindowId& id, | 25 const WindowId& id, |
26 const Properties& properties) | 26 const Properties& properties) |
27 : delegate_(delegate), | 27 : delegate_(delegate), |
28 id_(id), | 28 id_(id), |
29 frame_sink_id_(WindowIdToTransportId(id), 0), | 29 frame_sink_id_(WindowIdToTransportId(id), 0), |
30 parent_(nullptr), | 30 parent_(nullptr), |
31 stacking_target_(nullptr), | 31 stacking_target_(nullptr), |
32 transient_parent_(nullptr), | 32 transient_parent_(nullptr), |
33 is_modal_(false), | 33 modal_type_(MODAL_TYPE_NONE), |
34 visible_(false), | 34 visible_(false), |
35 // Default to POINTER as CURSOR_NULL doesn't change the cursor, it leaves | 35 // Default to POINTER as CURSOR_NULL doesn't change the cursor, it leaves |
36 // the last non-null cursor. | 36 // the last non-null cursor. |
37 cursor_id_(mojom::Cursor::POINTER), | 37 cursor_id_(mojom::Cursor::POINTER), |
38 non_client_cursor_id_(mojom::Cursor::POINTER), | 38 non_client_cursor_id_(mojom::Cursor::POINTER), |
39 opacity_(1), | 39 opacity_(1), |
40 can_focus_(true), | 40 can_focus_(true), |
41 properties_(properties), | 41 properties_(properties), |
42 // Don't notify newly added observers during notification. This causes | 42 // Don't notify newly added observers during notification. This causes |
43 // problems for code that adds an observer as part of an observer | 43 // problems for code that adds an observer as part of an observer |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 for (ServerWindow* child : children_) { | 221 for (ServerWindow* child : children_) { |
222 ServerWindow* window = child->GetChildWindow(window_id); | 222 ServerWindow* window = child->GetChildWindow(window_id); |
223 if (window) | 223 if (window) |
224 return window; | 224 return window; |
225 } | 225 } |
226 | 226 |
227 return nullptr; | 227 return nullptr; |
228 } | 228 } |
229 | 229 |
230 bool ServerWindow::AddTransientWindow(ServerWindow* child) { | 230 bool ServerWindow::AddTransientWindow(ServerWindow* child) { |
231 // A system modal window cannot become a transient child. | |
232 if (child->is_modal() && !child->transient_parent()) | |
Hadi
2017/03/06 20:07:05
I am not sure if we should have retained this chec
| |
233 return false; | |
234 | |
235 if (child->transient_parent()) | 231 if (child->transient_parent()) |
236 child->transient_parent()->RemoveTransientWindow(child); | 232 child->transient_parent()->RemoveTransientWindow(child); |
237 | 233 |
238 DCHECK(std::find(transient_children_.begin(), transient_children_.end(), | 234 DCHECK(std::find(transient_children_.begin(), transient_children_.end(), |
239 child) == transient_children_.end()); | 235 child) == transient_children_.end()); |
240 transient_children_.push_back(child); | 236 transient_children_.push_back(child); |
241 child->transient_parent_ = this; | 237 child->transient_parent_ = this; |
242 | 238 |
243 // Restack |child| properly above its transient parent, if they share the same | 239 // Restack |child| properly above its transient parent, if they share the same |
244 // parent. | 240 // parent. |
(...skipping 16 matching lines...) Expand all Loading... | |
261 // If |child| and its former transient parent share the same parent, |child| | 257 // If |child| and its former transient parent share the same parent, |child| |
262 // should be restacked properly so it is not among transient children of its | 258 // should be restacked properly so it is not among transient children of its |
263 // former parent, anymore. | 259 // former parent, anymore. |
264 if (parent() == child->parent()) | 260 if (parent() == child->parent()) |
265 RestackTransientDescendants(this, &GetStackingTarget, &ReorderImpl); | 261 RestackTransientDescendants(this, &GetStackingTarget, &ReorderImpl); |
266 | 262 |
267 for (auto& observer : observers_) | 263 for (auto& observer : observers_) |
268 observer.OnTransientWindowRemoved(this, child); | 264 observer.OnTransientWindowRemoved(this, child); |
269 } | 265 } |
270 | 266 |
271 void ServerWindow::SetModal() { | 267 void ServerWindow::SetModalType(ModalType modal_type) { |
272 is_modal_ = true; | 268 modal_type_ = modal_type; |
273 } | 269 } |
274 | 270 |
275 bool ServerWindow::Contains(const ServerWindow* window) const { | 271 bool ServerWindow::Contains(const ServerWindow* window) const { |
276 for (const ServerWindow* parent = window; parent; parent = parent->parent_) { | 272 for (const ServerWindow* parent = window; parent; parent = parent->parent_) { |
277 if (parent == this) | 273 if (parent == this) |
278 return true; | 274 return true; |
279 } | 275 } |
280 return false; | 276 return false; |
281 } | 277 } |
282 | 278 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
472 window->OnStackingChanged(); | 468 window->OnStackingChanged(); |
473 } | 469 } |
474 | 470 |
475 // static | 471 // static |
476 ServerWindow** ServerWindow::GetStackingTarget(ServerWindow* window) { | 472 ServerWindow** ServerWindow::GetStackingTarget(ServerWindow* window) { |
477 return &window->stacking_target_; | 473 return &window->stacking_target_; |
478 } | 474 } |
479 | 475 |
480 } // namespace ws | 476 } // namespace ws |
481 } // namespace ui | 477 } // namespace ui |
OLD | NEW |