Chromium Code Reviews| 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/cursor_manager.h" | 9 #include "ash/wm/cursor_manager.h" |
| 9 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
| 11 #include "ui/aura/client/screen_position_client.h" | |
| 10 #include "ui/aura/env.h" | 12 #include "ui/aura/env.h" |
| 11 #include "ui/aura/root_window.h" | 13 #include "ui/aura/root_window.h" |
| 12 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
| 13 #include "ui/aura/window_delegate.h" | 15 #include "ui/aura/window_delegate.h" |
| 14 #include "ui/base/hit_test.h" | 16 #include "ui/base/hit_test.h" |
| 15 #include "ui/base/ui_base_types.h" | 17 #include "ui/base/ui_base_types.h" |
| 16 #include "ui/compositor/layer.h" | 18 #include "ui/compositor/layer.h" |
| 17 #include "ui/compositor/scoped_layer_animation_settings.h" | 19 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 18 #include "ui/gfx/screen.h" | 20 #include "ui/gfx/screen.h" |
| 19 | 21 |
| 20 namespace ash { | 22 namespace ash { |
| 21 | 23 |
| 22 DefaultWindowResizer::~DefaultWindowResizer() { | 24 DefaultWindowResizer::~DefaultWindowResizer() { |
| 23 ash::Shell::GetInstance()->cursor_manager()->UnlockCursor(); | 25 ash::Shell::GetInstance()->cursor_manager()->UnlockCursor(); |
| 24 } | 26 } |
| 25 | 27 |
| 26 // static | 28 // static |
| 27 DefaultWindowResizer* | 29 DefaultWindowResizer* |
| 28 DefaultWindowResizer::Create(aura::Window* window, | 30 DefaultWindowResizer::Create(aura::Window* window, |
| 29 const gfx::Point& location, | 31 const gfx::Point& location, |
| 30 int window_component) { | 32 int window_component) { |
| 31 Details details(window, location, window_component); | 33 Details details(window, location, window_component); |
| 32 return details.is_resizable ? new DefaultWindowResizer(details) : NULL; | 34 return details.is_resizable ? new DefaultWindowResizer(details) : NULL; |
| 33 } | 35 } |
| 34 | 36 |
| 35 void DefaultWindowResizer::Drag(const gfx::Point& location, int event_flags) { | 37 void DefaultWindowResizer::Drag(const gfx::Point& location, int event_flags) { |
| 38 std::pair<aura::RootWindow*, gfx::Point> actual_location = | |
| 39 wm::GetRootWindowRelativeToWindow(details_.window->parent(), location); | |
| 40 | |
| 41 aura::RootWindow* current_root = actual_location.first; | |
| 42 gfx::Point location_in_root = actual_location.second; | |
| 43 gfx::Point location_in_screen = actual_location.second; | |
| 44 aura::client::GetScreenPositionClient(current_root)-> | |
| 45 ConvertPointToScreen(current_root, &location_in_screen); | |
|
sky
2012/08/03 17:07:18
This is too much code for something that seems lik
Yusuke Sato
2012/08/03 23:18:45
Done.
| |
| 46 | |
| 47 // TODO(mazda|yusukes): Implement dragging an item from one display to another | |
| 48 if (current_root != details_.window->GetRootWindow()) | |
| 49 return; | |
| 50 | |
| 51 aura::client::GetScreenPositionClient(current_root)-> | |
| 52 ConvertPointFromScreen(current_root, &location_in_root); | |
| 53 | |
| 36 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? | 54 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? |
| 37 0 : ash::Shell::GetInstance()->GetGridSize(); | 55 0 : ash::Shell::GetInstance()->GetGridSize(); |
| 38 gfx::Rect bounds(CalculateBoundsForDrag(details_, location, grid_size)); | 56 gfx::Rect bounds( |
| 57 CalculateBoundsForDrag(details_, location_in_root, grid_size)); | |
|
sky
2012/08/03 17:07:18
Why does this need to change?
Yusuke Sato
2012/08/03 23:18:45
Reverted.
| |
| 39 if (bounds != details_.window->bounds()) { | 58 if (bounds != details_.window->bounds()) { |
| 40 did_move_or_resize_ = true; | 59 did_move_or_resize_ = true; |
| 41 details_.window->SetBounds(bounds); | 60 details_.window->SetBounds(bounds); |
| 42 } | 61 } |
| 43 } | 62 } |
| 44 | 63 |
| 45 void DefaultWindowResizer::CompleteDrag(int event_flags) { | 64 void DefaultWindowResizer::CompleteDrag(int event_flags) { |
| 46 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? | 65 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? |
| 47 0 : ash::Shell::GetInstance()->GetGridSize(); | 66 0 : ash::Shell::GetInstance()->GetGridSize(); |
| 48 if (grid_size <= 1 || !did_move_or_resize_) | 67 if (grid_size <= 1 || !did_move_or_resize_) |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 73 } | 92 } |
| 74 | 93 |
| 75 DefaultWindowResizer::DefaultWindowResizer(const Details& details) | 94 DefaultWindowResizer::DefaultWindowResizer(const Details& details) |
| 76 : details_(details), | 95 : details_(details), |
| 77 did_move_or_resize_(false) { | 96 did_move_or_resize_(false) { |
| 78 DCHECK(details_.is_resizable); | 97 DCHECK(details_.is_resizable); |
| 79 ash::Shell::GetInstance()->cursor_manager()->LockCursor(); | 98 ash::Shell::GetInstance()->cursor_manager()->LockCursor(); |
| 80 } | 99 } |
| 81 | 100 |
| 82 } // namespace aura | 101 } // namespace aura |
| OLD | NEW |