| 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/workspace_window_resizer.h" | 5 #include "ash/wm/workspace/workspace_window_resizer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 if (!did_move_or_resize_ || details_.window_component != HTCAPTION) | 320 if (!did_move_or_resize_ || details_.window_component != HTCAPTION) |
| 321 return; | 321 return; |
| 322 | 322 |
| 323 // When the window is not in the normal show state, we do not snap thw window. | 323 // When the window is not in the normal show state, we do not snap thw window. |
| 324 // This happens when the user minimizes or maximizes the window by keyboard | 324 // This happens when the user minimizes or maximizes the window by keyboard |
| 325 // shortcut while dragging it. If the window is the result of dragging a tab | 325 // shortcut while dragging it. If the window is the result of dragging a tab |
| 326 // out of a maximized window, it's already in the normal show state when this | 326 // out of a maximized window, it's already in the normal show state when this |
| 327 // is called, so it does not matter. | 327 // is called, so it does not matter. |
| 328 if (wm::IsWindowNormal(window()) && | 328 if (wm::IsWindowNormal(window()) && |
| 329 (snap_type_ == SNAP_LEFT_EDGE || snap_type_ == SNAP_RIGHT_EDGE)) { | 329 (snap_type_ == SNAP_LEFT_EDGE || snap_type_ == SNAP_RIGHT_EDGE)) { |
| 330 if (!GetRestoreBoundsInScreen(window())) { | 330 if (!GetRestoreBoundsInScreen(window())) |
| 331 gfx::Rect initial_bounds = ScreenAsh::ConvertRectToScreen( | 331 SetRestoreBoundsInParent(window(), details_.restore_bounds.IsEmpty() ? |
| 332 window()->parent(), details_.initial_bounds_in_parent); | 332 details_.initial_bounds : |
| 333 SetRestoreBoundsInScreen(window(), details_.restore_bounds.IsEmpty() ? | 333 details_.restore_bounds); |
| 334 initial_bounds : | |
| 335 details_.restore_bounds); | |
| 336 } | |
| 337 window()->SetBounds(snap_sizer_->target_bounds()); | 334 window()->SetBounds(snap_sizer_->target_bounds()); |
| 338 return; | 335 return; |
| 339 } | 336 } |
| 340 | 337 |
| 341 gfx::Rect bounds(GetFinalBounds(window()->bounds())); | 338 gfx::Rect bounds(GetFinalBounds(window()->bounds())); |
| 342 | 339 |
| 343 // Check if the destination is another display. | 340 // Check if the destination is another display. |
| 344 gfx::Point last_mouse_location_in_screen = last_mouse_location_; | 341 gfx::Point last_mouse_location_in_screen = last_mouse_location_; |
| 345 wm::ConvertPointToScreen(window()->parent(), &last_mouse_location_in_screen); | 342 wm::ConvertPointToScreen(window()->parent(), &last_mouse_location_in_screen); |
| 346 gfx::Screen* screen = Shell::GetScreen(); | 343 gfx::Screen* screen = Shell::GetScreen(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 358 | 355 |
| 359 void WorkspaceWindowResizer::RevertDrag() { | 356 void WorkspaceWindowResizer::RevertDrag() { |
| 360 window()->layer()->SetOpacity(details_.initial_opacity); | 357 window()->layer()->SetOpacity(details_.initial_opacity); |
| 361 drag_phantom_window_controller_.reset(); | 358 drag_phantom_window_controller_.reset(); |
| 362 snap_phantom_window_controller_.reset(); | 359 snap_phantom_window_controller_.reset(); |
| 363 Shell::GetInstance()->mouse_cursor_filter()->HideSharedEdgeIndicator(); | 360 Shell::GetInstance()->mouse_cursor_filter()->HideSharedEdgeIndicator(); |
| 364 | 361 |
| 365 if (!did_move_or_resize_) | 362 if (!did_move_or_resize_) |
| 366 return; | 363 return; |
| 367 | 364 |
| 368 window()->SetBounds(details_.initial_bounds_in_parent); | 365 window()->SetBounds(details_.initial_bounds); |
| 369 if (!details_.restore_bounds.IsEmpty()) | 366 if (!details_.restore_bounds.IsEmpty()) |
| 370 SetRestoreBoundsInScreen(details_.window, details_.restore_bounds); | 367 SetRestoreBoundsInScreen(details_.window, details_.restore_bounds); |
| 371 | 368 |
| 372 if (details_.window_component == HTRIGHT) { | 369 if (details_.window_component == HTRIGHT) { |
| 373 int last_x = details_.initial_bounds_in_parent.right(); | 370 int last_x = details_.initial_bounds.right(); |
| 374 for (size_t i = 0; i < attached_windows_.size(); ++i) { | 371 for (size_t i = 0; i < attached_windows_.size(); ++i) { |
| 375 gfx::Rect bounds(attached_windows_[i]->bounds()); | 372 gfx::Rect bounds(attached_windows_[i]->bounds()); |
| 376 bounds.set_x(last_x); | 373 bounds.set_x(last_x); |
| 377 bounds.set_width(initial_size_[i]); | 374 bounds.set_width(initial_size_[i]); |
| 378 attached_windows_[i]->SetBounds(bounds); | 375 attached_windows_[i]->SetBounds(bounds); |
| 379 last_x = attached_windows_[i]->bounds().right(); | 376 last_x = attached_windows_[i]->bounds().right(); |
| 380 } | 377 } |
| 381 } else { | 378 } else { |
| 382 int last_y = details_.initial_bounds_in_parent.bottom(); | 379 int last_y = details_.initial_bounds.bottom(); |
| 383 for (size_t i = 0; i < attached_windows_.size(); ++i) { | 380 for (size_t i = 0; i < attached_windows_.size(); ++i) { |
| 384 gfx::Rect bounds(attached_windows_[i]->bounds()); | 381 gfx::Rect bounds(attached_windows_[i]->bounds()); |
| 385 bounds.set_y(last_y); | 382 bounds.set_y(last_y); |
| 386 bounds.set_height(initial_size_[i]); | 383 bounds.set_height(initial_size_[i]); |
| 387 attached_windows_[i]->SetBounds(bounds); | 384 attached_windows_[i]->SetBounds(bounds); |
| 388 last_y = attached_windows_[i]->bounds().bottom(); | 385 last_y = attached_windows_[i]->bounds().bottom(); |
| 389 } | 386 } |
| 390 } | 387 } |
| 391 } | 388 } |
| 392 | 389 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 return snap_phantom_window_controller_->bounds(); | 467 return snap_phantom_window_controller_->bounds(); |
| 471 } | 468 } |
| 472 return bounds; | 469 return bounds; |
| 473 } | 470 } |
| 474 | 471 |
| 475 void WorkspaceWindowResizer::LayoutAttachedWindows( | 472 void WorkspaceWindowResizer::LayoutAttachedWindows( |
| 476 const gfx::Rect& bounds) { | 473 const gfx::Rect& bounds) { |
| 477 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(window())); | 474 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(window())); |
| 478 std::vector<int> sizes; | 475 std::vector<int> sizes; |
| 479 CalculateAttachedSizes( | 476 CalculateAttachedSizes( |
| 480 PrimaryAxisSize(details_.initial_bounds_in_parent.size()), | 477 PrimaryAxisSize(details_.initial_bounds.size()), |
| 481 PrimaryAxisSize(bounds.size()), | 478 PrimaryAxisSize(bounds.size()), |
| 482 PrimaryAxisCoordinate(bounds.right(), bounds.bottom()), | 479 PrimaryAxisCoordinate(bounds.right(), bounds.bottom()), |
| 483 PrimaryAxisCoordinate(work_area.right(), work_area.bottom()), | 480 PrimaryAxisCoordinate(work_area.right(), work_area.bottom()), |
| 484 &sizes); | 481 &sizes); |
| 485 DCHECK_EQ(attached_windows_.size(), sizes.size()); | 482 DCHECK_EQ(attached_windows_.size(), sizes.size()); |
| 486 int last = PrimaryAxisCoordinate(bounds.right(), bounds.bottom()); | 483 int last = PrimaryAxisCoordinate(bounds.right(), bounds.bottom()); |
| 487 for (size_t i = 0; i < attached_windows_.size(); ++i) { | 484 for (size_t i = 0; i < attached_windows_.size(); ++i) { |
| 488 gfx::Rect attached_bounds(attached_windows_[i]->bounds()); | 485 gfx::Rect attached_bounds(attached_windows_[i]->bounds()); |
| 489 if (details_.window_component == HTRIGHT) { | 486 if (details_.window_component == HTRIGHT) { |
| 490 attached_bounds.set_x(last); | 487 attached_bounds.set_x(last); |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 gfx::Rect layer_bounds = layer_->bounds(); | 828 gfx::Rect layer_bounds = layer_->bounds(); |
| 832 layer_bounds.set_origin(gfx::Point(0, 0)); | 829 layer_bounds.set_origin(gfx::Point(0, 0)); |
| 833 layer_->SetBounds(layer_bounds); | 830 layer_->SetBounds(layer_bounds); |
| 834 layer_->SetVisible(false); | 831 layer_->SetVisible(false); |
| 835 // Detach it from the current container. | 832 // Detach it from the current container. |
| 836 layer_->parent()->Remove(layer_); | 833 layer_->parent()->Remove(layer_); |
| 837 } | 834 } |
| 838 | 835 |
| 839 } // namespace internal | 836 } // namespace internal |
| 840 } // namespace ash | 837 } // namespace ash |
| OLD | NEW |