| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "ui/aura/window_observer.h" | 26 #include "ui/aura/window_observer.h" |
| 27 #include "ui/base/animation/multi_animation.h" | 27 #include "ui/base/animation/multi_animation.h" |
| 28 #include "ui/compositor/compositor.h" | 28 #include "ui/compositor/compositor.h" |
| 29 #include "ui/compositor/layer.h" | 29 #include "ui/compositor/layer.h" |
| 30 #include "ui/gfx/canvas.h" | 30 #include "ui/gfx/canvas.h" |
| 31 #include "ui/gfx/path.h" | 31 #include "ui/gfx/path.h" |
| 32 #include "ui/gfx/screen.h" | 32 #include "ui/gfx/screen.h" |
| 33 | 33 |
| 34 namespace aura { | 34 namespace aura { |
| 35 | 35 |
| 36 namespace { | |
| 37 | |
| 38 Window* GetParentForWindow(Window* window, Window* suggested_parent) { | |
| 39 if (suggested_parent) | |
| 40 return suggested_parent; | |
| 41 if (client::GetStackingClient()) | |
| 42 return client::GetStackingClient()->GetDefaultParent( | |
| 43 window, window, gfx::Rect()); | |
| 44 return NULL; | |
| 45 } | |
| 46 | |
| 47 } // namespace | |
| 48 | |
| 49 Window::TestApi::TestApi(Window* window) : window_(window) {} | 36 Window::TestApi::TestApi(Window* window) : window_(window) {} |
| 50 | 37 |
| 51 bool Window::TestApi::OwnsLayer() const { | 38 bool Window::TestApi::OwnsLayer() const { |
| 52 return !!window_->layer_owner_.get(); | 39 return !!window_->layer_owner_.get(); |
| 53 } | 40 } |
| 54 | 41 |
| 55 bool Window::TestApi::ContainsMouse() { | 42 bool Window::TestApi::ContainsMouse() { |
| 56 return window_->ContainsMouse(); | 43 return window_->ContainsMouse(); |
| 57 } | 44 } |
| 58 | 45 |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 } | 313 } |
| 327 } | 314 } |
| 328 | 315 |
| 329 void Window::SetExternalTexture(ui::Texture* texture) { | 316 void Window::SetExternalTexture(ui::Texture* texture) { |
| 330 layer_->SetExternalTexture(texture); | 317 layer_->SetExternalTexture(texture); |
| 331 gfx::Rect region(bounds().size()); | 318 gfx::Rect region(bounds().size()); |
| 332 FOR_EACH_OBSERVER( | 319 FOR_EACH_OBSERVER( |
| 333 WindowObserver, observers_, OnWindowPaintScheduled(this, region)); | 320 WindowObserver, observers_, OnWindowPaintScheduled(this, region)); |
| 334 } | 321 } |
| 335 | 322 |
| 336 void Window::SetParent(Window* parent) { | 323 void Window::SetDefaultParentByRootWindow(RootWindow* root_window, |
| 337 GetParentForWindow(this, parent)->AddChild(this); | 324 const gfx::Rect& bounds_in_screen) { |
| 325 // TODO(erg): Enable this DCHECK once it is safe. |
| 326 // DCHECK(root_window); |
| 327 |
| 328 // Stacking clients are mandatory on RootWindow objects. |
| 329 client::StackingClient* client = client::GetStackingClient(root_window); |
| 330 DCHECK(client); |
| 331 |
| 332 aura::Window* default_parent = client->GetDefaultParent( |
| 333 root_window, this, bounds_in_screen); |
| 334 default_parent->AddChild(this); |
| 338 } | 335 } |
| 339 | 336 |
| 340 void Window::StackChildAtTop(Window* child) { | 337 void Window::StackChildAtTop(Window* child) { |
| 341 if (children_.size() <= 1 || child == children_.back()) | 338 if (children_.size() <= 1 || child == children_.back()) |
| 342 return; // In the front already. | 339 return; // In the front already. |
| 343 StackChildAbove(child, children_.back()); | 340 StackChildAbove(child, children_.back()); |
| 344 } | 341 } |
| 345 | 342 |
| 346 void Window::StackChildAbove(Window* child, Window* target) { | 343 void Window::StackChildAbove(Window* child, Window* target) { |
| 347 StackChildRelativeTo(child, target, STACK_ABOVE); | 344 StackChildRelativeTo(child, target, STACK_ABOVE); |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 bool contains_mouse = false; | 968 bool contains_mouse = false; |
| 972 if (IsVisible()) { | 969 if (IsVisible()) { |
| 973 RootWindow* root_window = GetRootWindow(); | 970 RootWindow* root_window = GetRootWindow(); |
| 974 contains_mouse = root_window && | 971 contains_mouse = root_window && |
| 975 ContainsPointInRoot(root_window->GetLastMouseLocationInRoot()); | 972 ContainsPointInRoot(root_window->GetLastMouseLocationInRoot()); |
| 976 } | 973 } |
| 977 return contains_mouse; | 974 return contains_mouse; |
| 978 } | 975 } |
| 979 | 976 |
| 980 } // namespace aura | 977 } // namespace aura |
| OLD | NEW |