| 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/cursor_manager.h" | 8 #include "ash/wm/cursor_manager.h" |
| 9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
| 10 #include "ui/aura/client/screen_position_client.h" |
| 10 #include "ui/aura/env.h" | 11 #include "ui/aura/env.h" |
| 11 #include "ui/aura/root_window.h" | 12 #include "ui/aura/root_window.h" |
| 12 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 13 #include "ui/aura/window_delegate.h" | 14 #include "ui/aura/window_delegate.h" |
| 14 #include "ui/base/hit_test.h" | 15 #include "ui/base/hit_test.h" |
| 15 #include "ui/base/ui_base_types.h" | 16 #include "ui/base/ui_base_types.h" |
| 16 #include "ui/compositor/layer.h" | 17 #include "ui/compositor/layer.h" |
| 17 #include "ui/compositor/scoped_layer_animation_settings.h" | 18 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 18 #include "ui/gfx/screen.h" | 19 #include "ui/gfx/screen.h" |
| 19 | 20 |
| 20 namespace ash { | 21 namespace ash { |
| 21 | 22 |
| 22 DefaultWindowResizer::~DefaultWindowResizer() { | 23 DefaultWindowResizer::~DefaultWindowResizer() { |
| 23 ash::Shell::GetInstance()->cursor_manager()->UnlockCursor(); | 24 ash::Shell::GetInstance()->cursor_manager()->UnlockCursor(); |
| 24 } | 25 } |
| 25 | 26 |
| 26 // static | 27 // static |
| 27 DefaultWindowResizer* | 28 DefaultWindowResizer* |
| 28 DefaultWindowResizer::Create(aura::Window* window, | 29 DefaultWindowResizer::Create(aura::Window* window, |
| 29 const gfx::Point& location, | 30 const gfx::Point& location, |
| 30 int window_component) { | 31 int window_component) { |
| 31 Details details(window, location, window_component); | 32 Details details(window, location, window_component); |
| 32 return details.is_resizable ? new DefaultWindowResizer(details) : NULL; | 33 return details.is_resizable ? new DefaultWindowResizer(details) : NULL; |
| 33 } | 34 } |
| 34 | 35 |
| 35 void DefaultWindowResizer::Drag(const gfx::Point& location, int event_flags) { | 36 void DefaultWindowResizer::Drag(const gfx::Point& location_in_screen, |
| 37 int event_flags) { |
| 38 // TODO(mazda|yusukes): Implement dragging an item from one display to another |
| 39 aura::RootWindow* current_root = Shell::GetRootWindowAt(location_in_screen); |
| 40 if (current_root != details_.window->GetRootWindow()) |
| 41 return; |
| 42 |
| 43 gfx::Point location_in_root = location_in_screen; |
| 44 aura::client::GetScreenPositionClient(current_root)-> |
| 45 ConvertPointFromScreen(current_root, &location_in_root); |
| 46 |
| 36 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? | 47 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? |
| 37 0 : ash::Shell::GetInstance()->GetGridSize(); | 48 0 : ash::Shell::GetInstance()->GetGridSize(); |
| 38 gfx::Rect bounds(CalculateBoundsForDrag(details_, location, grid_size)); | 49 gfx::Rect bounds( |
| 50 CalculateBoundsForDrag(details_, location_in_root, grid_size)); |
| 39 if (bounds != details_.window->bounds()) { | 51 if (bounds != details_.window->bounds()) { |
| 40 did_move_or_resize_ = true; | 52 did_move_or_resize_ = true; |
| 41 details_.window->SetBounds(bounds); | 53 details_.window->SetBounds(bounds); |
| 42 } | 54 } |
| 43 } | 55 } |
| 44 | 56 |
| 45 void DefaultWindowResizer::CompleteDrag(int event_flags) { | 57 void DefaultWindowResizer::CompleteDrag(int event_flags) { |
| 46 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? | 58 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? |
| 47 0 : ash::Shell::GetInstance()->GetGridSize(); | 59 0 : ash::Shell::GetInstance()->GetGridSize(); |
| 48 if (grid_size <= 1 || !did_move_or_resize_) | 60 if (grid_size <= 1 || !did_move_or_resize_) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 73 } | 85 } |
| 74 | 86 |
| 75 DefaultWindowResizer::DefaultWindowResizer(const Details& details) | 87 DefaultWindowResizer::DefaultWindowResizer(const Details& details) |
| 76 : details_(details), | 88 : details_(details), |
| 77 did_move_or_resize_(false) { | 89 did_move_or_resize_(false) { |
| 78 DCHECK(details_.is_resizable); | 90 DCHECK(details_.is_resizable); |
| 79 ash::Shell::GetInstance()->cursor_manager()->LockCursor(); | 91 ash::Shell::GetInstance()->cursor_manager()->LockCursor(); |
| 80 } | 92 } |
| 81 | 93 |
| 82 } // namespace aura | 94 } // namespace aura |
| OLD | NEW |