Index: ui/aura/window.cc |
diff --git a/ui/aura/window.cc b/ui/aura/window.cc |
index 6ccf808d8a7c93106a8c7afc6c8213a6a65ac8a0..e9d5b3065cb09df9ef6da095f0e4476163d626ee 100644 |
--- a/ui/aura/window.cc |
+++ b/ui/aura/window.cc |
@@ -19,6 +19,8 @@ |
namespace aura { |
+using internal::RootWindow; |
+ |
Window::Window(WindowDelegate* delegate) |
: delegate_(delegate), |
visibility_(VISIBILITY_HIDDEN), |
@@ -32,12 +34,10 @@ Window::~Window() { |
if (delegate_) |
delegate_->OnWindowDestroying(); |
- // Update the FocusManager in case we were focused. This must be done before |
- // we are removed from the hierarchy otherwise we won't be able to find the |
- // FocusManager. |
- internal::FocusManager* focus_manager = GetFocusManager(); |
- if (focus_manager && focus_manager->focused_window() == this) |
- focus_manager->SetFocusedWindow(NULL); |
+ // Let the root know so that it can remove any references to us. |
+ RootWindow* root = GetRoot(); |
+ if (root) |
+ root->WindowDestroying(this); |
// Then destroy the children. |
while (!children_.empty()) { |
@@ -70,6 +70,8 @@ void Window::SetVisibility(Visibility visibility) { |
layer_->set_visible(visibility_ != VISIBILITY_HIDDEN); |
if (layer_->visible()) |
SchedulePaint(); |
+ if (visibility_ != VISIBILITY_SHOWN) |
+ ReleaseCapture(); |
} |
void Window::SetLayoutManager(LayoutManager* layout_manager) { |
@@ -199,6 +201,34 @@ internal::FocusManager* Window::GetFocusManager() { |
return parent_ ? parent_->GetFocusManager() : NULL; |
} |
+void Window::SetCapture() { |
+ if (visibility_ != VISIBILITY_SHOWN) |
+ return; |
+ |
+ RootWindow* root = GetRoot(); |
+ if (!root) |
+ return; |
+ |
+ root->SetCapture(this); |
+} |
+ |
+void Window::ReleaseCapture() { |
+ RootWindow* root = GetRoot(); |
+ if (!root) |
+ return; |
+ |
+ root->ReleaseCapture(this); |
+} |
+ |
+bool Window::HasCapture() { |
+ RootWindow* root = GetRoot(); |
+ return root && root->capture_window() == this; |
+} |
+ |
+internal::RootWindow* Window::GetRoot() { |
+ return parent_ ? parent_->GetRoot() : NULL; |
+} |
+ |
void Window::SchedulePaint() { |
SchedulePaintInRect(gfx::Rect(0, 0, bounds_.width(), bounds_.height())); |
} |