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 "components/mus/public/cpp/window.h" | 5 #include "components/mus/public/cpp/window.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <set> | 10 #include <set> |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 } | 339 } |
340 | 340 |
341 void Window::RemoveTransientWindow(Window* transient_window) { | 341 void Window::RemoveTransientWindow(Window* transient_window) { |
342 if (connection_) | 342 if (connection_) |
343 CHECK_EQ(transient_window->connection(), connection_); | 343 CHECK_EQ(transient_window->connection(), connection_); |
344 LocalRemoveTransientWindow(transient_window); | 344 LocalRemoveTransientWindow(transient_window); |
345 if (connection_) | 345 if (connection_) |
346 tree_client()->RemoveTransientWindowFromParent(transient_window); | 346 tree_client()->RemoveTransientWindowFromParent(transient_window); |
347 } | 347 } |
348 | 348 |
349 void Window::SetModal() { | |
350 LocalSetModal(); | |
sky
2016/03/10 00:21:43
Early out if already modal.
mohsen
2016/03/10 03:23:16
Done.
| |
351 if (connection_) | |
352 tree_client()->SetModal(this); | |
353 } | |
354 | |
349 Window* Window::GetChildById(Id id) { | 355 Window* Window::GetChildById(Id id) { |
350 if (id == id_) | 356 if (id == id_) |
351 return this; | 357 return this; |
352 // TODO(beng): this could be improved depending on how we decide to own | 358 // TODO(beng): this could be improved depending on how we decide to own |
353 // windows. | 359 // windows. |
354 Children::const_iterator it = children_.begin(); | 360 Children::const_iterator it = children_.begin(); |
355 for (; it != children_.end(); ++it) { | 361 for (; it != children_.end(); ++it) { |
356 Window* window = (*it)->GetChildById(id); | 362 Window* window = (*it)->GetChildById(id); |
357 if (window) | 363 if (window) |
358 return window; | 364 return window; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
486 | 492 |
487 //////////////////////////////////////////////////////////////////////////////// | 493 //////////////////////////////////////////////////////////////////////////////// |
488 // Window, private: | 494 // Window, private: |
489 | 495 |
490 Window::Window(WindowTreeConnection* connection, Id id) | 496 Window::Window(WindowTreeConnection* connection, Id id) |
491 : connection_(connection), | 497 : connection_(connection), |
492 id_(id), | 498 id_(id), |
493 parent_(nullptr), | 499 parent_(nullptr), |
494 stacking_target_(nullptr), | 500 stacking_target_(nullptr), |
495 transient_parent_(nullptr), | 501 transient_parent_(nullptr), |
502 is_modal_(false), | |
496 input_event_handler_(nullptr), | 503 input_event_handler_(nullptr), |
497 viewport_metrics_(CreateEmptyViewportMetrics()), | 504 viewport_metrics_(CreateEmptyViewportMetrics()), |
498 visible_(false), | 505 visible_(false), |
499 cursor_id_(mojom::Cursor::CURSOR_NULL), | 506 cursor_id_(mojom::Cursor::CURSOR_NULL), |
500 drawn_(false) {} | 507 drawn_(false) {} |
501 | 508 |
502 WindowTreeClientImpl* Window::tree_client() { | 509 WindowTreeClientImpl* Window::tree_client() { |
503 return static_cast<WindowTreeClientImpl*>(connection_); | 510 return static_cast<WindowTreeClientImpl*>(connection_); |
504 } | 511 } |
505 | 512 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
581 | 588 |
582 // TODO(fsamuel): We might want a notification here. | 589 // TODO(fsamuel): We might want a notification here. |
583 } | 590 } |
584 | 591 |
585 void Window::LocalRemoveTransientWindow(Window* transient_window) { | 592 void Window::LocalRemoveTransientWindow(Window* transient_window) { |
586 DCHECK_EQ(this, transient_window->transient_parent()); | 593 DCHECK_EQ(this, transient_window->transient_parent()); |
587 RemoveTransientWindowImpl(transient_window); | 594 RemoveTransientWindowImpl(transient_window); |
588 // TODO(fsamuel): We might want a notification here. | 595 // TODO(fsamuel): We might want a notification here. |
589 } | 596 } |
590 | 597 |
598 void Window::LocalSetModal() { | |
599 is_modal_ = true; | |
600 } | |
601 | |
591 bool Window::LocalReorder(Window* relative, mojom::OrderDirection direction) { | 602 bool Window::LocalReorder(Window* relative, mojom::OrderDirection direction) { |
592 OrderChangedNotifier notifier(this, relative, direction); | 603 OrderChangedNotifier notifier(this, relative, direction); |
593 return ReorderImpl(this, relative, direction, ¬ifier); | 604 return ReorderImpl(this, relative, direction, ¬ifier); |
594 } | 605 } |
595 | 606 |
596 void Window::LocalSetBounds(const gfx::Rect& old_bounds, | 607 void Window::LocalSetBounds(const gfx::Rect& old_bounds, |
597 const gfx::Rect& new_bounds) { | 608 const gfx::Rect& new_bounds) { |
598 // If this client owns the window, then it should be the only one to change | 609 // If this client owns the window, then it should be the only one to change |
599 // the bounds. | 610 // the bounds. |
600 DCHECK(!OwnsWindow(connection_, this) || old_bounds == bounds_); | 611 DCHECK(!OwnsWindow(connection_, this) || old_bounds == bounds_); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
826 notifier->NotifyWindowReordered(); | 837 notifier->NotifyWindowReordered(); |
827 | 838 |
828 return true; | 839 return true; |
829 } | 840 } |
830 | 841 |
831 // static | 842 // static |
832 Window** Window::GetStackingTarget(Window* window) { | 843 Window** Window::GetStackingTarget(Window* window) { |
833 return &window->stacking_target_; | 844 return &window->stacking_target_; |
834 } | 845 } |
835 } // namespace mus | 846 } // namespace mus |
OLD | NEW |