| 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 16 matching lines...) Expand all Loading... |
| 27 #include "ui/compositor/compositor.h" | 27 #include "ui/compositor/compositor.h" |
| 28 #include "ui/compositor/layer.h" | 28 #include "ui/compositor/layer.h" |
| 29 #include "ui/gfx/animation/multi_animation.h" | 29 #include "ui/gfx/animation/multi_animation.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 Window::Window(WindowDelegate* delegate) | 36 Window::Window(WindowDelegate* delegate) |
| 37 : type_(client::WINDOW_TYPE_UNKNOWN), | 37 : dispatcher_(NULL), |
| 38 type_(client::WINDOW_TYPE_UNKNOWN), |
| 38 owned_by_parent_(true), | 39 owned_by_parent_(true), |
| 39 delegate_(delegate), | 40 delegate_(delegate), |
| 40 parent_(NULL), | 41 parent_(NULL), |
| 41 transient_parent_(NULL), | 42 transient_parent_(NULL), |
| 42 visible_(false), | 43 visible_(false), |
| 43 id_(-1), | 44 id_(-1), |
| 44 transparent_(false), | 45 transparent_(false), |
| 45 user_data_(NULL), | 46 user_data_(NULL), |
| 46 ignore_events_(false), | 47 ignore_events_(false), |
| 47 // Don't notify newly added observers during notification. This causes | 48 // Don't notify newly added observers during notification. This causes |
| 48 // problems for code that adds an observer as part of an observer | 49 // problems for code that adds an observer as part of an observer |
| 49 // notification (such as the workspace code). | 50 // notification (such as the workspace code). |
| 50 observers_(ObserverList<WindowObserver>::NOTIFY_EXISTING_ONLY) { | 51 observers_(ObserverList<WindowObserver>::NOTIFY_EXISTING_ONLY) { |
| 51 set_target_handler(delegate_); | 52 set_target_handler(delegate_); |
| 52 } | 53 } |
| 53 | 54 |
| 54 Window::~Window() { | 55 Window::~Window() { |
| 55 // layer_ can be NULL if Init() wasn't invoked, which can happen | 56 // layer_ can be NULL if Init() wasn't invoked, which can happen |
| 56 // only in tests. | 57 // only in tests. |
| 57 if (layer_) | 58 if (layer_) |
| 58 layer_->SuppressPaint(); | 59 layer_->SuppressPaint(); |
| 59 | 60 |
| 60 // Let the delegate know we're in the processing of destroying. | 61 // Let the delegate know we're in the processing of destroying. |
| 61 if (delegate_) | 62 if (delegate_) |
| 62 delegate_->OnWindowDestroying(); | 63 delegate_->OnWindowDestroying(); |
| 63 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowDestroying(this)); | 64 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowDestroying(this)); |
| 64 | 65 |
| 65 // Let the root know so that it can remove any references to us. | 66 // Let the root know so that it can remove any references to us. |
| 66 RootWindow* root_window = GetRootWindow(); | 67 WindowEventDispatcher* dispatcher = GetDispatcher(); |
| 67 if (root_window) | 68 if (dispatcher) |
| 68 root_window->OnWindowDestroying(this); | 69 dispatcher->OnWindowDestroying(this); |
| 69 | 70 |
| 70 // Then destroy the children. | 71 // Then destroy the children. |
| 71 RemoveOrDestroyChildren(); | 72 RemoveOrDestroyChildren(); |
| 72 | 73 |
| 73 // Removes ourselves from our transient parent (if it hasn't been done by the | 74 // Removes ourselves from our transient parent (if it hasn't been done by the |
| 74 // RootWindow). | 75 // RootWindow). |
| 75 if (transient_parent_) | 76 if (transient_parent_) |
| 76 transient_parent_->RemoveTransientChild(this); | 77 transient_parent_->RemoveTransientChild(this); |
| 77 | 78 |
| 78 // The window needs to be removed from the parent before calling the | 79 // The window needs to be removed from the parent before calling the |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 if (layer()) | 170 if (layer()) |
| 170 UpdateLayerName(name_); | 171 UpdateLayerName(name_); |
| 171 } | 172 } |
| 172 | 173 |
| 173 void Window::SetTransparent(bool transparent) { | 174 void Window::SetTransparent(bool transparent) { |
| 174 transparent_ = transparent; | 175 transparent_ = transparent; |
| 175 if (layer()) | 176 if (layer()) |
| 176 layer_->SetFillsBoundsOpaquely(!transparent_); | 177 layer_->SetFillsBoundsOpaquely(!transparent_); |
| 177 } | 178 } |
| 178 | 179 |
| 179 RootWindow* Window::GetRootWindow() { | 180 Window* Window::GetRootWindow() { |
| 180 return const_cast<RootWindow*>( | 181 return const_cast<Window*>( |
| 181 static_cast<const Window*>(this)->GetRootWindow()); | 182 static_cast<const Window*>(this)->GetRootWindow()); |
| 182 } | 183 } |
| 183 | 184 |
| 184 const RootWindow* Window::GetRootWindow() const { | 185 const Window* Window::GetRootWindow() const { |
| 185 return parent_ ? parent_->GetRootWindow() : NULL; | 186 return parent_ ? parent_->GetRootWindow() : NULL; |
| 186 } | 187 } |
| 187 | 188 |
| 189 WindowEventDispatcher* Window::GetDispatcher() { |
| 190 return const_cast<WindowEventDispatcher*>(const_cast<const Window*>(this)-> |
| 191 GetDispatcher()); |
| 192 } |
| 193 |
| 194 const WindowEventDispatcher* Window::GetDispatcher() const { |
| 195 const Window* root_window = GetRootWindow(); |
| 196 return root_window ? root_window->dispatcher_ : NULL; |
| 197 } |
| 198 |
| 188 void Window::Show() { | 199 void Window::Show() { |
| 189 SetVisible(true); | 200 SetVisible(true); |
| 190 } | 201 } |
| 191 | 202 |
| 192 void Window::Hide() { | 203 void Window::Hide() { |
| 193 for (Windows::iterator it = transient_children_.begin(); | 204 for (Windows::iterator it = transient_children_.begin(); |
| 194 it != transient_children_.end(); ++it) { | 205 it != transient_children_.end(); ++it) { |
| 195 (*it)->Hide(); | 206 (*it)->Hide(); |
| 196 } | 207 } |
| 197 SetVisible(false); | 208 SetVisible(false); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 212 // do for now. | 223 // do for now. |
| 213 if (!GetRootWindow()) | 224 if (!GetRootWindow()) |
| 214 return bounds(); | 225 return bounds(); |
| 215 gfx::Point origin = bounds().origin(); | 226 gfx::Point origin = bounds().origin(); |
| 216 ConvertPointToTarget(parent_, GetRootWindow(), &origin); | 227 ConvertPointToTarget(parent_, GetRootWindow(), &origin); |
| 217 return gfx::Rect(origin, bounds().size()); | 228 return gfx::Rect(origin, bounds().size()); |
| 218 } | 229 } |
| 219 | 230 |
| 220 gfx::Rect Window::GetBoundsInScreen() const { | 231 gfx::Rect Window::GetBoundsInScreen() const { |
| 221 gfx::Rect bounds(GetBoundsInRootWindow()); | 232 gfx::Rect bounds(GetBoundsInRootWindow()); |
| 222 const RootWindow* root = GetRootWindow(); | 233 const Window* root = GetRootWindow(); |
| 223 if (root) { | 234 if (root) { |
| 224 aura::client::ScreenPositionClient* screen_position_client = | 235 aura::client::ScreenPositionClient* screen_position_client = |
| 225 aura::client::GetScreenPositionClient(root); | 236 aura::client::GetScreenPositionClient(root); |
| 226 if (screen_position_client) { | 237 if (screen_position_client) { |
| 227 gfx::Point origin = bounds.origin(); | 238 gfx::Point origin = bounds.origin(); |
| 228 screen_position_client->ConvertPointToScreen(root, &origin); | 239 screen_position_client->ConvertPointToScreen(root, &origin); |
| 229 bounds.set_origin(origin); | 240 bounds.set_origin(origin); |
| 230 } | 241 } |
| 231 } | 242 } |
| 232 return bounds; | 243 return bounds; |
| 233 } | 244 } |
| 234 | 245 |
| 235 void Window::SetTransform(const gfx::Transform& transform) { | 246 void Window::SetTransform(const gfx::Transform& transform) { |
| 236 RootWindow* root_window = GetRootWindow(); | 247 WindowEventDispatcher* dispatcher = GetDispatcher(); |
| 237 bool contained_mouse = IsVisible() && root_window && | 248 bool contained_mouse = IsVisible() && dispatcher && |
| 238 ContainsPointInRoot(root_window->GetLastMouseLocationInRoot()); | 249 ContainsPointInRoot(dispatcher->GetLastMouseLocationInRoot()); |
| 239 layer()->SetTransform(transform); | 250 layer()->SetTransform(transform); |
| 240 if (root_window) | 251 if (dispatcher) |
| 241 root_window->OnWindowTransformed(this, contained_mouse); | 252 dispatcher->OnWindowTransformed(this, contained_mouse); |
| 242 } | 253 } |
| 243 | 254 |
| 244 void Window::SetLayoutManager(LayoutManager* layout_manager) { | 255 void Window::SetLayoutManager(LayoutManager* layout_manager) { |
| 245 if (layout_manager == layout_manager_) | 256 if (layout_manager == layout_manager_) |
| 246 return; | 257 return; |
| 247 layout_manager_.reset(layout_manager); | 258 layout_manager_.reset(layout_manager); |
| 248 if (!layout_manager) | 259 if (!layout_manager) |
| 249 return; | 260 return; |
| 250 // If we're changing to a new layout manager, ensure it is aware of all the | 261 // If we're changing to a new layout manager, ensure it is aware of all the |
| 251 // existing child windows. | 262 // existing child windows. |
| 252 for (Windows::const_iterator it = children_.begin(); | 263 for (Windows::const_iterator it = children_.begin(); |
| 253 it != children_.end(); | 264 it != children_.end(); |
| 254 ++it) | 265 ++it) |
| 255 layout_manager_->OnWindowAddedToLayout(*it); | 266 layout_manager_->OnWindowAddedToLayout(*it); |
| 256 } | 267 } |
| 257 | 268 |
| 258 void Window::SetBounds(const gfx::Rect& new_bounds) { | 269 void Window::SetBounds(const gfx::Rect& new_bounds) { |
| 259 if (parent_ && parent_->layout_manager()) | 270 if (parent_ && parent_->layout_manager()) |
| 260 parent_->layout_manager()->SetChildBounds(this, new_bounds); | 271 parent_->layout_manager()->SetChildBounds(this, new_bounds); |
| 261 else | 272 else |
| 262 SetBoundsInternal(new_bounds); | 273 SetBoundsInternal(new_bounds); |
| 263 } | 274 } |
| 264 | 275 |
| 265 void Window::SetBoundsInScreen(const gfx::Rect& new_bounds_in_screen, | 276 void Window::SetBoundsInScreen(const gfx::Rect& new_bounds_in_screen, |
| 266 const gfx::Display& dst_display) { | 277 const gfx::Display& dst_display) { |
| 267 RootWindow* root = GetRootWindow(); | 278 Window* root = GetRootWindow(); |
| 268 if (root) { | 279 if (root) { |
| 269 gfx::Point origin = new_bounds_in_screen.origin(); | 280 gfx::Point origin = new_bounds_in_screen.origin(); |
| 270 aura::client::ScreenPositionClient* screen_position_client = | 281 aura::client::ScreenPositionClient* screen_position_client = |
| 271 aura::client::GetScreenPositionClient(root); | 282 aura::client::GetScreenPositionClient(root); |
| 272 screen_position_client->SetBounds(this, new_bounds_in_screen, dst_display); | 283 screen_position_client->SetBounds(this, new_bounds_in_screen, dst_display); |
| 273 return; | 284 return; |
| 274 } | 285 } |
| 275 SetBounds(new_bounds_in_screen); | 286 SetBounds(new_bounds_in_screen); |
| 276 } | 287 } |
| 277 | 288 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 } | 322 } |
| 312 | 323 |
| 313 void Window::AddChild(Window* child) { | 324 void Window::AddChild(Window* child) { |
| 314 WindowObserver::HierarchyChangeParams params; | 325 WindowObserver::HierarchyChangeParams params; |
| 315 params.target = child; | 326 params.target = child; |
| 316 params.new_parent = this; | 327 params.new_parent = this; |
| 317 params.old_parent = child->parent(); | 328 params.old_parent = child->parent(); |
| 318 params.phase = WindowObserver::HierarchyChangeParams::HIERARCHY_CHANGING; | 329 params.phase = WindowObserver::HierarchyChangeParams::HIERARCHY_CHANGING; |
| 319 NotifyWindowHierarchyChange(params); | 330 NotifyWindowHierarchyChange(params); |
| 320 | 331 |
| 321 RootWindow* old_root = child->GetRootWindow(); | 332 Window* old_root = child->GetRootWindow(); |
| 322 | 333 |
| 323 DCHECK(std::find(children_.begin(), children_.end(), child) == | 334 DCHECK(std::find(children_.begin(), children_.end(), child) == |
| 324 children_.end()); | 335 children_.end()); |
| 325 if (child->parent()) | 336 if (child->parent()) |
| 326 child->parent()->RemoveChildImpl(child, this); | 337 child->parent()->RemoveChildImpl(child, this); |
| 327 child->parent_ = this; | 338 child->parent_ = this; |
| 328 | 339 |
| 329 layer_->Add(child->layer_); | 340 layer_->Add(child->layer_); |
| 330 | 341 |
| 331 children_.push_back(child); | 342 children_.push_back(child); |
| 332 if (layout_manager_) | 343 if (layout_manager_) |
| 333 layout_manager_->OnWindowAddedToLayout(child); | 344 layout_manager_->OnWindowAddedToLayout(child); |
| 334 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowAdded(child)); | 345 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowAdded(child)); |
| 335 child->OnParentChanged(); | 346 child->OnParentChanged(); |
| 336 | 347 |
| 337 RootWindow* root_window = GetRootWindow(); | 348 Window* root_window = GetRootWindow(); |
| 338 if (root_window && old_root != root_window) { | 349 if (root_window && old_root != root_window) { |
| 339 root_window->OnWindowAddedToRootWindow(child); | 350 root_window->GetDispatcher()->OnWindowAddedToRootWindow(child); |
| 340 child->NotifyAddedToRootWindow(); | 351 child->NotifyAddedToRootWindow(); |
| 341 } | 352 } |
| 342 | 353 |
| 343 params.phase = WindowObserver::HierarchyChangeParams::HIERARCHY_CHANGED; | 354 params.phase = WindowObserver::HierarchyChangeParams::HIERARCHY_CHANGED; |
| 344 NotifyWindowHierarchyChange(params); | 355 NotifyWindowHierarchyChange(params); |
| 345 } | 356 } |
| 346 | 357 |
| 347 void Window::RemoveChild(Window* child) { | 358 void Window::RemoveChild(Window* child) { |
| 348 WindowObserver::HierarchyChangeParams params; | 359 WindowObserver::HierarchyChangeParams params; |
| 349 params.target = child; | 360 params.target = child; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 } | 416 } |
| 406 | 417 |
| 407 // static | 418 // static |
| 408 void Window::ConvertPointToTarget(const Window* source, | 419 void Window::ConvertPointToTarget(const Window* source, |
| 409 const Window* target, | 420 const Window* target, |
| 410 gfx::Point* point) { | 421 gfx::Point* point) { |
| 411 if (!source) | 422 if (!source) |
| 412 return; | 423 return; |
| 413 if (source->GetRootWindow() != target->GetRootWindow()) { | 424 if (source->GetRootWindow() != target->GetRootWindow()) { |
| 414 client::ScreenPositionClient* source_client = | 425 client::ScreenPositionClient* source_client = |
| 415 GetScreenPositionClient(source->GetRootWindow()); | 426 client::GetScreenPositionClient(source->GetRootWindow()); |
| 416 source_client->ConvertPointToScreen(source, point); | 427 source_client->ConvertPointToScreen(source, point); |
| 417 | 428 |
| 418 client::ScreenPositionClient* target_client = | 429 client::ScreenPositionClient* target_client = |
| 419 GetScreenPositionClient(target->GetRootWindow()); | 430 client::GetScreenPositionClient(target->GetRootWindow()); |
| 420 target_client->ConvertPointFromScreen(target, point); | 431 target_client->ConvertPointFromScreen(target, point); |
| 421 } else { | 432 } else { |
| 422 ui::Layer::ConvertPointToLayer(source->layer(), target->layer(), point); | 433 ui::Layer::ConvertPointToLayer(source->layer(), target->layer(), point); |
| 423 } | 434 } |
| 424 } | 435 } |
| 425 | 436 |
| 426 void Window::MoveCursorTo(const gfx::Point& point_in_window) { | 437 void Window::MoveCursorTo(const gfx::Point& point_in_window) { |
| 427 RootWindow* root_window = GetRootWindow(); | 438 Window* root_window = GetRootWindow(); |
| 428 DCHECK(root_window); | 439 DCHECK(root_window); |
| 429 gfx::Point point_in_root(point_in_window); | 440 gfx::Point point_in_root(point_in_window); |
| 430 ConvertPointToTarget(this, root_window, &point_in_root); | 441 ConvertPointToTarget(this, root_window, &point_in_root); |
| 431 root_window->MoveCursorTo(point_in_root); | 442 root_window->GetDispatcher()->MoveCursorTo(point_in_root); |
| 432 } | 443 } |
| 433 | 444 |
| 434 gfx::NativeCursor Window::GetCursor(const gfx::Point& point) const { | 445 gfx::NativeCursor Window::GetCursor(const gfx::Point& point) const { |
| 435 return delegate_ ? delegate_->GetCursor(point) : gfx::kNullCursor; | 446 return delegate_ ? delegate_->GetCursor(point) : gfx::kNullCursor; |
| 436 } | 447 } |
| 437 | 448 |
| 438 void Window::SetEventFilter(ui::EventHandler* event_filter) { | 449 void Window::SetEventFilter(ui::EventHandler* event_filter) { |
| 439 if (event_filter_) | 450 if (event_filter_) |
| 440 RemovePreTargetHandler(event_filter_.get()); | 451 RemovePreTargetHandler(event_filter_.get()); |
| 441 event_filter_.reset(event_filter); | 452 event_filter_.reset(event_filter); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 if (client && !client->CanProcessEventsWithinSubtree(this)) | 558 if (client && !client->CanProcessEventsWithinSubtree(this)) |
| 548 return false; | 559 return false; |
| 549 | 560 |
| 550 return parent_ && IsVisible() && parent_->CanReceiveEvents(); | 561 return parent_ && IsVisible() && parent_->CanReceiveEvents(); |
| 551 } | 562 } |
| 552 | 563 |
| 553 void Window::SetCapture() { | 564 void Window::SetCapture() { |
| 554 if (!IsVisible()) | 565 if (!IsVisible()) |
| 555 return; | 566 return; |
| 556 | 567 |
| 557 RootWindow* root_window = GetRootWindow(); | 568 Window* root_window = GetRootWindow(); |
| 558 if (!root_window) | 569 if (!root_window) |
| 559 return; | 570 return; |
| 560 client::GetCaptureClient(root_window)->SetCapture(this); | 571 client::GetCaptureClient(root_window)->SetCapture(this); |
| 561 } | 572 } |
| 562 | 573 |
| 563 void Window::ReleaseCapture() { | 574 void Window::ReleaseCapture() { |
| 564 RootWindow* root_window = GetRootWindow(); | 575 Window* root_window = GetRootWindow(); |
| 565 if (!root_window) | 576 if (!root_window) |
| 566 return; | 577 return; |
| 567 client::GetCaptureClient(root_window)->ReleaseCapture(this); | 578 client::GetCaptureClient(root_window)->ReleaseCapture(this); |
| 568 } | 579 } |
| 569 | 580 |
| 570 bool Window::HasCapture() { | 581 bool Window::HasCapture() { |
| 571 RootWindow* root_window = GetRootWindow(); | 582 Window* root_window = GetRootWindow(); |
| 572 return root_window && | 583 return root_window && |
| 573 client::GetCaptureClient(root_window)->GetCaptureWindow() == this; | 584 client::GetCaptureClient(root_window)->GetCaptureWindow() == this; |
| 574 } | 585 } |
| 575 | 586 |
| 576 void Window::SuppressPaint() { | 587 void Window::SuppressPaint() { |
| 577 layer_->SuppressPaint(); | 588 layer_->SuppressPaint(); |
| 578 } | 589 } |
| 579 | 590 |
| 580 // {Set,Get,Clear}Property are implemented in window_property.h. | 591 // {Set,Get,Clear}Property are implemented in window_property.h. |
| 581 | 592 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 OnLayerBoundsChanged(old_bounds, ContainsMouse()); | 698 OnLayerBoundsChanged(old_bounds, ContainsMouse()); |
| 688 } | 699 } |
| 689 | 700 |
| 690 void Window::SetVisible(bool visible) { | 701 void Window::SetVisible(bool visible) { |
| 691 if (visible == layer_->GetTargetVisibility()) | 702 if (visible == layer_->GetTargetVisibility()) |
| 692 return; // No change. | 703 return; // No change. |
| 693 | 704 |
| 694 FOR_EACH_OBSERVER(WindowObserver, observers_, | 705 FOR_EACH_OBSERVER(WindowObserver, observers_, |
| 695 OnWindowVisibilityChanging(this, visible)); | 706 OnWindowVisibilityChanging(this, visible)); |
| 696 | 707 |
| 697 RootWindow* root_window = GetRootWindow(); | 708 WindowEventDispatcher* dispatcher = GetDispatcher(); |
| 698 if (root_window) | 709 if (dispatcher) |
| 699 root_window->DispatchMouseExitToHidingWindow(this); | 710 dispatcher->DispatchMouseExitToHidingWindow(this); |
| 700 | 711 |
| 701 client::VisibilityClient* visibility_client = | 712 client::VisibilityClient* visibility_client = |
| 702 client::GetVisibilityClient(this); | 713 client::GetVisibilityClient(this); |
| 703 if (visibility_client) | 714 if (visibility_client) |
| 704 visibility_client->UpdateLayerVisibility(this, visible); | 715 visibility_client->UpdateLayerVisibility(this, visible); |
| 705 else | 716 else |
| 706 layer_->SetVisible(visible); | 717 layer_->SetVisible(visible); |
| 707 visible_ = visible; | 718 visible_ = visible; |
| 708 SchedulePaint(); | 719 SchedulePaint(); |
| 709 if (parent_ && parent_->layout_manager_) | 720 if (parent_ && parent_->layout_manager_) |
| 710 parent_->layout_manager_->OnChildWindowVisibilityChanged(this, visible); | 721 parent_->layout_manager_->OnChildWindowVisibilityChanged(this, visible); |
| 711 | 722 |
| 712 if (delegate_) | 723 if (delegate_) |
| 713 delegate_->OnWindowTargetVisibilityChanged(visible); | 724 delegate_->OnWindowTargetVisibilityChanged(visible); |
| 714 | 725 |
| 715 NotifyWindowVisibilityChanged(this, visible); | 726 NotifyWindowVisibilityChanged(this, visible); |
| 716 | 727 |
| 717 if (root_window) | 728 if (dispatcher) |
| 718 root_window->OnWindowVisibilityChanged(this, visible); | 729 dispatcher->OnWindowVisibilityChanged(this, visible); |
| 719 } | 730 } |
| 720 | 731 |
| 721 void Window::SchedulePaint() { | 732 void Window::SchedulePaint() { |
| 722 SchedulePaintInRect(gfx::Rect(0, 0, bounds().width(), bounds().height())); | 733 SchedulePaintInRect(gfx::Rect(0, 0, bounds().width(), bounds().height())); |
| 723 } | 734 } |
| 724 | 735 |
| 725 Window* Window::GetWindowForPoint(const gfx::Point& local_point, | 736 Window* Window::GetWindowForPoint(const gfx::Point& local_point, |
| 726 bool return_tightest, | 737 bool return_tightest, |
| 727 bool for_event_handling) { | 738 bool for_event_handling) { |
| 728 if (!IsVisible()) | 739 if (!IsVisible()) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 return match; | 786 return match; |
| 776 } | 787 } |
| 777 | 788 |
| 778 return delegate_ ? this : NULL; | 789 return delegate_ ? this : NULL; |
| 779 } | 790 } |
| 780 | 791 |
| 781 void Window::RemoveChildImpl(Window* child, Window* new_parent) { | 792 void Window::RemoveChildImpl(Window* child, Window* new_parent) { |
| 782 if (layout_manager_) | 793 if (layout_manager_) |
| 783 layout_manager_->OnWillRemoveWindowFromLayout(child); | 794 layout_manager_->OnWillRemoveWindowFromLayout(child); |
| 784 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWillRemoveWindow(child)); | 795 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWillRemoveWindow(child)); |
| 785 RootWindow* root_window = child->GetRootWindow(); | 796 Window* root_window = child->GetRootWindow(); |
| 786 RootWindow* new_root_window = new_parent ? new_parent->GetRootWindow() : NULL; | 797 Window* new_root_window = new_parent ? new_parent->GetRootWindow() : NULL; |
| 787 if (root_window && root_window != new_root_window) { | 798 if (root_window && root_window != new_root_window) { |
| 788 root_window->OnWindowRemovedFromRootWindow(child, new_root_window); | 799 root_window->GetDispatcher()->OnWindowRemovedFromRootWindow( |
| 800 child, new_root_window); |
| 789 child->NotifyRemovingFromRootWindow(); | 801 child->NotifyRemovingFromRootWindow(); |
| 790 } | 802 } |
| 791 child->parent_ = NULL; | 803 child->parent_ = NULL; |
| 792 // We should only remove the child's layer if the child still owns that layer. | 804 // We should only remove the child's layer if the child still owns that layer. |
| 793 // Someone else may have acquired ownership of it via AcquireLayer() and may | 805 // Someone else may have acquired ownership of it via AcquireLayer() and may |
| 794 // expect the hierarchy to go unchanged as the Window is destroyed. | 806 // expect the hierarchy to go unchanged as the Window is destroyed. |
| 795 if (child->layer_owner_) | 807 if (child->layer_owner_) |
| 796 layer_->Remove(child->layer_); | 808 layer_->Remove(child->layer_); |
| 797 Windows::iterator i = std::find(children_.begin(), children_.end(), child); | 809 Windows::iterator i = std::find(children_.begin(), children_.end(), child); |
| 798 DCHECK(i != children_.end()); | 810 DCHECK(i != children_.end()); |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 | 1089 |
| 1078 void Window::OnLayerBoundsChanged(const gfx::Rect& old_bounds, | 1090 void Window::OnLayerBoundsChanged(const gfx::Rect& old_bounds, |
| 1079 bool contained_mouse) { | 1091 bool contained_mouse) { |
| 1080 if (layout_manager_) | 1092 if (layout_manager_) |
| 1081 layout_manager_->OnWindowResized(); | 1093 layout_manager_->OnWindowResized(); |
| 1082 if (delegate_) | 1094 if (delegate_) |
| 1083 delegate_->OnBoundsChanged(old_bounds, bounds()); | 1095 delegate_->OnBoundsChanged(old_bounds, bounds()); |
| 1084 FOR_EACH_OBSERVER(WindowObserver, | 1096 FOR_EACH_OBSERVER(WindowObserver, |
| 1085 observers_, | 1097 observers_, |
| 1086 OnWindowBoundsChanged(this, old_bounds, bounds())); | 1098 OnWindowBoundsChanged(this, old_bounds, bounds())); |
| 1087 RootWindow* root_window = GetRootWindow(); | 1099 WindowEventDispatcher* dispatcher = GetDispatcher(); |
| 1088 if (root_window) | 1100 if (dispatcher) |
| 1089 root_window->OnWindowBoundsChanged(this, contained_mouse); | 1101 dispatcher->OnWindowBoundsChanged(this, contained_mouse); |
| 1090 } | 1102 } |
| 1091 | 1103 |
| 1092 void Window::OnPaintLayer(gfx::Canvas* canvas) { | 1104 void Window::OnPaintLayer(gfx::Canvas* canvas) { |
| 1093 if (delegate_) | 1105 if (delegate_) |
| 1094 delegate_->OnPaint(canvas); | 1106 delegate_->OnPaint(canvas); |
| 1095 } | 1107 } |
| 1096 | 1108 |
| 1097 base::Closure Window::PrepareForLayerBoundsChange() { | 1109 base::Closure Window::PrepareForLayerBoundsChange() { |
| 1098 return base::Bind(&Window::OnLayerBoundsChanged, base::Unretained(this), | 1110 return base::Bind(&Window::OnLayerBoundsChanged, base::Unretained(this), |
| 1099 bounds(), ContainsMouse()); | 1111 bounds(), ContainsMouse()); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1127 base::snprintf(id_buf, sizeof(id_buf), " %d", id_); | 1139 base::snprintf(id_buf, sizeof(id_buf), " %d", id_); |
| 1128 layer_name.append(id_buf); | 1140 layer_name.append(id_buf); |
| 1129 } | 1141 } |
| 1130 layer()->set_name(layer_name); | 1142 layer()->set_name(layer_name); |
| 1131 #endif | 1143 #endif |
| 1132 } | 1144 } |
| 1133 | 1145 |
| 1134 bool Window::ContainsMouse() { | 1146 bool Window::ContainsMouse() { |
| 1135 bool contains_mouse = false; | 1147 bool contains_mouse = false; |
| 1136 if (IsVisible()) { | 1148 if (IsVisible()) { |
| 1137 RootWindow* root_window = GetRootWindow(); | 1149 WindowEventDispatcher* dispatcher = GetDispatcher(); |
| 1138 contains_mouse = root_window && | 1150 contains_mouse = dispatcher && |
| 1139 ContainsPointInRoot(root_window->GetLastMouseLocationInRoot()); | 1151 ContainsPointInRoot(dispatcher->GetLastMouseLocationInRoot()); |
| 1140 } | 1152 } |
| 1141 return contains_mouse; | 1153 return contains_mouse; |
| 1142 } | 1154 } |
| 1143 | 1155 |
| 1144 } // namespace aura | 1156 } // namespace aura |
| OLD | NEW |