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/display/display_controller.h" | 8 #include "ash/display/display_controller.h" |
9 #include "ash/launcher/launcher.h" | 9 #include "ash/launcher/launcher.h" |
10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
11 #include "ash/screen_ash.h" | 11 #include "ash/screen_ash.h" |
12 #include "ash/shelf/shelf_types.h" | 12 #include "ash/shelf/shelf_types.h" |
13 #include "ash/shelf/shelf_widget.h" | 13 #include "ash/shelf/shelf_widget.h" |
14 #include "ash/shell.h" | 14 #include "ash/shell.h" |
15 #include "ash/shell_window_ids.h" | 15 #include "ash/shell_window_ids.h" |
16 #include "ash/wm/coordinate_conversion.h" | 16 #include "ash/wm/coordinate_conversion.h" |
17 #include "ash/wm/dock/docked_window_layout_manager.h" | 17 #include "ash/wm/dock/docked_window_layout_manager.h" |
18 #include "ash/wm/window_state.h" | 18 #include "ash/wm/window_state.h" |
19 #include "ash/wm/window_util.h" | 19 #include "ash/wm/window_util.h" |
20 #include "ash/wm/workspace/magnetism_matcher.h" | 20 #include "ash/wm/workspace/magnetism_matcher.h" |
21 #include "ash/wm/workspace/workspace_window_resizer.h" | 21 #include "ash/wm/workspace/workspace_window_resizer.h" |
22 #include "base/command_line.h" | 22 #include "base/command_line.h" |
23 #include "base/memory/weak_ptr.h" | 23 #include "base/memory/weak_ptr.h" |
24 #include "base/metrics/histogram.h" | |
24 #include "ui/aura/client/aura_constants.h" | 25 #include "ui/aura/client/aura_constants.h" |
25 #include "ui/aura/client/window_tree_client.h" | 26 #include "ui/aura/client/window_tree_client.h" |
26 #include "ui/aura/env.h" | 27 #include "ui/aura/env.h" |
27 #include "ui/aura/root_window.h" | 28 #include "ui/aura/root_window.h" |
28 #include "ui/aura/window.h" | 29 #include "ui/aura/window.h" |
29 #include "ui/aura/window_delegate.h" | 30 #include "ui/aura/window_delegate.h" |
30 #include "ui/base/hit_test.h" | 31 #include "ui/base/hit_test.h" |
31 #include "ui/base/ui_base_types.h" | 32 #include "ui/base/ui_base_types.h" |
32 #include "ui/gfx/screen.h" | 33 #include "ui/gfx/screen.h" |
33 #include "ui/views/widget/widget.h" | 34 #include "ui/views/widget/widget.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 return next_window_resizer_->GetTarget(); | 155 return next_window_resizer_->GetTarget(); |
155 } | 156 } |
156 | 157 |
157 const gfx::Point& DockedWindowResizer::GetInitialLocation() const { | 158 const gfx::Point& DockedWindowResizer::GetInitialLocation() const { |
158 return details_.initial_location_in_parent; | 159 return details_.initial_location_in_parent; |
159 } | 160 } |
160 | 161 |
161 DockedWindowResizer::DockedWindowResizer(WindowResizer* next_window_resizer, | 162 DockedWindowResizer::DockedWindowResizer(WindowResizer* next_window_resizer, |
162 const Details& details) | 163 const Details& details) |
163 : details_(details), | 164 : details_(details), |
165 last_docked_action_(base::Time::Now()), | |
164 next_window_resizer_(next_window_resizer), | 166 next_window_resizer_(next_window_resizer), |
165 dock_layout_(NULL), | 167 dock_layout_(NULL), |
166 initial_dock_layout_(NULL), | 168 initial_dock_layout_(NULL), |
167 did_move_or_resize_(false), | 169 did_move_or_resize_(false), |
168 was_docked_(false), | 170 was_docked_(false), |
169 is_docked_(false), | 171 is_docked_(false), |
170 weak_ptr_factory_(this) { | 172 weak_ptr_factory_(this) { |
171 DCHECK(details_.is_resizable); | 173 DCHECK(details_.is_resizable); |
172 aura::Window* dock_container = Shell::GetContainer( | 174 aura::Window* dock_container = Shell::GetContainer( |
173 details.window->GetRootWindow(), | 175 details.window->GetRootWindow(), |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
255 window->parent(), dock_layout_->dragged_bounds()); | 257 window->parent(), dock_layout_->dragged_bounds()); |
256 if (!bounds.IsEmpty() && bounds.width() != window->bounds().width()) { | 258 if (!bounds.IsEmpty() && bounds.width() != window->bounds().width()) { |
257 window->SetBounds(bounds); | 259 window->SetBounds(bounds); |
258 } | 260 } |
259 } | 261 } |
260 // No longer restore to pre-docked bounds if a window has been resized. | 262 // No longer restore to pre-docked bounds if a window has been resized. |
261 if (is_resized && is_docked_) | 263 if (is_resized && is_docked_) |
262 window_state->ClearRestoreBounds(); | 264 window_state->ClearRestoreBounds(); |
263 | 265 |
264 // Check if the window needs to be docked or returned to workspace. | 266 // Check if the window needs to be docked or returned to workspace. |
267 DockedAction action = DOCKED_ACTION_CANCEL; | |
265 aura::Window* dock_container = Shell::GetContainer( | 268 aura::Window* dock_container = Shell::GetContainer( |
266 window->GetRootWindow(), | 269 window->GetRootWindow(), |
267 kShellWindowId_DockedContainer); | 270 kShellWindowId_DockedContainer); |
268 if ((is_resized || !attached_panel) && | 271 if ((is_resized || !attached_panel) && |
269 is_docked_ != (window->parent() == dock_container)) { | 272 is_docked_ != (window->parent() == dock_container)) { |
270 if (is_docked_) { | 273 if (is_docked_) { |
271 wm::ReparentChildWithTransientChildren(dock_container, window); | 274 wm::ReparentChildWithTransientChildren(dock_container, window); |
275 action = DOCKED_ACTION_DOCK; | |
272 } else if (window->parent()->id() == kShellWindowId_DockedContainer) { | 276 } else if (window->parent()->id() == kShellWindowId_DockedContainer) { |
273 // Reparent the window back to workspace. | 277 // Reparent the window back to workspace. |
274 // We need to be careful to give ParentWindowWithContext a location in | 278 // We need to be careful to give ParentWindowWithContext a location in |
275 // the right root window (matching the logic in DragWindowResizer) based | 279 // the right root window (matching the logic in DragWindowResizer) based |
276 // on which root window a mouse pointer is in. We want to undock into the | 280 // on which root window a mouse pointer is in. We want to undock into the |
277 // right screen near the edge of a multiscreen setup (based on where the | 281 // right screen near the edge of a multiscreen setup (based on where the |
278 // mouse is). | 282 // mouse is). |
279 gfx::Rect near_last_location(last_location_, gfx::Size()); | 283 gfx::Rect near_last_location(last_location_, gfx::Size()); |
280 // Reparenting will cause Relayout and possible dock shrinking. | 284 // Reparenting will cause Relayout and possible dock shrinking. |
281 aura::Window* previous_parent = window->parent(); | 285 aura::Window* previous_parent = window->parent(); |
282 aura::client::ParentWindowWithContext(window, window, near_last_location); | 286 aura::client::ParentWindowWithContext(window, window, near_last_location); |
283 if (window->parent() != previous_parent) | 287 if (window->parent() != previous_parent) |
284 wm::ReparentTransientChildrenOfChild(window->parent(), window); | 288 wm::ReparentTransientChildrenOfChild(window->parent(), window); |
289 action = was_docked_ ? DOCKED_ACTION_UNDOCK : DOCKED_ACTION_CANCEL; | |
285 } | 290 } |
291 } else { | |
292 // Docked state was not changed but still need to record a UMA action. | |
293 if (is_resized && is_docked_ && was_docked_) | |
294 action = DOCKED_ACTION_RESIZE; | |
295 else if (is_docked_ && was_docked_) | |
296 action = DOCKED_ACTION_REORDER; | |
297 else if (is_docked_ && !was_docked_) | |
298 action = DOCKED_ACTION_DOCK; | |
299 else | |
300 action = DOCKED_ACTION_CANCEL; | |
flackr
2013/10/29 21:33:49
As with the time between use below, I don't think
varkha
2013/10/30 19:21:00
Done.
| |
286 } | 301 } |
302 if (action != DOCKED_ACTION_CANCEL) { | |
303 base::Time time_now = base::Time::Now(); | |
304 UMA_HISTOGRAM_LONG_TIMES_100("Ash.Dock.TimeBetweenUse", | |
305 time_now - last_docked_action_); | |
flackr
2013/10/29 21:33:49
Doesn't DockedWindowResizer::FinishDragging get ca
varkha
2013/10/30 19:21:00
Done.
| |
306 last_docked_action_ = time_now; | |
307 } | |
308 UMA_HISTOGRAM_ENUMERATION("Ash.Dock.Actions", action, DOCKED_ACTION_COUNT); | |
287 dock_layout_->FinishDragging(); | 309 dock_layout_->FinishDragging(); |
288 | 310 |
289 // If we started the drag in one root window and moved into another root | 311 // If we started the drag in one root window and moved into another root |
290 // but then canceled the drag we may need to inform the original layout | 312 // but then canceled the drag we may need to inform the original layout |
291 // manager that the drag is finished. | 313 // manager that the drag is finished. |
292 if (initial_dock_layout_ != dock_layout_) | 314 if (initial_dock_layout_ != dock_layout_) |
293 initial_dock_layout_->FinishDragging(); | 315 initial_dock_layout_->FinishDragging(); |
294 is_docked_ = false; | 316 is_docked_ = false; |
295 } | 317 } |
296 | 318 |
297 } // namespace internal | 319 } // namespace internal |
298 } // namespace ash | 320 } // namespace ash |
OLD | NEW |