| 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" |
| 11 #include "ash/wm/window_animations.h" | 11 #include "ash/wm/window_animations.h" |
| 12 #include "ash/wm/window_state_aura.h" | 12 #include "ash/wm/window_state_aura.h" |
| 13 #include "ash/wm/workspace/workspace_event_handler.h" | 13 #include "ash/wm/workspace/workspace_event_handler.h" |
| 14 #include "ash/wm/workspace/workspace_window_resizer.h" | 14 #include "ash/wm/workspace/workspace_window_resizer.h" |
| 15 #include "grit/ash_resources.h" | 15 #include "grit/ash_resources.h" |
| 16 #include "ui/aura/client/screen_position_client.h" | 16 #include "ui/aura/client/screen_position_client.h" |
| 17 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
| 18 #include "ui/aura/window_delegate.h" | 18 #include "ui/aura/window_delegate.h" |
| 19 #include "ui/aura/window_event_dispatcher.h" | 19 #include "ui/aura/window_event_dispatcher.h" |
| 20 #include "ui/base/hit_test.h" | 20 #include "ui/base/hit_test.h" |
| 21 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
| 22 #include "ui/display/screen.h" |
| 22 #include "ui/events/event_targeter.h" | 23 #include "ui/events/event_targeter.h" |
| 23 #include "ui/events/event_utils.h" | 24 #include "ui/events/event_utils.h" |
| 24 #include "ui/gfx/canvas.h" | 25 #include "ui/gfx/canvas.h" |
| 25 #include "ui/gfx/image/image.h" | 26 #include "ui/gfx/image/image.h" |
| 26 #include "ui/gfx/screen.h" | |
| 27 #include "ui/views/view.h" | 27 #include "ui/views/view.h" |
| 28 #include "ui/views/widget/widget.h" | 28 #include "ui/views/widget/widget.h" |
| 29 #include "ui/views/widget/widget_delegate.h" | 29 #include "ui/views/widget/widget_delegate.h" |
| 30 #include "ui/wm/core/compound_event_filter.h" | 30 #include "ui/wm/core/compound_event_filter.h" |
| 31 #include "ui/wm/core/coordinate_conversion.h" | 31 #include "ui/wm/core/coordinate_conversion.h" |
| 32 | 32 |
| 33 using aura::Window; | 33 using aura::Window; |
| 34 | 34 |
| 35 namespace ash { | 35 namespace ash { |
| 36 namespace { | 36 namespace { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 void MultiWindowResizeController::OnWindowDestroying( | 234 void MultiWindowResizeController::OnWindowDestroying( |
| 235 aura::Window* window) { | 235 aura::Window* window) { |
| 236 // Have to explicitly reset the WindowResizer, otherwise Hide() does nothing. | 236 // Have to explicitly reset the WindowResizer, otherwise Hide() does nothing. |
| 237 window_resizer_.reset(); | 237 window_resizer_.reset(); |
| 238 Hide(); | 238 Hide(); |
| 239 } | 239 } |
| 240 | 240 |
| 241 MultiWindowResizeController::ResizeWindows | 241 MultiWindowResizeController::ResizeWindows |
| 242 MultiWindowResizeController::DetermineWindowsFromScreenPoint( | 242 MultiWindowResizeController::DetermineWindowsFromScreenPoint( |
| 243 aura::Window* window) const { | 243 aura::Window* window) const { |
| 244 gfx::Point mouse_location(gfx::Screen::GetScreen()->GetCursorScreenPoint()); | 244 gfx::Point mouse_location( |
| 245 display::Screen::GetScreen()->GetCursorScreenPoint()); |
| 245 ::wm::ConvertPointFromScreen(window, &mouse_location); | 246 ::wm::ConvertPointFromScreen(window, &mouse_location); |
| 246 const int component = | 247 const int component = |
| 247 window->delegate()->GetNonClientComponent(mouse_location); | 248 window->delegate()->GetNonClientComponent(mouse_location); |
| 248 return DetermineWindows(window, component, mouse_location); | 249 return DetermineWindows(window, component, mouse_location); |
| 249 } | 250 } |
| 250 | 251 |
| 251 void MultiWindowResizeController::CreateMouseWatcher() { | 252 void MultiWindowResizeController::CreateMouseWatcher() { |
| 252 mouse_watcher_.reset(new views::MouseWatcher( | 253 mouse_watcher_.reset(new views::MouseWatcher( |
| 253 new ResizeMouseWatcherHost(this), this)); | 254 new ResizeMouseWatcherHost(this), this)); |
| 254 mouse_watcher_->set_notify_on_exit_time( | 255 mouse_watcher_->set_notify_on_exit_time( |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 bounds.set_x(show_bounds_in_screen_.x()); | 471 bounds.set_x(show_bounds_in_screen_.x()); |
| 471 resize_widget_->SetBounds(bounds); | 472 resize_widget_->SetBounds(bounds); |
| 472 } | 473 } |
| 473 | 474 |
| 474 void MultiWindowResizeController::CompleteResize() { | 475 void MultiWindowResizeController::CompleteResize() { |
| 475 window_resizer_->CompleteDrag(); | 476 window_resizer_->CompleteDrag(); |
| 476 window_resizer_->GetTarget()->GetWindowState()->DeleteDragDetails(); | 477 window_resizer_->GetTarget()->GetWindowState()->DeleteDragDetails(); |
| 477 window_resizer_.reset(); | 478 window_resizer_.reset(); |
| 478 | 479 |
| 479 // Mouse may still be over resizer, if not hide. | 480 // Mouse may still be over resizer, if not hide. |
| 480 gfx::Point screen_loc = gfx::Screen::GetScreen()->GetCursorScreenPoint(); | 481 gfx::Point screen_loc = display::Screen::GetScreen()->GetCursorScreenPoint(); |
| 481 if (!resize_widget_->GetWindowBoundsInScreen().Contains(screen_loc)) { | 482 if (!resize_widget_->GetWindowBoundsInScreen().Contains(screen_loc)) { |
| 482 Hide(); | 483 Hide(); |
| 483 } else { | 484 } else { |
| 484 // If the mouse is over the resizer we need to remove observers on any of | 485 // 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 | 486 // the |other_windows|. If we start another resize we'll recalculate the |
| 486 // |other_windows| and invoke AddObserver() as necessary. | 487 // |other_windows| and invoke AddObserver() as necessary. |
| 487 for (size_t i = 0; i < windows_.other_windows.size(); ++i) | 488 for (size_t i = 0; i < windows_.other_windows.size(); ++i) |
| 488 windows_.other_windows[i]->RemoveObserver(this); | 489 windows_.other_windows[i]->RemoveObserver(this); |
| 489 windows_.other_windows.clear(); | 490 windows_.other_windows.clear(); |
| 490 | 491 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 bool MultiWindowResizeController::IsOverComponent( | 576 bool MultiWindowResizeController::IsOverComponent( |
| 576 aura::Window* window, | 577 aura::Window* window, |
| 577 const gfx::Point& location_in_screen, | 578 const gfx::Point& location_in_screen, |
| 578 int component) const { | 579 int component) const { |
| 579 gfx::Point window_loc(location_in_screen); | 580 gfx::Point window_loc(location_in_screen); |
| 580 ::wm::ConvertPointFromScreen(window, &window_loc); | 581 ::wm::ConvertPointFromScreen(window, &window_loc); |
| 581 return window->delegate()->GetNonClientComponent(window_loc) == component; | 582 return window->delegate()->GetNonClientComponent(window_loc) == component; |
| 582 } | 583 } |
| 583 | 584 |
| 584 } // namespace ash | 585 } // namespace ash |
| OLD | NEW |