Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/aura_shell/default_container_layout_manager.h" | 5 #include "ui/aura_shell/default_container_layout_manager.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "ui/aura/desktop.h" | 8 #include "ui/aura/desktop.h" |
| 9 #include "ui/aura/event.h" | |
| 9 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
| 10 #include "ui/aura/screen_aura.h" | 11 #include "ui/aura/screen_aura.h" |
| 11 #include "ui/aura/window_types.h" | 12 #include "ui/aura/window_types.h" |
| 12 #include "ui/aura_shell/workspace/workspace.h" | 13 #include "ui/aura_shell/workspace/workspace.h" |
| 13 #include "ui/aura_shell/workspace/workspace_manager.h" | 14 #include "ui/aura_shell/workspace/workspace_manager.h" |
| 14 #include "ui/base/view_prop.h" | 15 #include "ui/base/view_prop.h" |
| 15 #include "ui/gfx/rect.h" | 16 #include "ui/gfx/rect.h" |
| 16 #include "views/widget/native_widget_aura.h" | 17 #include "views/widget/native_widget_aura.h" |
| 17 | 18 |
| 18 namespace aura_shell { | 19 namespace aura_shell { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 37 aura::MouseEvent* event) { | 38 aura::MouseEvent* event) { |
| 38 drag_window_ = drag; | 39 drag_window_ = drag; |
| 39 } | 40 } |
| 40 | 41 |
| 41 void DefaultContainerLayoutManager::CancelMoveOrResize( | 42 void DefaultContainerLayoutManager::CancelMoveOrResize( |
| 42 aura::Window* drag, | 43 aura::Window* drag, |
| 43 aura::MouseEvent* event) { | 44 aura::MouseEvent* event) { |
| 44 drag_window_ = NULL; | 45 drag_window_ = NULL; |
| 45 } | 46 } |
| 46 | 47 |
| 48 void DefaultContainerLayoutManager::ProcessMove( | |
| 49 aura::Window* drag, | |
| 50 aura::MouseEvent* event) { | |
| 51 AutoReset<bool> reset(&ignore_calculate_bounds_, true); | |
| 52 | |
| 53 // TODO(oshima): Just zooming out may (and will) move/swap window without | |
| 54 // a users's intent. We probably should scroll viewport, but that may not | |
| 55 // be enough. See crbug.com/101826 for more discussion. | |
| 56 workspace_manager_->SetOverview(true); | |
| 57 | |
| 58 gfx::Point point_in_owner = event->location(); | |
| 59 aura::Window::ConvertPointToWindow( | |
| 60 drag, | |
| 61 owner_, | |
| 62 &point_in_owner); | |
| 63 | |
| 64 aura::Window* swap_target = | |
| 65 workspace_manager_->FindSwapWindowForLocation(point_in_owner); | |
| 66 if (swap_target) | |
| 67 workspace_manager_->SwapWindow(drag, swap_target); | |
|
sky
2011/10/27 00:53:03
Don't we want to move rather than swapping?
oshima
2011/10/27 16:16:27
You're right. we want move (or rotate). I'll fix a
| |
| 68 } | |
| 69 | |
| 47 void DefaultContainerLayoutManager::EndMove( | 70 void DefaultContainerLayoutManager::EndMove( |
| 48 aura::Window* drag, | 71 aura::Window* drag, |
| 49 aura::MouseEvent* evnet) { | 72 aura::MouseEvent* evnet) { |
| 50 // TODO(oshima): finish moving window between workspaces. | 73 // TODO(oshima): finish moving window between workspaces. |
| 51 AutoReset<bool> reset(&ignore_calculate_bounds_, true); | 74 AutoReset<bool> reset(&ignore_calculate_bounds_, true); |
| 52 drag_window_ = NULL; | 75 drag_window_ = NULL; |
| 53 Workspace* workspace = workspace_manager_->GetActiveWorkspace(); | 76 Workspace* workspace = workspace_manager_->GetActiveWorkspace(); |
| 54 if (workspace) | 77 if (workspace) |
| 55 workspace->Layout(NULL); | 78 workspace->Layout(NULL, NULL); |
| 79 workspace_manager_->SetOverview(false); | |
| 56 } | 80 } |
| 57 | 81 |
| 58 void DefaultContainerLayoutManager::EndResize( | 82 void DefaultContainerLayoutManager::EndResize( |
| 59 aura::Window* drag, | 83 aura::Window* drag, |
| 60 aura::MouseEvent* evnet) { | 84 aura::MouseEvent* evnet) { |
| 61 AutoReset<bool> reset(&ignore_calculate_bounds_, true); | 85 AutoReset<bool> reset(&ignore_calculate_bounds_, true); |
| 62 drag_window_ = NULL; | 86 drag_window_ = NULL; |
| 63 Workspace* workspace = workspace_manager_->GetActiveWorkspace(); | 87 Workspace* workspace = workspace_manager_->GetActiveWorkspace(); |
| 64 if (workspace) | 88 if (workspace) |
| 65 workspace->Layout(NULL); | 89 workspace->Layout(NULL, NULL); |
| 90 workspace_manager_->SetOverview(false); | |
| 66 } | 91 } |
| 67 | 92 |
| 68 //////////////////////////////////////////////////////////////////////////////// | 93 //////////////////////////////////////////////////////////////////////////////// |
| 69 // DefaultContainerLayoutManager, aura::LayoutManager implementation: | 94 // DefaultContainerLayoutManager, aura::LayoutManager implementation: |
| 70 | 95 |
| 71 void DefaultContainerLayoutManager::OnWindowResized() { | 96 void DefaultContainerLayoutManager::OnWindowResized() { |
| 72 // Workspace is updated via DesktopObserver::OnDesktopResized. | 97 // Workspace is updated via DesktopObserver::OnDesktopResized. |
| 73 } | 98 } |
| 74 | 99 |
| 75 void DefaultContainerLayoutManager::OnWindowAdded(aura::Window* child) { | 100 void DefaultContainerLayoutManager::OnWindowAdded(aura::Window* child) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 | 156 |
| 132 Workspace* workspace = workspace_manager_->FindBy(child); | 157 Workspace* workspace = workspace_manager_->FindBy(child); |
| 133 gfx::Rect work_area = workspace->GetWorkAreaBounds(); | 158 gfx::Rect work_area = workspace->GetWorkAreaBounds(); |
| 134 requested_bounds->set_origin( | 159 requested_bounds->set_origin( |
| 135 gfx::Point(child->GetTargetBounds().x(), work_area.y())); | 160 gfx::Point(child->GetTargetBounds().x(), work_area.y())); |
| 136 *requested_bounds = requested_bounds->AdjustToFit(work_area); | 161 *requested_bounds = requested_bounds->AdjustToFit(work_area); |
| 137 } | 162 } |
| 138 | 163 |
| 139 } // namespace internal | 164 } // namespace internal |
| 140 } // namespace aura_shell | 165 } // namespace aura_shell |
| OLD | NEW |