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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 details_.restore_bounds); | 186 details_.restore_bounds); |
187 window()->SetBounds(snap_sizer_->target_bounds()); | 187 window()->SetBounds(snap_sizer_->target_bounds()); |
188 return; | 188 return; |
189 } | 189 } |
190 | 190 |
191 gfx::Rect bounds(GetFinalBounds(window()->bounds())); | 191 gfx::Rect bounds(GetFinalBounds(window()->bounds())); |
192 | 192 |
193 // Check if the destination is another display. | 193 // Check if the destination is another display. |
194 gfx::Point last_mouse_location_in_screen = last_mouse_location_; | 194 gfx::Point last_mouse_location_in_screen = last_mouse_location_; |
195 wm::ConvertPointToScreen(window()->parent(), &last_mouse_location_in_screen); | 195 wm::ConvertPointToScreen(window()->parent(), &last_mouse_location_in_screen); |
| 196 gfx::Screen* screen = Shell::GetScreen(); |
196 const gfx::Display dst_display = | 197 const gfx::Display dst_display = |
197 gfx::Screen::GetDisplayNearestPoint(last_mouse_location_in_screen); | 198 screen->GetDisplayNearestPoint(last_mouse_location_in_screen); |
198 | 199 |
199 if (dst_display.id() != | 200 if (dst_display.id() != |
200 gfx::Screen::GetDisplayNearestWindow(window()->GetRootWindow()).id()) { | 201 screen->GetDisplayNearestWindow(window()->GetRootWindow()).id()) { |
201 // Don't animate when moving to another display. | 202 // Don't animate when moving to another display. |
202 const gfx::Rect dst_bounds = | 203 const gfx::Rect dst_bounds = |
203 ScreenAsh::ConvertRectToScreen(window()->parent(), bounds); | 204 ScreenAsh::ConvertRectToScreen(window()->parent(), bounds); |
204 window()->SetBoundsInScreen(dst_bounds, dst_display); | 205 window()->SetBoundsInScreen(dst_bounds, dst_display); |
205 } | 206 } |
206 } | 207 } |
207 | 208 |
208 void WorkspaceWindowResizer::RevertDrag() { | 209 void WorkspaceWindowResizer::RevertDrag() { |
209 window()->layer()->SetOpacity(details_.initial_opacity); | 210 window()->layer()->SetOpacity(details_.initial_opacity); |
210 drag_phantom_window_controller_.reset(); | 211 drag_phantom_window_controller_.reset(); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 } | 420 } |
420 } | 421 } |
421 } | 422 } |
422 | 423 |
423 void WorkspaceWindowResizer::AdjustBoundsForMainWindow( | 424 void WorkspaceWindowResizer::AdjustBoundsForMainWindow( |
424 gfx::Rect* bounds, | 425 gfx::Rect* bounds, |
425 int grid_size) { | 426 int grid_size) { |
426 | 427 |
427 gfx::Point last_mouse_location_in_screen = last_mouse_location_; | 428 gfx::Point last_mouse_location_in_screen = last_mouse_location_; |
428 wm::ConvertPointToScreen(window()->parent(), &last_mouse_location_in_screen); | 429 wm::ConvertPointToScreen(window()->parent(), &last_mouse_location_in_screen); |
429 gfx::Display display = | 430 gfx::Display display = Shell::GetScreen()->GetDisplayNearestPoint( |
430 gfx::Screen::GetDisplayNearestPoint(last_mouse_location_in_screen); | 431 last_mouse_location_in_screen); |
431 gfx::Rect work_area = | 432 gfx::Rect work_area = |
432 ScreenAsh::ConvertRectFromScreen(window()->parent(), display.work_area()); | 433 ScreenAsh::ConvertRectFromScreen(window()->parent(), display.work_area()); |
433 if (details_.window_component == HTCAPTION) { | 434 if (details_.window_component == HTCAPTION) { |
434 // Adjust the bounds to the work area where the mouse cursor is located. | 435 // Adjust the bounds to the work area where the mouse cursor is located. |
435 // Always keep kMinOnscreenHeight on the bottom. | 436 // Always keep kMinOnscreenHeight on the bottom. |
436 int max_y = work_area.bottom() - kMinOnscreenHeight; | 437 int max_y = work_area.bottom() - kMinOnscreenHeight; |
437 if (bounds->y() > max_y) { | 438 if (bounds->y() > max_y) { |
438 bounds->set_y(max_y); | 439 bounds->set_y(max_y); |
439 } else if (bounds->y() <= work_area.y()) { | 440 } else if (bounds->y() <= work_area.y()) { |
440 // Don't allow dragging above the top of the display until the mouse | 441 // Don't allow dragging above the top of the display until the mouse |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 in_original_root ? 1 : (kMaxOpacity * (1 - fraction_in_another_window)); | 538 in_original_root ? 1 : (kMaxOpacity * (1 - fraction_in_another_window)); |
538 | 539 |
539 if (fraction_in_another_window > 0) { | 540 if (fraction_in_another_window > 0) { |
540 if (!drag_phantom_window_controller_.get()) { | 541 if (!drag_phantom_window_controller_.get()) { |
541 drag_phantom_window_controller_.reset( | 542 drag_phantom_window_controller_.reset( |
542 new PhantomWindowController(window())); | 543 new PhantomWindowController(window())); |
543 drag_phantom_window_controller_->set_style( | 544 drag_phantom_window_controller_->set_style( |
544 PhantomWindowController::STYLE_DRAGGING); | 545 PhantomWindowController::STYLE_DRAGGING); |
545 // Always show the drag phantom on the |another_root| window. | 546 // Always show the drag phantom on the |another_root| window. |
546 drag_phantom_window_controller_->SetDestinationDisplay( | 547 drag_phantom_window_controller_->SetDestinationDisplay( |
547 gfx::Screen::GetDisplayMatching(another_root->GetBoundsInScreen())); | 548 Shell::GetScreen()->GetDisplayMatching( |
| 549 another_root->GetBoundsInScreen())); |
548 if (!layer_) | 550 if (!layer_) |
549 RecreateWindowLayers(); | 551 RecreateWindowLayers(); |
550 drag_phantom_window_controller_->Show(bounds_in_screen, layer_); | 552 drag_phantom_window_controller_->Show(bounds_in_screen, layer_); |
551 } else { | 553 } else { |
552 // No animation. | 554 // No animation. |
553 drag_phantom_window_controller_->SetBounds(bounds_in_screen); | 555 drag_phantom_window_controller_->SetBounds(bounds_in_screen); |
554 } | 556 } |
555 drag_phantom_window_controller_->SetOpacity(phantom_opacity); | 557 drag_phantom_window_controller_->SetOpacity(phantom_opacity); |
556 window()->layer()->SetOpacity(window_opacity); | 558 window()->layer()->SetOpacity(window_opacity); |
557 } else { | 559 } else { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 gfx::Rect layer_bounds = layer_->bounds(); | 647 gfx::Rect layer_bounds = layer_->bounds(); |
646 layer_bounds.set_origin(gfx::Point(0, 0)); | 648 layer_bounds.set_origin(gfx::Point(0, 0)); |
647 layer_->SetBounds(layer_bounds); | 649 layer_->SetBounds(layer_bounds); |
648 layer_->SetVisible(false); | 650 layer_->SetVisible(false); |
649 // Detach it from the current container. | 651 // Detach it from the current container. |
650 layer_->parent()->Remove(layer_); | 652 layer_->parent()->Remove(layer_); |
651 } | 653 } |
652 | 654 |
653 } // namespace internal | 655 } // namespace internal |
654 } // namespace ash | 656 } // namespace ash |
OLD | NEW |