OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_layout_manager.h" | 5 #include "ash/wm/dock/docked_window_layout_manager.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/screen_ash.h" | 9 #include "ash/screen_ash.h" |
10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
11 #include "ash/shelf/shelf_types.h" | 11 #include "ash/shelf/shelf_types.h" |
12 #include "ash/shelf/shelf_widget.h" | 12 #include "ash/shelf/shelf_widget.h" |
13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
14 #include "ash/shell_window_ids.h" | 14 #include "ash/shell_window_ids.h" |
15 #include "ash/wm/coordinate_conversion.h" | 15 #include "ash/wm/coordinate_conversion.h" |
16 #include "ash/wm/window_animations.h" | 16 #include "ash/wm/window_animations.h" |
17 #include "ash/wm/window_properties.h" | 17 #include "ash/wm/window_properties.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_controller.h" | 20 #include "ash/wm/workspace_controller.h" |
21 #include "base/auto_reset.h" | 21 #include "base/auto_reset.h" |
22 #include "base/command_line.h" | 22 #include "base/command_line.h" |
| 23 #include "base/metrics/histogram.h" |
23 #include "third_party/skia/include/core/SkColor.h" | 24 #include "third_party/skia/include/core/SkColor.h" |
24 #include "ui/aura/client/activation_client.h" | 25 #include "ui/aura/client/activation_client.h" |
25 #include "ui/aura/client/focus_client.h" | 26 #include "ui/aura/client/focus_client.h" |
26 #include "ui/aura/client/window_tree_client.h" | 27 #include "ui/aura/client/window_tree_client.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/compositor/scoped_layer_animation_settings.h" | 31 #include "ui/compositor/scoped_layer_animation_settings.h" |
31 #include "ui/gfx/rect.h" | 32 #include "ui/gfx/rect.h" |
32 | 33 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 const gfx::Point& location) { | 86 const gfx::Point& location) { |
86 gfx::Rect near_location(location, gfx::Size()); | 87 gfx::Rect near_location(location, gfx::Size()); |
87 aura::Window* dock = Shell::GetContainer( | 88 aura::Window* dock = Shell::GetContainer( |
88 wm::GetRootWindowMatching(near_location), | 89 wm::GetRootWindowMatching(near_location), |
89 kShellWindowId_DockedContainer); | 90 kShellWindowId_DockedContainer); |
90 return static_cast<internal::DockedWindowLayoutManager*>( | 91 return static_cast<internal::DockedWindowLayoutManager*>( |
91 dock->layout_manager()); | 92 dock->layout_manager()); |
92 } | 93 } |
93 | 94 |
94 // Returns true if a window is a popup or a transient child. | 95 // Returns true if a window is a popup or a transient child. |
95 bool IsPopupOrTransient(aura::Window* window) { | 96 bool IsPopupOrTransient(const aura::Window* window) { |
96 return (window->type() == aura::client::WINDOW_TYPE_POPUP || | 97 return (window->type() == aura::client::WINDOW_TYPE_POPUP || |
97 window->transient_parent()); | 98 window->transient_parent()); |
98 } | 99 } |
99 | 100 |
100 // Certain windows (minimized, hidden or popups) do not matter to docking. | 101 // Certain windows (minimized, hidden or popups) do not matter to docking. |
101 bool IsUsedByLayout(aura::Window* window) { | 102 bool IsUsedByLayout(const aura::Window* window) { |
102 return (window->IsVisible() && | 103 return (window->IsVisible() && |
103 !wm::GetWindowState(window)->IsMinimized() && | 104 !wm::GetWindowState(window)->IsMinimized() && |
104 !IsPopupOrTransient(window)); | 105 !IsPopupOrTransient(window)); |
105 } | 106 } |
106 | 107 |
107 void UndockWindow(aura::Window* window) { | 108 void UndockWindow(aura::Window* window) { |
108 gfx::Rect previous_bounds = window->bounds(); | 109 gfx::Rect previous_bounds = window->bounds(); |
109 aura::Window* previous_parent = window->parent(); | 110 aura::Window* previous_parent = window->parent(); |
110 aura::client::ParentWindowWithContext(window, window, gfx::Rect()); | 111 aura::client::ParentWindowWithContext(window, window, gfx::Rect()); |
111 if (window->parent() != previous_parent) | 112 if (window->parent() != previous_parent) |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 dragged_window_(NULL), | 242 dragged_window_(NULL), |
242 is_dragged_window_docked_(false), | 243 is_dragged_window_docked_(false), |
243 is_dragged_from_dock_(false), | 244 is_dragged_from_dock_(false), |
244 launcher_(NULL), | 245 launcher_(NULL), |
245 workspace_controller_(workspace_controller), | 246 workspace_controller_(workspace_controller), |
246 in_fullscreen_(workspace_controller_->GetWindowState() == | 247 in_fullscreen_(workspace_controller_->GetWindowState() == |
247 WORKSPACE_WINDOW_STATE_FULL_SCREEN), | 248 WORKSPACE_WINDOW_STATE_FULL_SCREEN), |
248 docked_width_(0), | 249 docked_width_(0), |
249 alignment_(DOCKED_ALIGNMENT_NONE), | 250 alignment_(DOCKED_ALIGNMENT_NONE), |
250 last_active_window_(NULL), | 251 last_active_window_(NULL), |
| 252 last_action_time_(base::Time::Now()), |
251 background_widget_(new DockedBackgroundWidget(dock_container_)) { | 253 background_widget_(new DockedBackgroundWidget(dock_container_)) { |
252 DCHECK(dock_container); | 254 DCHECK(dock_container); |
253 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> | 255 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> |
254 AddObserver(this); | 256 AddObserver(this); |
255 Shell::GetInstance()->AddShellObserver(this); | 257 Shell::GetInstance()->AddShellObserver(this); |
256 } | 258 } |
257 | 259 |
258 DockedWindowLayoutManager::~DockedWindowLayoutManager() { | 260 DockedWindowLayoutManager::~DockedWindowLayoutManager() { |
259 Shutdown(); | 261 Shutdown(); |
260 } | 262 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 } | 304 } |
303 | 305 |
304 void DockedWindowLayoutManager::UndockDraggedWindow() { | 306 void DockedWindowLayoutManager::UndockDraggedWindow() { |
305 DCHECK(!IsPopupOrTransient(dragged_window_)); | 307 DCHECK(!IsPopupOrTransient(dragged_window_)); |
306 OnDraggedWindowUndocked(); | 308 OnDraggedWindowUndocked(); |
307 Relayout(); | 309 Relayout(); |
308 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); | 310 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); |
309 is_dragged_from_dock_ = false; | 311 is_dragged_from_dock_ = false; |
310 } | 312 } |
311 | 313 |
312 void DockedWindowLayoutManager::FinishDragging() { | 314 void DockedWindowLayoutManager::FinishDragging(DockedAction action, |
| 315 DockedActionSource source) { |
313 DCHECK(dragged_window_); | 316 DCHECK(dragged_window_); |
314 DCHECK(!IsPopupOrTransient(dragged_window_)); | 317 DCHECK(!IsPopupOrTransient(dragged_window_)); |
315 if (is_dragged_window_docked_) | 318 if (is_dragged_window_docked_) |
316 OnDraggedWindowUndocked(); | 319 OnDraggedWindowUndocked(); |
317 DCHECK (!is_dragged_window_docked_); | 320 DCHECK (!is_dragged_window_docked_); |
318 // Stop observing a window unless it is docked container's child in which | 321 // Stop observing a window unless it is docked container's child in which |
319 // case it needs to keep being observed after the drag completes. | 322 // case it needs to keep being observed after the drag completes. |
320 if (dragged_window_->parent() != dock_container_) { | 323 if (dragged_window_->parent() != dock_container_) { |
321 dragged_window_->RemoveObserver(this); | 324 dragged_window_->RemoveObserver(this); |
322 wm::GetWindowState(dragged_window_)->RemoveObserver(this); | 325 wm::GetWindowState(dragged_window_)->RemoveObserver(this); |
323 if (last_active_window_ == dragged_window_) | 326 if (last_active_window_ == dragged_window_) |
324 last_active_window_ = NULL; | 327 last_active_window_ = NULL; |
325 } else { | 328 } else { |
326 // A window is no longer dragged and is a child. | 329 // A window is no longer dragged and is a child. |
327 // When a window becomes a child at drag start this is | 330 // When a window becomes a child at drag start this is |
328 // the only opportunity we will have to enforce a window | 331 // the only opportunity we will have to enforce a window |
329 // count limit so do it here. | 332 // count limit so do it here. |
330 MaybeMinimizeChildrenExcept(dragged_window_); | 333 MaybeMinimizeChildrenExcept(dragged_window_); |
331 } | 334 } |
332 dragged_window_ = NULL; | 335 dragged_window_ = NULL; |
333 dragged_bounds_ = gfx::Rect(); | 336 dragged_bounds_ = gfx::Rect(); |
334 Relayout(); | 337 Relayout(); |
335 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); | 338 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); |
| 339 RecordUmaAction(action, source); |
336 } | 340 } |
337 | 341 |
338 void DockedWindowLayoutManager::SetLauncher(ash::Launcher* launcher) { | 342 void DockedWindowLayoutManager::SetLauncher(ash::Launcher* launcher) { |
339 DCHECK(!launcher_); | 343 DCHECK(!launcher_); |
340 launcher_ = launcher; | 344 launcher_ = launcher; |
341 } | 345 } |
342 | 346 |
343 DockedAlignment DockedWindowLayoutManager::GetAlignmentOfWindow( | 347 DockedAlignment DockedWindowLayoutManager::GetAlignmentOfWindow( |
344 const aura::Window* window) const { | 348 const aura::Window* window) const { |
345 const gfx::Rect& bounds(window->GetBoundsInScreen()); | 349 const gfx::Rect& bounds(window->GetBoundsInScreen()); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 if (IsPopupOrTransient(child)) | 461 if (IsPopupOrTransient(child)) |
458 return; | 462 return; |
459 // Dragged windows are stopped being observed by FinishDragging and do not | 463 // Dragged windows are stopped being observed by FinishDragging and do not |
460 // change alignment during the drag. They also cannot be set to be the | 464 // change alignment during the drag. They also cannot be set to be the |
461 // |last_active_window_|. | 465 // |last_active_window_|. |
462 if (child == dragged_window_) | 466 if (child == dragged_window_) |
463 return; | 467 return; |
464 // If this is the last window, set alignment and maximize the workspace. | 468 // If this is the last window, set alignment and maximize the workspace. |
465 if (!IsAnyWindowDocked()) { | 469 if (!IsAnyWindowDocked()) { |
466 alignment_ = DOCKED_ALIGNMENT_NONE; | 470 alignment_ = DOCKED_ALIGNMENT_NONE; |
467 docked_width_ = 0; | 471 UpdateDockedWidth(0); |
468 } | 472 } |
469 if (last_active_window_ == child) | 473 if (last_active_window_ == child) |
470 last_active_window_ = NULL; | 474 last_active_window_ = NULL; |
471 child->RemoveObserver(this); | 475 child->RemoveObserver(this); |
472 wm::GetWindowState(child)->RemoveObserver(this); | 476 wm::GetWindowState(child)->RemoveObserver(this); |
473 Relayout(); | 477 Relayout(); |
474 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); | 478 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); |
475 } | 479 } |
476 | 480 |
477 void DockedWindowLayoutManager::OnChildWindowVisibilityChanged( | 481 void DockedWindowLayoutManager::OnChildWindowVisibilityChanged( |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 // The window property will still be set, but no actual change will occur | 574 // The window property will still be set, but no actual change will occur |
571 // until OnFullscreenStateChange is called when exiting fullscreen. | 575 // until OnFullscreenStateChange is called when exiting fullscreen. |
572 if (in_fullscreen_) | 576 if (in_fullscreen_) |
573 return; | 577 return; |
574 if (window_state->IsMinimized()) { | 578 if (window_state->IsMinimized()) { |
575 MinimizeDockedWindow(window_state); | 579 MinimizeDockedWindow(window_state); |
576 } else if (window_state->IsMaximizedOrFullscreen()) { | 580 } else if (window_state->IsMaximizedOrFullscreen()) { |
577 // Reparenting changes the source bounds for the animation if a window is | 581 // Reparenting changes the source bounds for the animation if a window is |
578 // visible so hide it here and show later when it is already in the desktop. | 582 // visible so hide it here and show later when it is already in the desktop. |
579 UndockWindow(window); | 583 UndockWindow(window); |
| 584 RecordUmaAction(DOCKED_ACTION_MAXIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN); |
580 } else if (old_type == wm::SHOW_TYPE_MINIMIZED) { | 585 } else if (old_type == wm::SHOW_TYPE_MINIMIZED) { |
581 RestoreDockedWindow(window_state); | 586 RestoreDockedWindow(window_state); |
582 } | 587 } |
583 } | 588 } |
584 | 589 |
585 ///////////////////////////////////////////////////////////////////////////// | 590 ///////////////////////////////////////////////////////////////////////////// |
586 // DockLayoutManager, WindowObserver implementation: | 591 // DockLayoutManager, WindowObserver implementation: |
587 | 592 |
588 void DockedWindowLayoutManager::OnWindowBoundsChanged( | 593 void DockedWindowLayoutManager::OnWindowBoundsChanged( |
589 aura::Window* window, | 594 aura::Window* window, |
(...skipping 12 matching lines...) Expand all Loading... |
602 if (visible) { | 607 if (visible) { |
603 animation_type = views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT; | 608 animation_type = views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT; |
604 views::corewm::SetWindowVisibilityAnimationDuration( | 609 views::corewm::SetWindowVisibilityAnimationDuration( |
605 window, base::TimeDelta::FromMilliseconds(kFadeDurationMs)); | 610 window, base::TimeDelta::FromMilliseconds(kFadeDurationMs)); |
606 } | 611 } |
607 views::corewm::SetWindowVisibilityAnimationType(window, animation_type); | 612 views::corewm::SetWindowVisibilityAnimationType(window, animation_type); |
608 } | 613 } |
609 | 614 |
610 void DockedWindowLayoutManager::OnWindowDestroying(aura::Window* window) { | 615 void DockedWindowLayoutManager::OnWindowDestroying(aura::Window* window) { |
611 if (dragged_window_ == window) { | 616 if (dragged_window_ == window) { |
612 FinishDragging(); | 617 FinishDragging(DOCKED_ACTION_NONE, DOCKED_ACTION_SOURCE_UNKNOWN); |
613 DCHECK(!dragged_window_); | 618 DCHECK(!dragged_window_); |
614 DCHECK (!is_dragged_window_docked_); | 619 DCHECK (!is_dragged_window_docked_); |
615 } | 620 } |
616 if (window == last_active_window_) | 621 if (window == last_active_window_) |
617 last_active_window_ = NULL; | 622 last_active_window_ = NULL; |
| 623 RecordUmaAction(DOCKED_ACTION_CLOSE, DOCKED_ACTION_SOURCE_UNKNOWN); |
618 } | 624 } |
619 | 625 |
620 | 626 |
621 //////////////////////////////////////////////////////////////////////////////// | 627 //////////////////////////////////////////////////////////////////////////////// |
622 // DockLayoutManager, aura::client::ActivationChangeObserver implementation: | 628 // DockLayoutManager, aura::client::ActivationChangeObserver implementation: |
623 | 629 |
624 void DockedWindowLayoutManager::OnWindowActivated(aura::Window* gained_active, | 630 void DockedWindowLayoutManager::OnWindowActivated(aura::Window* gained_active, |
625 aura::Window* lost_active) { | 631 aura::Window* lost_active) { |
626 if (gained_active && IsPopupOrTransient(gained_active)) | 632 if (gained_active && IsPopupOrTransient(gained_active)) |
627 return; | 633 return; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 wm::GetWindowState(window)->Minimize(); | 669 wm::GetWindowState(window)->Minimize(); |
664 } | 670 } |
665 } | 671 } |
666 | 672 |
667 void DockedWindowLayoutManager::MinimizeDockedWindow( | 673 void DockedWindowLayoutManager::MinimizeDockedWindow( |
668 wm::WindowState* window_state) { | 674 wm::WindowState* window_state) { |
669 DCHECK(!IsPopupOrTransient(window_state->window())); | 675 DCHECK(!IsPopupOrTransient(window_state->window())); |
670 window_state->window()->Hide(); | 676 window_state->window()->Hide(); |
671 if (window_state->IsActive()) | 677 if (window_state->IsActive()) |
672 window_state->Deactivate(); | 678 window_state->Deactivate(); |
| 679 RecordUmaAction(DOCKED_ACTION_MINIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN); |
673 } | 680 } |
674 | 681 |
675 void DockedWindowLayoutManager::RestoreDockedWindow( | 682 void DockedWindowLayoutManager::RestoreDockedWindow( |
676 wm::WindowState* window_state) { | 683 wm::WindowState* window_state) { |
677 aura::Window* window = window_state->window(); | 684 aura::Window* window = window_state->window(); |
678 DCHECK(!IsPopupOrTransient(window)); | 685 DCHECK(!IsPopupOrTransient(window)); |
679 // Always place restored window at the top shuffling the other windows down. | 686 // Always place restored window at the top shuffling the other windows down. |
680 // TODO(varkha): add a separate container for docked windows to keep track | 687 // TODO(varkha): add a separate container for docked windows to keep track |
681 // of ordering. | 688 // of ordering. |
682 gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow( | 689 gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow( |
683 dock_container_); | 690 dock_container_); |
684 const gfx::Rect work_area = display.work_area(); | 691 const gfx::Rect work_area = display.work_area(); |
685 | 692 |
686 // Evict the window if it can no longer be docked because of its height. | 693 // Evict the window if it can no longer be docked because of its height. |
687 if (!CanDockWindow(window, SNAP_NONE)) { | 694 if (!CanDockWindow(window, SNAP_NONE)) { |
688 UndockWindow(window); | 695 UndockWindow(window); |
| 696 RecordUmaAction(DOCKED_ACTION_EVICT, DOCKED_ACTION_SOURCE_UNKNOWN); |
689 return; | 697 return; |
690 } | 698 } |
691 gfx::Rect bounds(window->bounds()); | 699 gfx::Rect bounds(window->bounds()); |
692 bounds.set_y(work_area.y() - bounds.height()); | 700 bounds.set_y(work_area.y() - bounds.height()); |
693 window->SetBounds(bounds); | 701 window->SetBounds(bounds); |
694 window->Show(); | 702 window->Show(); |
695 MaybeMinimizeChildrenExcept(window); | 703 MaybeMinimizeChildrenExcept(window); |
| 704 RecordUmaAction(DOCKED_ACTION_RESTORE, DOCKED_ACTION_SOURCE_UNKNOWN); |
| 705 } |
| 706 |
| 707 void DockedWindowLayoutManager::RecordUmaAction(DockedAction action, |
| 708 DockedActionSource source) { |
| 709 if (action == DOCKED_ACTION_NONE) |
| 710 return; |
| 711 UMA_HISTOGRAM_ENUMERATION("Ash.Dock.Action", action, DOCKED_ACTION_COUNT); |
| 712 UMA_HISTOGRAM_ENUMERATION("Ash.Dock.ActionSource", source, |
| 713 DOCKED_ACTION_SOURCE_COUNT); |
| 714 base::Time time_now = base::Time::Now(); |
| 715 base::TimeDelta time_between_use = time_now - last_action_time_; |
| 716 UMA_HISTOGRAM_CUSTOM_COUNTS("Ash.Dock.TimeBetweenUse", |
| 717 time_between_use.InSeconds(), |
| 718 1, |
| 719 base::TimeDelta::FromHours(10).InSeconds(), |
| 720 100); |
| 721 last_action_time_ = time_now; |
| 722 int docked_all_count = 0; |
| 723 int docked_visible_count = 0; |
| 724 int docked_panels_count = 0; |
| 725 int large_windows_count = 0; |
| 726 for (size_t i = 0; i < dock_container_->children().size(); ++i) { |
| 727 const aura::Window* window(dock_container_->children()[i]); |
| 728 if (IsPopupOrTransient(window)) |
| 729 continue; |
| 730 docked_all_count++; |
| 731 if (!IsUsedByLayout(window)) |
| 732 continue; |
| 733 docked_visible_count++; |
| 734 if (window->type() == aura::client::WINDOW_TYPE_PANEL) |
| 735 docked_panels_count++; |
| 736 const wm::WindowState* window_state = wm::GetWindowState(window); |
| 737 if (window_state->HasRestoreBounds()) { |
| 738 const gfx::Rect restore_bounds = window_state->GetRestoreBoundsInScreen(); |
| 739 if (restore_bounds.width() > kMaxDockWidth) |
| 740 large_windows_count++; |
| 741 } |
| 742 } |
| 743 UMA_HISTOGRAM_COUNTS_100("Ash.Dock.ItemsAll", docked_all_count); |
| 744 UMA_HISTOGRAM_COUNTS_100("Ash.Dock.ItemsLarge", large_windows_count); |
| 745 UMA_HISTOGRAM_COUNTS_100("Ash.Dock.ItemsPanels", docked_panels_count); |
| 746 UMA_HISTOGRAM_COUNTS_100("Ash.Dock.ItemsVisible", docked_visible_count); |
| 747 } |
| 748 |
| 749 void DockedWindowLayoutManager::UpdateDockedWidth(int width) { |
| 750 if (docked_width_ == width) |
| 751 return; |
| 752 docked_width_ = width; |
| 753 UMA_HISTOGRAM_COUNTS_10000("Ash.Dock.Width", docked_width_); |
696 } | 754 } |
697 | 755 |
698 void DockedWindowLayoutManager::OnDraggedWindowDocked(aura::Window* window) { | 756 void DockedWindowLayoutManager::OnDraggedWindowDocked(aura::Window* window) { |
699 DCHECK(!is_dragged_window_docked_); | 757 DCHECK(!is_dragged_window_docked_); |
700 is_dragged_window_docked_ = true; | 758 is_dragged_window_docked_ = true; |
701 | 759 |
702 // If there are no other docked windows update alignment. | 760 // If there are no other docked windows update alignment. |
703 if (!IsAnyWindowDocked()) | 761 if (!IsAnyWindowDocked()) |
704 alignment_ = DOCKED_ALIGNMENT_NONE; | 762 alignment_ = DOCKED_ALIGNMENT_NONE; |
705 } | 763 } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 | 900 |
843 // Calculate initial vertical offset and the gap or overlap between windows. | 901 // Calculate initial vertical offset and the gap or overlap between windows. |
844 const int num_windows = visible_windows->size(); | 902 const int num_windows = visible_windows->size(); |
845 const float delta = kMinDockGap + (float)available_room / | 903 const float delta = kMinDockGap + (float)available_room / |
846 ((available_room > 0 || num_windows <= 1) ? | 904 ((available_room > 0 || num_windows <= 1) ? |
847 num_windows + 1 : num_windows - 1); | 905 num_windows + 1 : num_windows - 1); |
848 float y_pos = work_area.y() + ((delta > 0) ? delta : kMinDockGap); | 906 float y_pos = work_area.y() + ((delta > 0) ? delta : kMinDockGap); |
849 | 907 |
850 // Docked area is shown only if there is at least one non-dragged visible | 908 // Docked area is shown only if there is at least one non-dragged visible |
851 // docked window. | 909 // docked window. |
852 docked_width_ = ideal_docked_width; | 910 int new_width = ideal_docked_width; |
853 if (visible_windows->empty() || | 911 if (visible_windows->empty() || |
854 (visible_windows->size() == 1 && | 912 (visible_windows->size() == 1 && |
855 (*visible_windows)[0].window() == dragged_window_)) { | 913 (*visible_windows)[0].window() == dragged_window_)) { |
856 docked_width_ = 0; | 914 new_width = 0; |
857 } | 915 } |
858 | 916 UpdateDockedWidth(new_width); |
859 // Sort windows by their center positions and fan out overlapping | 917 // Sort windows by their center positions and fan out overlapping |
860 // windows. | 918 // windows. |
861 std::sort(visible_windows->begin(), visible_windows->end(), | 919 std::sort(visible_windows->begin(), visible_windows->end(), |
862 CompareWindowPos(is_dragged_from_dock_ ? dragged_window_ : NULL, | 920 CompareWindowPos(is_dragged_from_dock_ ? dragged_window_ : NULL, |
863 delta)); | 921 delta)); |
864 for (std::vector<WindowWithHeight>::iterator iter = visible_windows->begin(); | 922 for (std::vector<WindowWithHeight>::iterator iter = visible_windows->begin(); |
865 iter != visible_windows->end(); ++iter) { | 923 iter != visible_windows->end(); ++iter) { |
866 aura::Window* window = iter->window(); | 924 aura::Window* window = iter->window(); |
867 gfx::Rect bounds = ScreenAsh::ConvertRectToScreen( | 925 gfx::Rect bounds = ScreenAsh::ConvertRectToScreen( |
868 window->parent(), window->GetTargetBounds()); | 926 window->parent(), window->GetTargetBounds()); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( | 1072 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( |
1015 const gfx::Rect& keyboard_bounds) { | 1073 const gfx::Rect& keyboard_bounds) { |
1016 // This bounds change will have caused a change to the Shelf which does not | 1074 // This bounds change will have caused a change to the Shelf which does not |
1017 // propagate automatically to this class, so manually recalculate bounds. | 1075 // propagate automatically to this class, so manually recalculate bounds. |
1018 Relayout(); | 1076 Relayout(); |
1019 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); | 1077 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); |
1020 } | 1078 } |
1021 | 1079 |
1022 } // namespace internal | 1080 } // namespace internal |
1023 } // namespace ash | 1081 } // namespace ash |
OLD | NEW |