Index: ui/aura/toplevel_window_event_filter.cc |
=================================================================== |
--- ui/aura/toplevel_window_event_filter.cc (revision 101829) |
+++ ui/aura/toplevel_window_event_filter.cc (working copy) |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "ui/aura/window_manager.h" |
+#include "ui/aura/toplevel_window_event_filter.h" |
#include "ui/aura/event.h" |
#include "ui/aura/focus_manager.h" |
@@ -15,32 +15,35 @@ |
namespace aura { |
-WindowManager::WindowManager(Window* owner) |
- : owner_(owner), |
+ToplevelWindowEventFilter::ToplevelWindowEventFilter(Window* owner) |
+ : EventFilter(owner), |
window_component_(HTNOWHERE) { |
} |
-WindowManager::~WindowManager() { |
+ToplevelWindowEventFilter::~ToplevelWindowEventFilter() { |
} |
-bool WindowManager::OnMouseEvent(MouseEvent* event) { |
+bool ToplevelWindowEventFilter::OnMouseEvent(Window* target, |
+ MouseEvent* event) { |
switch (event->type()) { |
case ui::ET_MOUSE_PRESSED: |
// TODO(beng): some windows (e.g. disabled ones, tooltips, etc) may not be |
// focusable. |
- owner_->GetFocusManager()->SetFocusedWindow(owner_); |
+ target->GetFocusManager()->SetFocusedWindow(target); |
window_component_ = |
- owner_->delegate()->GetNonClientComponent(event->location()); |
- MoveWindowToFront(); |
+ target->delegate()->GetNonClientComponent(event->location()); |
+ MoveWindowToFront(target); |
mouse_down_offset_ = event->location(); |
- window_location_ = owner_->bounds().origin(); |
+ window_location_ = target->bounds().origin(); |
+ if (window_component_ == HTCAPTION) |
+ return true; |
break; |
case ui::ET_MOUSE_DRAGGED: |
if (window_component_ == HTCAPTION) { |
gfx::Point new_origin(event->location()); |
new_origin.Offset(-mouse_down_offset_.x(), -mouse_down_offset_.y()); |
- new_origin.Offset(owner_->bounds().x(), owner_->bounds().y()); |
- owner_->SetBounds(gfx::Rect(new_origin, owner_->bounds().size()), 0); |
+ new_origin.Offset(target->bounds().x(), target->bounds().y()); |
+ target->SetBounds(gfx::Rect(new_origin, target->bounds().size()), 0); |
return true; |
} |
break; |
@@ -53,11 +56,13 @@ |
return false; |
} |
-void WindowManager::MoveWindowToFront() { |
- Window* parent = owner_->parent(); |
- Window* child = owner_; |
+void ToplevelWindowEventFilter::MoveWindowToFront(Window* target) { |
+ Window* parent = target->parent(); |
+ Window* child = target; |
while (parent) { |
parent->MoveChildToFront(child); |
+ if (parent == owner()) |
+ break; |
parent = parent->parent(); |
child = child->parent(); |
} |