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 SetRestoreBoundsInParent(window(), details_.restore_bounds.IsEmpty() ? | 331 gfx::Rect initial_bounds = ScreenAsh::ConvertRectToScreen( |
332 details_.initial_bounds : | 332 window()->parent(), details_.initial_bounds_in_parent); |
333 details_.restore_bounds); | 333 SetRestoreBoundsInScreen(window(), details_.restore_bounds.IsEmpty() ? |
| 334 initial_bounds : |
| 335 details_.restore_bounds); |
| 336 } |
334 window()->SetBounds(snap_sizer_->target_bounds()); | 337 window()->SetBounds(snap_sizer_->target_bounds()); |
335 return; | 338 return; |
336 } | 339 } |
337 | 340 |
338 gfx::Rect bounds(GetFinalBounds(window()->bounds())); | 341 gfx::Rect bounds(GetFinalBounds(window()->bounds())); |
339 | 342 |
340 // Check if the destination is another display. | 343 // Check if the destination is another display. |
341 gfx::Point last_mouse_location_in_screen = last_mouse_location_; | 344 gfx::Point last_mouse_location_in_screen = last_mouse_location_; |
342 wm::ConvertPointToScreen(window()->parent(), &last_mouse_location_in_screen); | 345 wm::ConvertPointToScreen(window()->parent(), &last_mouse_location_in_screen); |
343 gfx::Screen* screen = Shell::GetScreen(); | 346 gfx::Screen* screen = Shell::GetScreen(); |
(...skipping 11 matching lines...) Expand all Loading... |
355 | 358 |
356 void WorkspaceWindowResizer::RevertDrag() { | 359 void WorkspaceWindowResizer::RevertDrag() { |
357 window()->layer()->SetOpacity(details_.initial_opacity); | 360 window()->layer()->SetOpacity(details_.initial_opacity); |
358 drag_phantom_window_controller_.reset(); | 361 drag_phantom_window_controller_.reset(); |
359 snap_phantom_window_controller_.reset(); | 362 snap_phantom_window_controller_.reset(); |
360 Shell::GetInstance()->mouse_cursor_filter()->HideSharedEdgeIndicator(); | 363 Shell::GetInstance()->mouse_cursor_filter()->HideSharedEdgeIndicator(); |
361 | 364 |
362 if (!did_move_or_resize_) | 365 if (!did_move_or_resize_) |
363 return; | 366 return; |
364 | 367 |
365 window()->SetBounds(details_.initial_bounds); | 368 window()->SetBounds(details_.initial_bounds_in_parent); |
366 if (!details_.restore_bounds.IsEmpty()) | 369 if (!details_.restore_bounds.IsEmpty()) |
367 SetRestoreBoundsInScreen(details_.window, details_.restore_bounds); | 370 SetRestoreBoundsInScreen(details_.window, details_.restore_bounds); |
368 | 371 |
369 if (details_.window_component == HTRIGHT) { | 372 if (details_.window_component == HTRIGHT) { |
370 int last_x = details_.initial_bounds.right(); | 373 int last_x = details_.initial_bounds_in_parent.right(); |
371 for (size_t i = 0; i < attached_windows_.size(); ++i) { | 374 for (size_t i = 0; i < attached_windows_.size(); ++i) { |
372 gfx::Rect bounds(attached_windows_[i]->bounds()); | 375 gfx::Rect bounds(attached_windows_[i]->bounds()); |
373 bounds.set_x(last_x); | 376 bounds.set_x(last_x); |
374 bounds.set_width(initial_size_[i]); | 377 bounds.set_width(initial_size_[i]); |
375 attached_windows_[i]->SetBounds(bounds); | 378 attached_windows_[i]->SetBounds(bounds); |
376 last_x = attached_windows_[i]->bounds().right(); | 379 last_x = attached_windows_[i]->bounds().right(); |
377 } | 380 } |
378 } else { | 381 } else { |
379 int last_y = details_.initial_bounds.bottom(); | 382 int last_y = details_.initial_bounds_in_parent.bottom(); |
380 for (size_t i = 0; i < attached_windows_.size(); ++i) { | 383 for (size_t i = 0; i < attached_windows_.size(); ++i) { |
381 gfx::Rect bounds(attached_windows_[i]->bounds()); | 384 gfx::Rect bounds(attached_windows_[i]->bounds()); |
382 bounds.set_y(last_y); | 385 bounds.set_y(last_y); |
383 bounds.set_height(initial_size_[i]); | 386 bounds.set_height(initial_size_[i]); |
384 attached_windows_[i]->SetBounds(bounds); | 387 attached_windows_[i]->SetBounds(bounds); |
385 last_y = attached_windows_[i]->bounds().bottom(); | 388 last_y = attached_windows_[i]->bounds().bottom(); |
386 } | 389 } |
387 } | 390 } |
388 } | 391 } |
389 | 392 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 return snap_phantom_window_controller_->bounds(); | 470 return snap_phantom_window_controller_->bounds(); |
468 } | 471 } |
469 return bounds; | 472 return bounds; |
470 } | 473 } |
471 | 474 |
472 void WorkspaceWindowResizer::LayoutAttachedWindows( | 475 void WorkspaceWindowResizer::LayoutAttachedWindows( |
473 const gfx::Rect& bounds) { | 476 const gfx::Rect& bounds) { |
474 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(window())); | 477 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(window())); |
475 std::vector<int> sizes; | 478 std::vector<int> sizes; |
476 CalculateAttachedSizes( | 479 CalculateAttachedSizes( |
477 PrimaryAxisSize(details_.initial_bounds.size()), | 480 PrimaryAxisSize(details_.initial_bounds_in_parent.size()), |
478 PrimaryAxisSize(bounds.size()), | 481 PrimaryAxisSize(bounds.size()), |
479 PrimaryAxisCoordinate(bounds.right(), bounds.bottom()), | 482 PrimaryAxisCoordinate(bounds.right(), bounds.bottom()), |
480 PrimaryAxisCoordinate(work_area.right(), work_area.bottom()), | 483 PrimaryAxisCoordinate(work_area.right(), work_area.bottom()), |
481 &sizes); | 484 &sizes); |
482 DCHECK_EQ(attached_windows_.size(), sizes.size()); | 485 DCHECK_EQ(attached_windows_.size(), sizes.size()); |
483 int last = PrimaryAxisCoordinate(bounds.right(), bounds.bottom()); | 486 int last = PrimaryAxisCoordinate(bounds.right(), bounds.bottom()); |
484 for (size_t i = 0; i < attached_windows_.size(); ++i) { | 487 for (size_t i = 0; i < attached_windows_.size(); ++i) { |
485 gfx::Rect attached_bounds(attached_windows_[i]->bounds()); | 488 gfx::Rect attached_bounds(attached_windows_[i]->bounds()); |
486 if (details_.window_component == HTRIGHT) { | 489 if (details_.window_component == HTRIGHT) { |
487 attached_bounds.set_x(last); | 490 attached_bounds.set_x(last); |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 gfx::Rect layer_bounds = layer_->bounds(); | 831 gfx::Rect layer_bounds = layer_->bounds(); |
829 layer_bounds.set_origin(gfx::Point(0, 0)); | 832 layer_bounds.set_origin(gfx::Point(0, 0)); |
830 layer_->SetBounds(layer_bounds); | 833 layer_->SetBounds(layer_bounds); |
831 layer_->SetVisible(false); | 834 layer_->SetVisible(false); |
832 // Detach it from the current container. | 835 // Detach it from the current container. |
833 layer_->parent()->Remove(layer_); | 836 layer_->parent()->Remove(layer_); |
834 } | 837 } |
835 | 838 |
836 } // namespace internal | 839 } // namespace internal |
837 } // namespace ash | 840 } // namespace ash |
OLD | NEW |