OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/dock/docked_window_resizer.h" | 5 #include "ash/wm/dock/docked_window_resizer.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/launcher/launcher.h" | 8 #include "ash/launcher/launcher.h" |
9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
10 #include "ash/screen_ash.h" | 10 #include "ash/screen_ash.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 bool can_snap = was_docked_ || | 167 bool can_snap = was_docked_ || |
168 internal::DockedWindowLayoutManager::ShouldWindowDock(GetTarget(), | 168 internal::DockedWindowLayoutManager::ShouldWindowDock(GetTarget(), |
169 last_location_); | 169 last_location_); |
170 if (!can_snap) | 170 if (!can_snap) |
171 return false; | 171 return false; |
172 | 172 |
173 if (dock_alignment == internal::DOCKED_ALIGNMENT_LEFT || | 173 if (dock_alignment == internal::DOCKED_ALIGNMENT_LEFT || |
174 (dock_alignment == internal::DOCKED_ALIGNMENT_NONE && was_docked_)) { | 174 (dock_alignment == internal::DOCKED_ALIGNMENT_NONE && was_docked_)) { |
175 const int distance = bounds.x() - dock_bounds.x(); | 175 const int distance = bounds.x() - dock_bounds.x(); |
176 if (distance < kSnapToDockDistance && distance > -kStickyDistance) { | 176 if (distance < kSnapToDockDistance && distance > -kStickyDistance) { |
177 offset->set_x(dock_bounds.x() - bounds.x()); | 177 offset->set_x(-distance); |
178 return true; | 178 return true; |
179 } | 179 } |
180 } | 180 } |
181 if (dock_alignment == internal::DOCKED_ALIGNMENT_RIGHT || | 181 if (dock_alignment == internal::DOCKED_ALIGNMENT_RIGHT || |
182 (dock_alignment == internal::DOCKED_ALIGNMENT_NONE && was_docked_)) { | 182 (dock_alignment == internal::DOCKED_ALIGNMENT_NONE && was_docked_)) { |
183 const int distance = dock_bounds.right() - bounds.right(); | 183 const int distance = dock_bounds.right() - bounds.right(); |
184 if (distance < kSnapToDockDistance && distance > -kStickyDistance) { | 184 if (distance < kSnapToDockDistance && distance > -kStickyDistance) { |
185 offset->set_x(dock_bounds.right() - bounds.right()); | 185 offset->set_x(distance); |
186 return true; | 186 return true; |
187 } | 187 } |
188 } | 188 } |
189 return false; | 189 return false; |
190 } | 190 } |
191 | 191 |
192 void DockedWindowResizer::StartedDragging() { | 192 void DockedWindowResizer::StartedDragging() { |
193 // Tell the dock layout manager that we are dragging this window. | 193 // Tell the dock layout manager that we are dragging this window. |
194 dock_layout_->StartDragging(GetTarget()); | 194 dock_layout_->StartDragging(GetTarget()); |
195 } | 195 } |
(...skipping 10 matching lines...) Expand all Loading... | |
206 switches::kAshEnableDockedWindows)) { | 206 switches::kAshEnableDockedWindows)) { |
207 should_dock = internal::DockedWindowLayoutManager::ShouldWindowDock( | 207 should_dock = internal::DockedWindowLayoutManager::ShouldWindowDock( |
208 window, last_location_); | 208 window, last_location_); |
209 } | 209 } |
210 | 210 |
211 // Check if desired docked state is not same as current. | 211 // Check if desired docked state is not same as current. |
212 // If not same dock or undock accordingly. | 212 // If not same dock or undock accordingly. |
213 if (should_dock != | 213 if (should_dock != |
214 (window->parent()->id() == internal::kShellWindowId_DockedContainer)) { | 214 (window->parent()->id() == internal::kShellWindowId_DockedContainer)) { |
215 if (should_dock) { | 215 if (should_dock) { |
216 // Panel resizer might have attached this to the launcher. | |
217 // Docked resizer takes priority and may attach it to the docked area. | |
218 if (window->type() == aura::client::WINDOW_TYPE_PANEL) | |
219 window->SetProperty(internal::kPanelAttachedKey, false); | |
flackr
2013/07/16 22:05:45
Separate CL please.
varkha
2013/07/18 21:56:59
Done.
| |
216 aura::Window* dock_container = Shell::GetContainer( | 220 aura::Window* dock_container = Shell::GetContainer( |
217 window->GetRootWindow(), | 221 window->GetRootWindow(), |
218 internal::kShellWindowId_DockedContainer); | 222 internal::kShellWindowId_DockedContainer); |
219 dock_container->AddChild(window); | 223 dock_container->AddChild(window); |
220 } else { | 224 } else { |
221 // Reparent the window back to workspace. | 225 // Reparent the window back to workspace. |
222 // We need to be careful to give SetDefaultParentByRootWindow location in | 226 // We need to be careful to give SetDefaultParentByRootWindow location in |
223 // the right root window (matching the logic in DragWindowResizer) based | 227 // the right root window (matching the logic in DragWindowResizer) based |
224 // on which root window a mouse pointer is in. We want to undock into the | 228 // on which root window a mouse pointer is in. We want to undock into the |
225 // right screen near the edge of a multiscreen setup (based on where the | 229 // right screen near the edge of a multiscreen setup (based on where the |
226 // mouse is). | 230 // mouse is). |
227 gfx::Rect near_last_location(last_location_, gfx::Size()); | 231 gfx::Rect near_last_location(last_location_, gfx::Size()); |
228 // Reparenting will cause Relayout and possible dock shrinking. | 232 // Reparenting will cause Relayout and possible dock shrinking. |
229 window->SetDefaultParentByRootWindow(window->GetRootWindow(), | 233 window->SetDefaultParentByRootWindow(window->GetRootWindow(), |
230 near_last_location); | 234 near_last_location); |
231 // A maximized workspace may be active so we may need to switch | 235 // A maximized workspace may be active so we may need to switch |
232 // to a parent workspace of the window being dragged out. | 236 // to a parent workspace of the window being dragged out. |
233 internal::WorkspaceController* workspace_controller = | 237 internal::WorkspaceController* workspace_controller = |
234 GetRootWindowController( | 238 GetRootWindowController( |
235 window->GetRootWindow())->workspace_controller(); | 239 window->GetRootWindow())->workspace_controller(); |
236 workspace_controller->SetActiveWorkspaceByWindow(window); | 240 workspace_controller->SetActiveWorkspaceByWindow(window); |
237 } | 241 } |
238 } | 242 } |
239 dock_layout_->FinishDragging(); | 243 dock_layout_->FinishDragging(); |
240 } | 244 } |
241 | 245 |
242 } // namespace aura | 246 } // namespace aura |
OLD | NEW |