Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(552)

Unified Diff: ui/aura/window.cc

Issue 7976020: Wires up mouse capture code for aura. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix aura build Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura/window.h ('k') | ui/aura/window_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()));
}
« no previous file with comments | « ui/aura/window.h ('k') | ui/aura/window_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698