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/coordinate_conversion.h" |
| 9 #include "ash/wm/cursor_manager.h" | 9 #include "ash/wm/cursor_manager.h" |
| 10 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 Details details(window, location, window_component); | 32 Details details(window, location, window_component); |
| 33 return details.is_resizable ? new DefaultWindowResizer(details) : NULL; | 33 return details.is_resizable ? new DefaultWindowResizer(details) : NULL; |
| 34 } | 34 } |
| 35 | 35 |
| 36 void DefaultWindowResizer::Drag(const gfx::Point& location, int event_flags) { | 36 void DefaultWindowResizer::Drag(const gfx::Point& location, int event_flags) { |
| 37 std::pair<aura::RootWindow*, gfx::Point> actual_location = | 37 std::pair<aura::RootWindow*, gfx::Point> actual_location = |
| 38 wm::GetRootWindowRelativeToWindow(details_.window->parent(), location); | 38 wm::GetRootWindowRelativeToWindow(details_.window->parent(), location); |
| 39 | 39 |
| 40 // TODO(mazda|yusukes): Implement dragging an item from one display to another | 40 // TODO(mazda|yusukes): Implement dragging an item from one display to another |
| 41 aura::RootWindow* current_root = actual_location.first; | 41 aura::RootWindow* current_root = actual_location.first; |
| 42 gfx::Point location_in_screen = actual_location.second; | |
| 43 wm::ConvertPointToScreen(current_root, &location_in_screen); | |
| 42 if (current_root != details_.window->GetRootWindow()) | 44 if (current_root != details_.window->GetRootWindow()) |
| 43 return; | 45 return; |
| 44 | 46 |
| 45 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? | 47 int grid_size = event_flags & ui::EF_CONTROL_DOWN ? |
| 46 0 : ash::Shell::GetInstance()->GetGridSize(); | 48 0 : ash::Shell::GetInstance()->GetGridSize(); |
| 47 gfx::Rect bounds(CalculateBoundsForDrag(details_, location, grid_size)); | 49 gfx::Rect bounds( |
| 50 CalculateBoundsForDrag(details_, location_in_screen, grid_size)); | |
|
sky
2012/08/06 20:45:03
Why are any of these in screen coordinates?
Yusuke Sato
2012/08/06 21:36:41
Thanks, it's better to keep using the original coo
| |
| 48 if (bounds != details_.window->bounds()) { | 51 if (bounds != details_.window->bounds()) { |
| 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_) |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 82 } | 85 } |
| 83 | 86 |
| 84 DefaultWindowResizer::DefaultWindowResizer(const Details& details) | 87 DefaultWindowResizer::DefaultWindowResizer(const Details& details) |
| 85 : details_(details), | 88 : details_(details), |
| 86 did_move_or_resize_(false) { | 89 did_move_or_resize_(false) { |
| 87 DCHECK(details_.is_resizable); | 90 DCHECK(details_.is_resizable); |
| 88 ash::Shell::GetInstance()->cursor_manager()->LockCursor(); | 91 ash::Shell::GetInstance()->cursor_manager()->LockCursor(); |
| 89 } | 92 } |
| 90 | 93 |
| 91 } // namespace aura | 94 } // namespace aura |
| OLD | NEW |