| 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/default_window_resizer.h" | 5 #include "ash/wm/default_window_resizer.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/wm/coordinate_conversion.h" | 8 #include "ash/wm/coordinate_conversion.h" |
| 9 #include "ash/wm/cursor_manager.h" | 9 #include "ash/wm/cursor_manager.h" |
| 10 #include "ash/wm/property_util.h" |
| 10 #include "ui/aura/client/aura_constants.h" | 11 #include "ui/aura/client/aura_constants.h" |
| 11 #include "ui/aura/env.h" | 12 #include "ui/aura/env.h" |
| 12 #include "ui/aura/root_window.h" | 13 #include "ui/aura/root_window.h" |
| 13 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
| 14 #include "ui/aura/window_delegate.h" | 15 #include "ui/aura/window_delegate.h" |
| 15 #include "ui/base/hit_test.h" | 16 #include "ui/base/hit_test.h" |
| 16 #include "ui/base/ui_base_types.h" | 17 #include "ui/base/ui_base_types.h" |
| 17 #include "ui/compositor/layer.h" | 18 #include "ui/compositor/layer.h" |
| 18 #include "ui/compositor/scoped_layer_animation_settings.h" | 19 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 19 #include "ui/gfx/screen.h" | 20 #include "ui/gfx/screen.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 39 | 40 |
| 40 // TODO(mazda|yusukes): Implement dragging an item from one display to another | 41 // TODO(mazda|yusukes): Implement dragging an item from one display to another |
| 41 aura::RootWindow* current_root = actual_location.first; | 42 aura::RootWindow* current_root = actual_location.first; |
| 42 if (current_root != details_.window->GetRootWindow()) | 43 if (current_root != details_.window->GetRootWindow()) |
| 43 return; | 44 return; |
| 44 | 45 |
| 45 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? | 46 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? |
| 46 0 : ash::Shell::GetInstance()->GetGridSize(); | 47 0 : ash::Shell::GetInstance()->GetGridSize(); |
| 47 gfx::Rect bounds(CalculateBoundsForDrag(details_, location, grid_size)); | 48 gfx::Rect bounds(CalculateBoundsForDrag(details_, location, grid_size)); |
| 48 if (bounds != details_.window->bounds()) { | 49 if (bounds != details_.window->bounds()) { |
| 50 if (!did_move_or_resize_ && !details_.restore_bounds.IsEmpty()) |
| 51 ClearRestoreBounds(details_.window); |
| 49 did_move_or_resize_ = true; | 52 did_move_or_resize_ = true; |
| 50 details_.window->SetBounds(bounds); | 53 details_.window->SetBounds(bounds); |
| 51 } | 54 } |
| 52 } | 55 } |
| 53 | 56 |
| 54 void DefaultWindowResizer::CompleteDrag(int event_flags) { | 57 void DefaultWindowResizer::CompleteDrag(int event_flags) { |
| 55 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? | 58 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? |
| 56 0 : ash::Shell::GetInstance()->GetGridSize(); | 59 0 : ash::Shell::GetInstance()->GetGridSize(); |
| 57 if (grid_size <= 1 || !did_move_or_resize_) | 60 if (grid_size <= 1 || !did_move_or_resize_) |
| 58 return; | 61 return; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 72 // Use a small duration since the grid is small. | 75 // Use a small duration since the grid is small. |
| 73 scoped_setter.SetTransitionDuration(base::TimeDelta::FromMilliseconds(100)); | 76 scoped_setter.SetTransitionDuration(base::TimeDelta::FromMilliseconds(100)); |
| 74 details_.window->SetBounds(new_bounds); | 77 details_.window->SetBounds(new_bounds); |
| 75 } | 78 } |
| 76 | 79 |
| 77 void DefaultWindowResizer::RevertDrag() { | 80 void DefaultWindowResizer::RevertDrag() { |
| 78 if (!did_move_or_resize_) | 81 if (!did_move_or_resize_) |
| 79 return; | 82 return; |
| 80 | 83 |
| 81 details_.window->SetBounds(details_.initial_bounds); | 84 details_.window->SetBounds(details_.initial_bounds); |
| 85 |
| 86 if (!details_.restore_bounds.IsEmpty()) |
| 87 SetRestoreBoundsInScreen(details_.window, details_.restore_bounds); |
| 82 } | 88 } |
| 83 | 89 |
| 84 aura::Window* DefaultWindowResizer::GetTarget() { | 90 aura::Window* DefaultWindowResizer::GetTarget() { |
| 85 return details_.window; | 91 return details_.window; |
| 86 } | 92 } |
| 87 | 93 |
| 88 DefaultWindowResizer::DefaultWindowResizer(const Details& details) | 94 DefaultWindowResizer::DefaultWindowResizer(const Details& details) |
| 89 : details_(details), | 95 : details_(details), |
| 90 did_move_or_resize_(false) { | 96 did_move_or_resize_(false) { |
| 91 DCHECK(details_.is_resizable); | 97 DCHECK(details_.is_resizable); |
| 92 ash::Shell::GetInstance()->cursor_manager()->LockCursor(); | 98 ash::Shell::GetInstance()->cursor_manager()->LockCursor(); |
| 93 } | 99 } |
| 94 | 100 |
| 95 } // namespace aura | 101 } // namespace aura |
| OLD | NEW |