| 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 | 9 |
| 10 #include "ash/display/display_controller.h" | 10 #include "ash/display/display_controller.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // static | 65 // static |
| 66 const int WorkspaceWindowResizer::kMinOnscreenSize = 20; | 66 const int WorkspaceWindowResizer::kMinOnscreenSize = 20; |
| 67 | 67 |
| 68 // static | 68 // static |
| 69 const int WorkspaceWindowResizer::kMinOnscreenHeight = 32; | 69 const int WorkspaceWindowResizer::kMinOnscreenHeight = 32; |
| 70 | 70 |
| 71 WorkspaceWindowResizer::~WorkspaceWindowResizer() { | 71 WorkspaceWindowResizer::~WorkspaceWindowResizer() { |
| 72 Shell* shell = Shell::GetInstance(); | 72 Shell* shell = Shell::GetInstance(); |
| 73 shell->display_controller()->set_dont_warp_mouse(false); | 73 shell->display_controller()->set_dont_warp_mouse(false); |
| 74 shell->cursor_manager()->UnlockCursor(); | 74 shell->cursor_manager()->UnlockCursor(); |
| 75 |
| 76 // Delete phantom controllers first so that they will never see the deleted |
| 77 // |layer_|. |
| 78 snap_phantom_window_controller_.reset(); |
| 79 drag_phantom_window_controller_.reset(); |
| 80 |
| 81 if (layer_) |
| 82 wm::DeepDeleteLayers(layer_); |
| 75 } | 83 } |
| 76 | 84 |
| 77 // static | 85 // static |
| 78 WorkspaceWindowResizer* WorkspaceWindowResizer::Create( | 86 WorkspaceWindowResizer* WorkspaceWindowResizer::Create( |
| 79 aura::Window* window, | 87 aura::Window* window, |
| 80 const gfx::Point& location_in_parent, | 88 const gfx::Point& location_in_parent, |
| 81 int window_component, | 89 int window_component, |
| 82 const std::vector<aura::Window*>& attached_windows) { | 90 const std::vector<aura::Window*>& attached_windows) { |
| 83 Details details(window, location_in_parent, window_component); | 91 Details details(window, location_in_parent, window_component); |
| 84 return details.is_resizable ? | 92 return details.is_resizable ? |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 | 225 |
| 218 WorkspaceWindowResizer::WorkspaceWindowResizer( | 226 WorkspaceWindowResizer::WorkspaceWindowResizer( |
| 219 const Details& details, | 227 const Details& details, |
| 220 const std::vector<aura::Window*>& attached_windows) | 228 const std::vector<aura::Window*>& attached_windows) |
| 221 : details_(details), | 229 : details_(details), |
| 222 attached_windows_(attached_windows), | 230 attached_windows_(attached_windows), |
| 223 did_move_or_resize_(false), | 231 did_move_or_resize_(false), |
| 224 total_min_(0), | 232 total_min_(0), |
| 225 total_initial_size_(0), | 233 total_initial_size_(0), |
| 226 snap_type_(SNAP_NONE), | 234 snap_type_(SNAP_NONE), |
| 227 num_mouse_moves_since_bounds_change_(0) { | 235 num_mouse_moves_since_bounds_change_(0), |
| 236 layer_(NULL) { |
| 228 DCHECK(details_.is_resizable); | 237 DCHECK(details_.is_resizable); |
| 229 | 238 |
| 230 Shell* shell = Shell::GetInstance(); | 239 Shell* shell = Shell::GetInstance(); |
| 231 shell->cursor_manager()->LockCursor(); | 240 shell->cursor_manager()->LockCursor(); |
| 232 | 241 |
| 233 // The pointer should be confined in one display during resizing a window | 242 // The pointer should be confined in one display during resizing a window |
| 234 // because the window cannot span two displays at the same time anyway. The | 243 // because the window cannot span two displays at the same time anyway. The |
| 235 // exception is window/tab dragging operation. During that operation, | 244 // exception is window/tab dragging operation. During that operation, |
| 236 // |dont_warp_mouse_| should be set to false so that the user could move a | 245 // |dont_warp_mouse_| should be set to false so that the user could move a |
| 237 // window/tab to another display. | 246 // window/tab to another display. |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 | 479 |
| 471 if (fraction_in_another_window > 0) { | 480 if (fraction_in_another_window > 0) { |
| 472 if (!drag_phantom_window_controller_.get()) { | 481 if (!drag_phantom_window_controller_.get()) { |
| 473 drag_phantom_window_controller_.reset( | 482 drag_phantom_window_controller_.reset( |
| 474 new PhantomWindowController(window())); | 483 new PhantomWindowController(window())); |
| 475 drag_phantom_window_controller_->set_style( | 484 drag_phantom_window_controller_->set_style( |
| 476 PhantomWindowController::STYLE_WINDOW); | 485 PhantomWindowController::STYLE_WINDOW); |
| 477 // Always show the drag phantom on the |another_root| window. | 486 // Always show the drag phantom on the |another_root| window. |
| 478 drag_phantom_window_controller_->SetDestinationDisplay( | 487 drag_phantom_window_controller_->SetDestinationDisplay( |
| 479 gfx::Screen::GetDisplayMatching(another_root->GetBoundsInScreen())); | 488 gfx::Screen::GetDisplayMatching(another_root->GetBoundsInScreen())); |
| 489 if (!layer_) |
| 490 RecreateWindowLayers(); |
| 491 drag_phantom_window_controller_->set_layer(layer_); |
| 480 drag_phantom_window_controller_->Show(bounds_in_screen); | 492 drag_phantom_window_controller_->Show(bounds_in_screen); |
| 481 } else { | 493 } else { |
| 482 // No animation. | 494 // No animation. |
| 483 drag_phantom_window_controller_->SetBounds(bounds_in_screen); | 495 drag_phantom_window_controller_->SetBounds(bounds_in_screen); |
| 484 } | 496 } |
| 485 drag_phantom_window_controller_->SetOpacity(phantom_opacity); | 497 drag_phantom_window_controller_->SetOpacity(phantom_opacity); |
| 486 window()->layer()->SetOpacity(window_opacity); | 498 window()->layer()->SetOpacity(window_opacity); |
| 487 } else { | 499 } else { |
| 488 drag_phantom_window_controller_.reset(); | 500 drag_phantom_window_controller_.reset(); |
| 489 window()->layer()->SetOpacity(1.0f); | 501 window()->layer()->SetOpacity(1.0f); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 return SNAP_RIGHT_EDGE; | 574 return SNAP_RIGHT_EDGE; |
| 563 return SNAP_NONE; | 575 return SNAP_NONE; |
| 564 } | 576 } |
| 565 | 577 |
| 566 bool WorkspaceWindowResizer::ShouldAllowMouseWarp() const { | 578 bool WorkspaceWindowResizer::ShouldAllowMouseWarp() const { |
| 567 return (details_.window_component == HTCAPTION) && | 579 return (details_.window_component == HTCAPTION) && |
| 568 (window()->GetProperty(aura::client::kModalKey) == ui::MODAL_TYPE_NONE) && | 580 (window()->GetProperty(aura::client::kModalKey) == ui::MODAL_TYPE_NONE) && |
| 569 (window()->type() == aura::client::WINDOW_TYPE_NORMAL); | 581 (window()->type() == aura::client::WINDOW_TYPE_NORMAL); |
| 570 } | 582 } |
| 571 | 583 |
| 584 void WorkspaceWindowResizer::RecreateWindowLayers() { |
| 585 DCHECK(!layer_); |
| 586 layer_ = wm::RecreateWindowLayers(window()); |
| 587 // Place the layer at (0, 0) of the PhantomWindowController's window. |
| 588 gfx::Rect layer_bounds = layer_->bounds(); |
| 589 layer_bounds.set_origin(gfx::Point(0, 0)); |
| 590 layer_->SetBounds(layer_bounds); |
| 591 layer_->SetVisible(false); |
| 592 // Detach it from the current container. |
| 593 layer_->parent()->Remove(layer_); |
| 594 } |
| 595 |
| 572 } // namespace internal | 596 } // namespace internal |
| 573 } // namespace ash | 597 } // namespace ash |
| OLD | NEW |