| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "aura/window_manager.h" | |
| 6 | |
| 7 #include "aura/event.h" | |
| 8 #include "aura/focus_manager.h" | |
| 9 #include "aura/window.h" | |
| 10 #include "aura/window_delegate.h" | |
| 11 | |
| 12 #if !defined(OS_WIN) | |
| 13 #include "aura/hit_test.h" | |
| 14 #endif | |
| 15 | |
| 16 namespace aura { | |
| 17 | |
| 18 WindowManager::WindowManager(Window* owner) | |
| 19 : owner_(owner), | |
| 20 window_component_(HTNOWHERE) { | |
| 21 } | |
| 22 | |
| 23 WindowManager::~WindowManager() { | |
| 24 } | |
| 25 | |
| 26 bool WindowManager::OnMouseEvent(MouseEvent* event) { | |
| 27 switch (event->type()) { | |
| 28 case ui::ET_MOUSE_PRESSED: | |
| 29 // TODO(beng): some windows (e.g. disabled ones, tooltips, etc) may not be | |
| 30 // focusable. | |
| 31 owner_->GetFocusManager()->SetFocusedWindow(owner_); | |
| 32 window_component_ = | |
| 33 owner_->delegate()->GetNonClientComponent(event->location()); | |
| 34 MoveWindowToFront(); | |
| 35 mouse_down_offset_ = event->location(); | |
| 36 window_location_ = owner_->bounds().origin(); | |
| 37 break; | |
| 38 case ui::ET_MOUSE_DRAGGED: | |
| 39 if (window_component_ == HTCAPTION) { | |
| 40 gfx::Point new_origin(event->location()); | |
| 41 new_origin.Offset(-mouse_down_offset_.x(), -mouse_down_offset_.y()); | |
| 42 new_origin.Offset(owner_->bounds().x(), owner_->bounds().y()); | |
| 43 owner_->SetBounds(gfx::Rect(new_origin, owner_->bounds().size()), 0); | |
| 44 return true; | |
| 45 } | |
| 46 break; | |
| 47 case ui::ET_MOUSE_RELEASED: | |
| 48 window_component_ = HTNOWHERE; | |
| 49 break; | |
| 50 default: | |
| 51 break; | |
| 52 } | |
| 53 return false; | |
| 54 } | |
| 55 | |
| 56 void WindowManager::MoveWindowToFront() { | |
| 57 Window* parent = owner_->parent(); | |
| 58 Window* child = owner_; | |
| 59 while (parent) { | |
| 60 parent->MoveChildToFront(child); | |
| 61 parent = parent->parent(); | |
| 62 child = child->parent(); | |
| 63 } | |
| 64 } | |
| 65 | |
| 66 } // namespace aura | |
| OLD | NEW |