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 // TODO(oshima): We should support simply moving to another |
| 64 // workspace when the destination workspace has enough room to accomodate. |
| 65 aura::Window* rotate_target = |
| 66 workspace_manager_->FindRotateWindowForLocation(point_in_owner); |
| 67 if (rotate_target) |
| 68 workspace_manager_->RotateWindows(drag, rotate_target); |
| 69 } |
| 70 |
47 void DefaultContainerLayoutManager::EndMove( | 71 void DefaultContainerLayoutManager::EndMove( |
48 aura::Window* drag, | 72 aura::Window* drag, |
49 aura::MouseEvent* evnet) { | 73 aura::MouseEvent* evnet) { |
50 // TODO(oshima): finish moving window between workspaces. | 74 // TODO(oshima): finish moving window between workspaces. |
51 AutoReset<bool> reset(&ignore_calculate_bounds_, true); | 75 AutoReset<bool> reset(&ignore_calculate_bounds_, true); |
52 drag_window_ = NULL; | 76 drag_window_ = NULL; |
53 Workspace* workspace = workspace_manager_->GetActiveWorkspace(); | 77 Workspace* workspace = workspace_manager_->GetActiveWorkspace(); |
54 if (workspace) | 78 if (workspace) |
55 workspace->Layout(NULL); | 79 workspace->Layout(NULL, NULL); |
| 80 workspace_manager_->SetOverview(false); |
56 } | 81 } |
57 | 82 |
58 void DefaultContainerLayoutManager::EndResize( | 83 void DefaultContainerLayoutManager::EndResize( |
59 aura::Window* drag, | 84 aura::Window* drag, |
60 aura::MouseEvent* evnet) { | 85 aura::MouseEvent* evnet) { |
61 AutoReset<bool> reset(&ignore_calculate_bounds_, true); | 86 AutoReset<bool> reset(&ignore_calculate_bounds_, true); |
62 drag_window_ = NULL; | 87 drag_window_ = NULL; |
63 Workspace* workspace = workspace_manager_->GetActiveWorkspace(); | 88 Workspace* workspace = workspace_manager_->GetActiveWorkspace(); |
64 if (workspace) | 89 if (workspace) |
65 workspace->Layout(NULL); | 90 workspace->Layout(NULL, NULL); |
| 91 workspace_manager_->SetOverview(false); |
66 } | 92 } |
67 | 93 |
68 //////////////////////////////////////////////////////////////////////////////// | 94 //////////////////////////////////////////////////////////////////////////////// |
69 // DefaultContainerLayoutManager, aura::LayoutManager implementation: | 95 // DefaultContainerLayoutManager, aura::LayoutManager implementation: |
70 | 96 |
71 void DefaultContainerLayoutManager::OnWindowResized() { | 97 void DefaultContainerLayoutManager::OnWindowResized() { |
72 // Workspace is updated via DesktopObserver::OnDesktopResized. | 98 // Workspace is updated via DesktopObserver::OnDesktopResized. |
73 } | 99 } |
74 | 100 |
75 void DefaultContainerLayoutManager::OnWindowAdded(aura::Window* child) { | 101 void DefaultContainerLayoutManager::OnWindowAdded(aura::Window* child) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 157 |
132 Workspace* workspace = workspace_manager_->FindBy(child); | 158 Workspace* workspace = workspace_manager_->FindBy(child); |
133 gfx::Rect work_area = workspace->GetWorkAreaBounds(); | 159 gfx::Rect work_area = workspace->GetWorkAreaBounds(); |
134 requested_bounds->set_origin( | 160 requested_bounds->set_origin( |
135 gfx::Point(child->GetTargetBounds().x(), work_area.y())); | 161 gfx::Point(child->GetTargetBounds().x(), work_area.y())); |
136 *requested_bounds = requested_bounds->AdjustToFit(work_area); | 162 *requested_bounds = requested_bounds->AdjustToFit(work_area); |
137 } | 163 } |
138 | 164 |
139 } // namespace internal | 165 } // namespace internal |
140 } // namespace aura_shell | 166 } // namespace aura_shell |
OLD | NEW |