| OLD | NEW |
| 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 #include "ui/aura/window.h" | 5 #include "ui/aura/window.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "ui/aura/client/event_client.h" | 23 #include "ui/aura/client/event_client.h" |
| 24 #include "ui/aura/client/focus_client.h" | 24 #include "ui/aura/client/focus_client.h" |
| 25 #include "ui/aura/client/screen_position_client.h" | 25 #include "ui/aura/client/screen_position_client.h" |
| 26 #include "ui/aura/client/visibility_client.h" | 26 #include "ui/aura/client/visibility_client.h" |
| 27 #include "ui/aura/client/window_stacking_client.h" | 27 #include "ui/aura/client/window_stacking_client.h" |
| 28 #include "ui/aura/env.h" | 28 #include "ui/aura/env.h" |
| 29 #include "ui/aura/layout_manager.h" | 29 #include "ui/aura/layout_manager.h" |
| 30 #include "ui/aura/window_delegate.h" | 30 #include "ui/aura/window_delegate.h" |
| 31 #include "ui/aura/window_event_dispatcher.h" | 31 #include "ui/aura/window_event_dispatcher.h" |
| 32 #include "ui/aura/window_observer.h" | 32 #include "ui/aura/window_observer.h" |
| 33 #include "ui/aura/window_port.h" |
| 34 #include "ui/aura/window_port_local.h" |
| 33 #include "ui/aura/window_tracker.h" | 35 #include "ui/aura/window_tracker.h" |
| 34 #include "ui/aura/window_tree_host.h" | 36 #include "ui/aura/window_tree_host.h" |
| 35 #include "ui/compositor/compositor.h" | 37 #include "ui/compositor/compositor.h" |
| 36 #include "ui/compositor/layer.h" | 38 #include "ui/compositor/layer.h" |
| 37 #include "ui/display/display.h" | 39 #include "ui/display/display.h" |
| 38 #include "ui/display/screen.h" | 40 #include "ui/display/screen.h" |
| 39 #include "ui/events/event_target_iterator.h" | 41 #include "ui/events/event_target_iterator.h" |
| 40 #include "ui/gfx/canvas.h" | 42 #include "ui/gfx/canvas.h" |
| 41 #include "ui/gfx/path.h" | 43 #include "ui/gfx/path.h" |
| 42 #include "ui/gfx/scoped_canvas.h" | 44 #include "ui/gfx/scoped_canvas.h" |
| 43 | 45 |
| 44 namespace aura { | 46 namespace aura { |
| 45 | 47 |
| 46 class ScopedCursorHider { | 48 Window::Window(WindowDelegate* delegate) : Window(delegate, nullptr) {} |
| 47 public: | |
| 48 explicit ScopedCursorHider(Window* window) | |
| 49 : window_(window), | |
| 50 hid_cursor_(false) { | |
| 51 if (!window_->IsRootWindow()) | |
| 52 return; | |
| 53 const bool cursor_is_in_bounds = window_->GetBoundsInScreen().Contains( | |
| 54 Env::GetInstance()->last_mouse_location()); | |
| 55 client::CursorClient* cursor_client = client::GetCursorClient(window_); | |
| 56 if (cursor_is_in_bounds && cursor_client && | |
| 57 cursor_client->IsCursorVisible()) { | |
| 58 cursor_client->HideCursor(); | |
| 59 hid_cursor_ = true; | |
| 60 } | |
| 61 } | |
| 62 ~ScopedCursorHider() { | |
| 63 if (!window_->IsRootWindow()) | |
| 64 return; | |
| 65 | 49 |
| 66 // Update the device scale factor of the cursor client only when the last | 50 Window::Window(WindowDelegate* delegate, std::unique_ptr<WindowPort> port) |
| 67 // mouse location is on this root window. | 51 : port_owner_(std::move(port)), |
| 68 if (hid_cursor_) { | 52 port_(port_owner_.get()), |
| 69 client::CursorClient* cursor_client = client::GetCursorClient(window_); | 53 host_(nullptr), |
| 70 if (cursor_client) { | |
| 71 const display::Display& display = | |
| 72 display::Screen::GetScreen()->GetDisplayNearestWindow(window_); | |
| 73 cursor_client->SetDisplay(display); | |
| 74 cursor_client->ShowCursor(); | |
| 75 } | |
| 76 } | |
| 77 } | |
| 78 | |
| 79 private: | |
| 80 Window* window_; | |
| 81 bool hid_cursor_; | |
| 82 | |
| 83 DISALLOW_COPY_AND_ASSIGN(ScopedCursorHider); | |
| 84 }; | |
| 85 | |
| 86 Window::Window(WindowDelegate* delegate) | |
| 87 : host_(NULL), | |
| 88 type_(ui::wm::WINDOW_TYPE_UNKNOWN), | 54 type_(ui::wm::WINDOW_TYPE_UNKNOWN), |
| 89 owned_by_parent_(true), | 55 owned_by_parent_(true), |
| 90 delegate_(delegate), | 56 delegate_(delegate), |
| 91 parent_(NULL), | 57 parent_(nullptr), |
| 92 visible_(false), | 58 visible_(false), |
| 93 id_(kInitialId), | 59 id_(kInitialId), |
| 94 transparent_(false), | 60 transparent_(false), |
| 95 user_data_(NULL), | 61 user_data_(nullptr), |
| 96 ignore_events_(false), | 62 ignore_events_(false), |
| 97 // Don't notify newly added observers during notification. This causes | 63 // Don't notify newly added observers during notification. This causes |
| 98 // problems for code that adds an observer as part of an observer | 64 // problems for code that adds an observer as part of an observer |
| 99 // notification (such as the workspace code). | 65 // notification (such as the workspace code). |
| 100 observers_(base::ObserverList<WindowObserver>::NOTIFY_EXISTING_ONLY) { | 66 observers_(base::ObserverList<WindowObserver>::NOTIFY_EXISTING_ONLY) { |
| 101 SetTargetHandler(delegate_); | 67 SetTargetHandler(delegate_); |
| 102 } | 68 } |
| 103 | 69 |
| 104 Window::~Window() { | 70 Window::~Window() { |
| 71 // See comment in header as to why this is done. |
| 72 std::unique_ptr<WindowPort> port = std::move(port_owner_); |
| 73 |
| 105 if (layer()->owner() == this) | 74 if (layer()->owner() == this) |
| 106 layer()->CompleteAllAnimations(); | 75 layer()->CompleteAllAnimations(); |
| 107 layer()->SuppressPaint(); | 76 layer()->SuppressPaint(); |
| 108 | 77 |
| 109 // Let the delegate know we're in the processing of destroying. | 78 // Let the delegate know we're in the processing of destroying. |
| 110 if (delegate_) | 79 if (delegate_) |
| 111 delegate_->OnWindowDestroying(this); | 80 delegate_->OnWindowDestroying(this); |
| 112 for (WindowObserver& observer : observers_) | 81 for (WindowObserver& observer : observers_) |
| 113 observer.OnWindowDestroying(this); | 82 observer.OnWindowDestroying(this); |
| 114 | 83 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 } | 132 } |
| 164 prop_map_.clear(); | 133 prop_map_.clear(); |
| 165 | 134 |
| 166 // The layer will either be destroyed by |layer_owner_|'s dtor, or by whoever | 135 // The layer will either be destroyed by |layer_owner_|'s dtor, or by whoever |
| 167 // acquired it. | 136 // acquired it. |
| 168 layer()->set_delegate(NULL); | 137 layer()->set_delegate(NULL); |
| 169 DestroyLayer(); | 138 DestroyLayer(); |
| 170 } | 139 } |
| 171 | 140 |
| 172 void Window::Init(ui::LayerType layer_type) { | 141 void Window::Init(ui::LayerType layer_type) { |
| 142 if (!port_owner_) { |
| 143 port_owner_ = Env::GetInstance()->CreateWindowPort(this); |
| 144 port_ = port_owner_.get(); |
| 145 } |
| 173 SetLayer(new ui::Layer(layer_type)); | 146 SetLayer(new ui::Layer(layer_type)); |
| 147 std::unique_ptr<WindowPortInitData> init_data = port_->OnPreInit(this); |
| 174 layer()->SetVisible(false); | 148 layer()->SetVisible(false); |
| 175 layer()->set_delegate(this); | 149 layer()->set_delegate(this); |
| 176 UpdateLayerName(); | 150 UpdateLayerName(); |
| 177 layer()->SetFillsBoundsOpaquely(!transparent_); | 151 layer()->SetFillsBoundsOpaquely(!transparent_); |
| 178 Env::GetInstance()->NotifyWindowInitialized(this); | 152 Env::GetInstance()->NotifyWindowInitialized(this); |
| 153 port_->OnPostInit(std::move(init_data)); |
| 179 } | 154 } |
| 180 | 155 |
| 181 void Window::SetType(ui::wm::WindowType type) { | 156 void Window::SetType(ui::wm::WindowType type) { |
| 182 // Cannot change type after the window is initialized. | 157 // Cannot change type after the window is initialized. |
| 183 DCHECK(!layer()); | 158 DCHECK(!layer()); |
| 184 type_ = type; | 159 type_ = type; |
| 185 } | 160 } |
| 186 | 161 |
| 187 void Window::SetName(const std::string& name) { | 162 void Window::SetName(const std::string& name) { |
| 188 name_ = name; | 163 name_ = name; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 DCHECK(child->layer()) << "Child has not been Init()ed yt."; | 341 DCHECK(child->layer()) << "Child has not been Init()ed yt."; |
| 367 WindowObserver::HierarchyChangeParams params; | 342 WindowObserver::HierarchyChangeParams params; |
| 368 params.target = child; | 343 params.target = child; |
| 369 params.new_parent = this; | 344 params.new_parent = this; |
| 370 params.old_parent = child->parent(); | 345 params.old_parent = child->parent(); |
| 371 params.phase = WindowObserver::HierarchyChangeParams::HIERARCHY_CHANGING; | 346 params.phase = WindowObserver::HierarchyChangeParams::HIERARCHY_CHANGING; |
| 372 NotifyWindowHierarchyChange(params); | 347 NotifyWindowHierarchyChange(params); |
| 373 | 348 |
| 374 Window* old_root = child->GetRootWindow(); | 349 Window* old_root = child->GetRootWindow(); |
| 375 | 350 |
| 351 port_->OnWillAddChild(child); |
| 352 |
| 376 DCHECK(std::find(children_.begin(), children_.end(), child) == | 353 DCHECK(std::find(children_.begin(), children_.end(), child) == |
| 377 children_.end()); | 354 children_.end()); |
| 378 if (child->parent()) | 355 if (child->parent()) |
| 379 child->parent()->RemoveChildImpl(child, this); | 356 child->parent()->RemoveChildImpl(child, this); |
| 380 | 357 |
| 381 child->parent_ = this; | 358 child->parent_ = this; |
| 382 layer()->Add(child->layer()); | 359 layer()->Add(child->layer()); |
| 383 | 360 |
| 384 children_.push_back(child); | 361 children_.push_back(child); |
| 385 if (layout_manager_) | 362 if (layout_manager_) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 399 } | 376 } |
| 400 | 377 |
| 401 void Window::RemoveChild(Window* child) { | 378 void Window::RemoveChild(Window* child) { |
| 402 WindowObserver::HierarchyChangeParams params; | 379 WindowObserver::HierarchyChangeParams params; |
| 403 params.target = child; | 380 params.target = child; |
| 404 params.new_parent = NULL; | 381 params.new_parent = NULL; |
| 405 params.old_parent = this; | 382 params.old_parent = this; |
| 406 params.phase = WindowObserver::HierarchyChangeParams::HIERARCHY_CHANGING; | 383 params.phase = WindowObserver::HierarchyChangeParams::HIERARCHY_CHANGING; |
| 407 NotifyWindowHierarchyChange(params); | 384 NotifyWindowHierarchyChange(params); |
| 408 | 385 |
| 386 port_->OnWillRemoveChild(child); |
| 409 RemoveChildImpl(child, NULL); | 387 RemoveChildImpl(child, NULL); |
| 410 | 388 |
| 411 params.phase = WindowObserver::HierarchyChangeParams::HIERARCHY_CHANGED; | 389 params.phase = WindowObserver::HierarchyChangeParams::HIERARCHY_CHANGED; |
| 412 NotifyWindowHierarchyChange(params); | 390 NotifyWindowHierarchyChange(params); |
| 413 } | 391 } |
| 414 | 392 |
| 415 bool Window::Contains(const Window* other) const { | 393 bool Window::Contains(const Window* other) const { |
| 416 for (const Window* parent = other; parent; parent = parent->parent_) { | 394 for (const Window* parent = other; parent; parent = parent->parent_) { |
| 417 if (parent == this) | 395 if (parent == this) |
| 418 return true; | 396 return true; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 | 488 |
| 511 Window* Window::GetEventHandlerForPoint(const gfx::Point& local_point) { | 489 Window* Window::GetEventHandlerForPoint(const gfx::Point& local_point) { |
| 512 return GetWindowForPoint(local_point, true, true); | 490 return GetWindowForPoint(local_point, true, true); |
| 513 } | 491 } |
| 514 | 492 |
| 515 Window* Window::GetTopWindowContainingPoint(const gfx::Point& local_point) { | 493 Window* Window::GetTopWindowContainingPoint(const gfx::Point& local_point) { |
| 516 return GetWindowForPoint(local_point, false, false); | 494 return GetWindowForPoint(local_point, false, false); |
| 517 } | 495 } |
| 518 | 496 |
| 519 Window* Window::GetToplevelWindow() { | 497 Window* Window::GetToplevelWindow() { |
| 498 // TODO: this may need to call to the WindowPort. For mus this may need to |
| 499 // return for any top level. |
| 520 Window* topmost_window_with_delegate = NULL; | 500 Window* topmost_window_with_delegate = NULL; |
| 521 for (aura::Window* window = this; window != NULL; window = window->parent()) { | 501 for (aura::Window* window = this; window != NULL; window = window->parent()) { |
| 522 if (window->delegate()) | 502 if (window->delegate()) |
| 523 topmost_window_with_delegate = window; | 503 topmost_window_with_delegate = window; |
| 524 } | 504 } |
| 525 return topmost_window_with_delegate; | 505 return topmost_window_with_delegate; |
| 526 } | 506 } |
| 527 | 507 |
| 528 void Window::Focus() { | 508 void Window::Focus() { |
| 529 client::FocusClient* client = client::GetFocusClient(this); | 509 client::FocusClient* client = client::GetFocusClient(this); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 549 // The client may forbid certain windows from receiving focus at a given point | 529 // The client may forbid certain windows from receiving focus at a given point |
| 550 // in time. | 530 // in time. |
| 551 client::EventClient* client = client::GetEventClient(GetRootWindow()); | 531 client::EventClient* client = client::GetEventClient(GetRootWindow()); |
| 552 if (client && !client->CanProcessEventsWithinSubtree(this)) | 532 if (client && !client->CanProcessEventsWithinSubtree(this)) |
| 553 return false; | 533 return false; |
| 554 | 534 |
| 555 return parent_->CanFocus(); | 535 return parent_->CanFocus(); |
| 556 } | 536 } |
| 557 | 537 |
| 558 bool Window::CanReceiveEvents() const { | 538 bool Window::CanReceiveEvents() const { |
| 539 // TODO(sky): this may want to delegate to the WindowPort as for mus there |
| 540 // isn't a point in descending into windows owned by the client. |
| 559 if (IsRootWindow()) | 541 if (IsRootWindow()) |
| 560 return IsVisible(); | 542 return IsVisible(); |
| 561 | 543 |
| 562 // The client may forbid certain windows from receiving events at a given | 544 // The client may forbid certain windows from receiving events at a given |
| 563 // point in time. | 545 // point in time. |
| 564 client::EventClient* client = client::GetEventClient(GetRootWindow()); | 546 client::EventClient* client = client::GetEventClient(GetRootWindow()); |
| 565 if (client && !client->CanProcessEventsWithinSubtree(this)) | 547 if (client && !client->CanProcessEventsWithinSubtree(this)) |
| 566 return false; | 548 return false; |
| 567 | 549 |
| 568 return parent_ && IsVisible() && parent_->CanReceiveEvents(); | 550 return parent_ && IsVisible() && parent_->CanReceiveEvents(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 596 if (!root_window) | 578 if (!root_window) |
| 597 return false; | 579 return false; |
| 598 client::CaptureClient* capture_client = client::GetCaptureClient(root_window); | 580 client::CaptureClient* capture_client = client::GetCaptureClient(root_window); |
| 599 return capture_client && capture_client->GetCaptureWindow() == this; | 581 return capture_client && capture_client->GetCaptureWindow() == this; |
| 600 } | 582 } |
| 601 | 583 |
| 602 void Window::SuppressPaint() { | 584 void Window::SuppressPaint() { |
| 603 layer()->SuppressPaint(); | 585 layer()->SuppressPaint(); |
| 604 } | 586 } |
| 605 | 587 |
| 588 std::set<const void*> Window::GetAllPropertKeys() const { |
| 589 std::set<const void*> keys; |
| 590 for (auto& pair : prop_map_) |
| 591 keys.insert(pair.first); |
| 592 return keys; |
| 593 } |
| 594 |
| 606 // {Set,Get,Clear}Property are implemented in window_property.h. | 595 // {Set,Get,Clear}Property are implemented in window_property.h. |
| 607 | 596 |
| 608 void Window::SetNativeWindowProperty(const char* key, void* value) { | 597 void Window::SetNativeWindowProperty(const char* key, void* value) { |
| 609 SetPropertyInternal(key, key, NULL, reinterpret_cast<int64_t>(value), 0); | 598 SetPropertyInternal(key, key, NULL, reinterpret_cast<int64_t>(value), 0); |
| 610 } | 599 } |
| 611 | 600 |
| 612 void* Window::GetNativeWindowProperty(const char* key) const { | 601 void* Window::GetNativeWindowProperty(const char* key) const { |
| 613 return reinterpret_cast<void*>(GetPropertyInternal(key, 0)); | 602 return reinterpret_cast<void*>(GetPropertyInternal(key, 0)); |
| 614 } | 603 } |
| 615 | 604 |
| 616 void Window::OnDeviceScaleFactorChanged(float device_scale_factor) { | 605 void Window::OnDeviceScaleFactorChanged(float device_scale_factor) { |
| 617 ScopedCursorHider hider(this); | 606 port_->OnDeviceScaleFactorChanged(device_scale_factor); |
| 618 if (delegate_) | |
| 619 delegate_->OnDeviceScaleFactorChanged(device_scale_factor); | |
| 620 } | 607 } |
| 621 | 608 |
| 622 #if !defined(NDEBUG) | 609 #if !defined(NDEBUG) |
| 623 std::string Window::GetDebugInfo() const { | 610 std::string Window::GetDebugInfo() const { |
| 624 return base::StringPrintf( | 611 return base::StringPrintf( |
| 625 "%s<%d> bounds(%d, %d, %d, %d) %s %s opacity=%.1f", | 612 "%s<%d> bounds(%d, %d, %d, %d) %s %s opacity=%.1f", |
| 626 name().empty() ? "Unknown" : name().c_str(), id(), | 613 name().empty() ? "Unknown" : name().c_str(), id(), |
| 627 bounds().x(), bounds().y(), bounds().width(), bounds().height(), | 614 bounds().x(), bounds().y(), bounds().width(), bounds().height(), |
| 628 visible_ ? "WindowVisible" : "WindowHidden", | 615 visible_ ? "WindowVisible" : "WindowHidden", |
| 629 layer() ? | 616 layer() ? |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 } | 648 } |
| 662 | 649 |
| 663 /////////////////////////////////////////////////////////////////////////////// | 650 /////////////////////////////////////////////////////////////////////////////// |
| 664 // Window, private: | 651 // Window, private: |
| 665 | 652 |
| 666 int64_t Window::SetPropertyInternal(const void* key, | 653 int64_t Window::SetPropertyInternal(const void* key, |
| 667 const char* name, | 654 const char* name, |
| 668 PropertyDeallocator deallocator, | 655 PropertyDeallocator deallocator, |
| 669 int64_t value, | 656 int64_t value, |
| 670 int64_t default_value) { | 657 int64_t default_value) { |
| 658 // This code may be called before |port_| has been created. |
| 659 std::unique_ptr<WindowPortPropertyData> data = |
| 660 port_ ? port_->OnWillChangeProperty(key) : nullptr; |
| 671 int64_t old = GetPropertyInternal(key, default_value); | 661 int64_t old = GetPropertyInternal(key, default_value); |
| 672 if (value == default_value) { | 662 if (value == default_value) { |
| 673 prop_map_.erase(key); | 663 prop_map_.erase(key); |
| 674 } else { | 664 } else { |
| 675 Value prop_value; | 665 Value prop_value; |
| 676 prop_value.name = name; | 666 prop_value.name = name; |
| 677 prop_value.value = value; | 667 prop_value.value = value; |
| 678 prop_value.deallocator = deallocator; | 668 prop_value.deallocator = deallocator; |
| 679 prop_map_[key] = prop_value; | 669 prop_map_[key] = prop_value; |
| 680 } | 670 } |
| 671 if (port_) |
| 672 port_->OnPropertyChanged(key, std::move(data)); |
| 681 for (WindowObserver& observer : observers_) | 673 for (WindowObserver& observer : observers_) |
| 682 observer.OnWindowPropertyChanged(this, key, old); | 674 observer.OnWindowPropertyChanged(this, key, old); |
| 683 return old; | 675 return old; |
| 684 } | 676 } |
| 685 | 677 |
| 686 int64_t Window::GetPropertyInternal(const void* key, | 678 int64_t Window::GetPropertyInternal(const void* key, |
| 687 int64_t default_value) const { | 679 int64_t default_value) const { |
| 688 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); | 680 std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); |
| 689 if (iter == prop_map_.end()) | 681 if (iter == prop_map_.end()) |
| 690 return default_value; | 682 return default_value; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 for (WindowObserver& observer : observers_) | 720 for (WindowObserver& observer : observers_) |
| 729 observer.OnWindowVisibilityChanging(this, visible); | 721 observer.OnWindowVisibilityChanging(this, visible); |
| 730 | 722 |
| 731 client::VisibilityClient* visibility_client = | 723 client::VisibilityClient* visibility_client = |
| 732 client::GetVisibilityClient(this); | 724 client::GetVisibilityClient(this); |
| 733 if (visibility_client) | 725 if (visibility_client) |
| 734 visibility_client->UpdateLayerVisibility(this, visible); | 726 visibility_client->UpdateLayerVisibility(this, visible); |
| 735 else | 727 else |
| 736 layer()->SetVisible(visible); | 728 layer()->SetVisible(visible); |
| 737 visible_ = visible; | 729 visible_ = visible; |
| 730 port_->OnVisibilityChanged(visible); |
| 738 SchedulePaint(); | 731 SchedulePaint(); |
| 739 if (parent_ && parent_->layout_manager_) | 732 if (parent_ && parent_->layout_manager_) |
| 740 parent_->layout_manager_->OnChildWindowVisibilityChanged(this, visible); | 733 parent_->layout_manager_->OnChildWindowVisibilityChanged(this, visible); |
| 741 | 734 |
| 742 if (delegate_) | 735 if (delegate_) |
| 743 delegate_->OnWindowTargetVisibilityChanged(visible); | 736 delegate_->OnWindowTargetVisibilityChanged(visible); |
| 744 | 737 |
| 745 NotifyWindowVisibilityChanged(this, visible); | 738 NotifyWindowVisibilityChanged(this, visible); |
| 746 } | 739 } |
| 747 | 740 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 | 850 |
| 858 // Don't move the child if it is already in the right place. | 851 // Don't move the child if it is already in the right place. |
| 859 if ((direction == STACK_ABOVE && child_i == target_i + 1) || | 852 if ((direction == STACK_ABOVE && child_i == target_i + 1) || |
| 860 (direction == STACK_BELOW && child_i + 1 == target_i)) | 853 (direction == STACK_BELOW && child_i + 1 == target_i)) |
| 861 return; | 854 return; |
| 862 | 855 |
| 863 const size_t dest_i = | 856 const size_t dest_i = |
| 864 direction == STACK_ABOVE ? | 857 direction == STACK_ABOVE ? |
| 865 (child_i < target_i ? target_i : target_i + 1) : | 858 (child_i < target_i ? target_i : target_i + 1) : |
| 866 (child_i < target_i ? target_i - 1 : target_i); | 859 (child_i < target_i ? target_i - 1 : target_i); |
| 860 port_->OnWillMoveChild(child_i, dest_i); |
| 867 children_.erase(children_.begin() + child_i); | 861 children_.erase(children_.begin() + child_i); |
| 868 children_.insert(children_.begin() + dest_i, child); | 862 children_.insert(children_.begin() + dest_i, child); |
| 869 | 863 |
| 870 StackChildLayerRelativeTo(child, target, direction); | 864 StackChildLayerRelativeTo(child, target, direction); |
| 871 | 865 |
| 872 child->OnStackingChanged(); | 866 child->OnStackingChanged(); |
| 873 } | 867 } |
| 874 | 868 |
| 875 void Window::StackChildLayerRelativeTo(Window* child, | 869 void Window::StackChildLayerRelativeTo(Window* child, |
| 876 Window* target, | 870 Window* target, |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 } | 1025 } |
| 1032 | 1026 |
| 1033 void Window::OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) { | 1027 void Window::OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) { |
| 1034 DCHECK(layer()); | 1028 DCHECK(layer()); |
| 1035 for (WindowObserver& observer : observers_) | 1029 for (WindowObserver& observer : observers_) |
| 1036 observer.OnDelegatedFrameDamage(this, damage_rect_in_dip); | 1030 observer.OnDelegatedFrameDamage(this, damage_rect_in_dip); |
| 1037 } | 1031 } |
| 1038 | 1032 |
| 1039 void Window::OnLayerBoundsChanged(const gfx::Rect& old_bounds) { | 1033 void Window::OnLayerBoundsChanged(const gfx::Rect& old_bounds) { |
| 1040 bounds_ = layer()->bounds(); | 1034 bounds_ = layer()->bounds(); |
| 1035 |
| 1036 // Use |bounds_| as that is the bounds before any animations, which is what |
| 1037 // mus wants. |
| 1038 port_->OnDidChangeBounds(old_bounds, bounds_); |
| 1039 |
| 1041 if (layout_manager_) | 1040 if (layout_manager_) |
| 1042 layout_manager_->OnWindowResized(); | 1041 layout_manager_->OnWindowResized(); |
| 1043 if (delegate_) | 1042 if (delegate_) |
| 1044 delegate_->OnBoundsChanged(old_bounds, bounds_); | 1043 delegate_->OnBoundsChanged(old_bounds, bounds_); |
| 1045 for (auto& observer : observers_) | 1044 for (auto& observer : observers_) |
| 1046 observer.OnWindowBoundsChanged(this, old_bounds, bounds_); | 1045 observer.OnWindowBoundsChanged(this, old_bounds, bounds_); |
| 1047 } | 1046 } |
| 1048 | 1047 |
| 1049 bool Window::CanAcceptEvent(const ui::Event& event) { | 1048 bool Window::CanAcceptEvent(const ui::Event& event) { |
| 1050 // The client may forbid certain windows from receiving events at a given | 1049 // The client may forbid certain windows from receiving events at a given |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 layer_name = "Unnamed Window"; | 1104 layer_name = "Unnamed Window"; |
| 1106 | 1105 |
| 1107 if (id_ != -1) | 1106 if (id_ != -1) |
| 1108 layer_name += " " + base::IntToString(id_); | 1107 layer_name += " " + base::IntToString(id_); |
| 1109 | 1108 |
| 1110 layer()->set_name(layer_name); | 1109 layer()->set_name(layer_name); |
| 1111 #endif | 1110 #endif |
| 1112 } | 1111 } |
| 1113 | 1112 |
| 1114 } // namespace aura | 1113 } // namespace aura |
| OLD | NEW |