| 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 "ash/wm/workspace/multi_window_resize_controller.h" | 5 #include "ash/wm/workspace/multi_window_resize_controller.h" |
| 6 | 6 |
| 7 #include "ash/screen_util.h" | 7 #include "ash/screen_util.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
| 10 #include "ash/wm/aura/wm_window_aura.h" | 10 #include "ash/wm/aura/wm_window_aura.h" |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 | 466 |
| 467 if (windows_.direction == LEFT_RIGHT) | 467 if (windows_.direction == LEFT_RIGHT) |
| 468 bounds.set_y(show_bounds_in_screen_.y()); | 468 bounds.set_y(show_bounds_in_screen_.y()); |
| 469 else | 469 else |
| 470 bounds.set_x(show_bounds_in_screen_.x()); | 470 bounds.set_x(show_bounds_in_screen_.x()); |
| 471 resize_widget_->SetBounds(bounds); | 471 resize_widget_->SetBounds(bounds); |
| 472 } | 472 } |
| 473 | 473 |
| 474 void MultiWindowResizeController::CompleteResize() { | 474 void MultiWindowResizeController::CompleteResize() { |
| 475 window_resizer_->CompleteDrag(); | 475 window_resizer_->CompleteDrag(); |
| 476 wm::GetWindowState(window_resizer_->GetAuraTarget())->DeleteDragDetails(); | 476 window_resizer_->GetTarget()->GetWindowState()->DeleteDragDetails(); |
| 477 window_resizer_.reset(); | 477 window_resizer_.reset(); |
| 478 | 478 |
| 479 // Mouse may still be over resizer, if not hide. | 479 // Mouse may still be over resizer, if not hide. |
| 480 gfx::Point screen_loc = gfx::Screen::GetScreen()->GetCursorScreenPoint(); | 480 gfx::Point screen_loc = gfx::Screen::GetScreen()->GetCursorScreenPoint(); |
| 481 if (!resize_widget_->GetWindowBoundsInScreen().Contains(screen_loc)) { | 481 if (!resize_widget_->GetWindowBoundsInScreen().Contains(screen_loc)) { |
| 482 Hide(); | 482 Hide(); |
| 483 } else { | 483 } else { |
| 484 // If the mouse is over the resizer we need to remove observers on any of | 484 // If the mouse is over the resizer we need to remove observers on any of |
| 485 // the |other_windows|. If we start another resize we'll recalculate the | 485 // the |other_windows|. If we start another resize we'll recalculate the |
| 486 // |other_windows| and invoke AddObserver() as necessary. | 486 // |other_windows| and invoke AddObserver() as necessary. |
| 487 for (size_t i = 0; i < windows_.other_windows.size(); ++i) | 487 for (size_t i = 0; i < windows_.other_windows.size(); ++i) |
| 488 windows_.other_windows[i]->RemoveObserver(this); | 488 windows_.other_windows[i]->RemoveObserver(this); |
| 489 windows_.other_windows.clear(); | 489 windows_.other_windows.clear(); |
| 490 | 490 |
| 491 CreateMouseWatcher(); | 491 CreateMouseWatcher(); |
| 492 } | 492 } |
| 493 } | 493 } |
| 494 | 494 |
| 495 void MultiWindowResizeController::CancelResize() { | 495 void MultiWindowResizeController::CancelResize() { |
| 496 if (!window_resizer_) | 496 if (!window_resizer_) |
| 497 return; // Happens if window was destroyed and we nuked the WindowResizer. | 497 return; // Happens if window was destroyed and we nuked the WindowResizer. |
| 498 window_resizer_->RevertDrag(); | 498 window_resizer_->RevertDrag(); |
| 499 wm::GetWindowState(window_resizer_->GetAuraTarget())->DeleteDragDetails(); | 499 window_resizer_->GetTarget()->GetWindowState()->DeleteDragDetails(); |
| 500 window_resizer_.reset(); | 500 window_resizer_.reset(); |
| 501 Hide(); | 501 Hide(); |
| 502 } | 502 } |
| 503 | 503 |
| 504 gfx::Rect MultiWindowResizeController::CalculateResizeWidgetBounds( | 504 gfx::Rect MultiWindowResizeController::CalculateResizeWidgetBounds( |
| 505 const gfx::Point& location_in_parent) const { | 505 const gfx::Point& location_in_parent) const { |
| 506 gfx::Size pref = resize_widget_->GetContentsView()->GetPreferredSize(); | 506 gfx::Size pref = resize_widget_->GetContentsView()->GetPreferredSize(); |
| 507 int x = 0, y = 0; | 507 int x = 0, y = 0; |
| 508 if (windows_.direction == LEFT_RIGHT) { | 508 if (windows_.direction == LEFT_RIGHT) { |
| 509 x = windows_.window1->bounds().right() - pref.width() / 2; | 509 x = windows_.window1->bounds().right() - pref.width() / 2; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 bool MultiWindowResizeController::IsOverComponent( | 575 bool MultiWindowResizeController::IsOverComponent( |
| 576 aura::Window* window, | 576 aura::Window* window, |
| 577 const gfx::Point& location_in_screen, | 577 const gfx::Point& location_in_screen, |
| 578 int component) const { | 578 int component) const { |
| 579 gfx::Point window_loc(location_in_screen); | 579 gfx::Point window_loc(location_in_screen); |
| 580 ::wm::ConvertPointFromScreen(window, &window_loc); | 580 ::wm::ConvertPointFromScreen(window, &window_loc); |
| 581 return window->delegate()->GetNonClientComponent(window_loc) == component; | 581 return window->delegate()->GetNonClientComponent(window_loc) == component; |
| 582 } | 582 } |
| 583 | 583 |
| 584 } // namespace ash | 584 } // namespace ash |
| OLD | NEW |