Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: ash/wm/dock/docked_window_layout_manager.cc

Issue 1901773002: Removes most of aura dependencies from DefaultState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wm_window_positioner
Patch Set: nit and merge Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/wm/default_state.cc ('k') | ash/wm/dock/docked_window_resizer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/screen_util.h" 7 #include "ash/screen_util.h"
8 #include "ash/shelf/shelf.h" 8 #include "ash/shelf/shelf.h"
9 #include "ash/shelf/shelf_constants.h" 9 #include "ash/shelf/shelf_constants.h"
10 #include "ash/shelf/shelf_layout_manager.h" 10 #include "ash/shelf/shelf_layout_manager.h"
11 #include "ash/shelf/shelf_layout_manager_observer.h" 11 #include "ash/shelf/shelf_layout_manager_observer.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/common/window_animation_types.h"
17 #include "ash/wm/common/window_parenting_utils.h"
16 #include "ash/wm/coordinate_conversion.h" 18 #include "ash/wm/coordinate_conversion.h"
17 #include "ash/wm/window_animations.h" 19 #include "ash/wm/window_animations.h"
18 #include "ash/wm/window_properties.h" 20 #include "ash/wm/window_properties.h"
19 #include "ash/wm/window_resizer.h" 21 #include "ash/wm/window_resizer.h"
20 #include "ash/wm/window_state.h" 22 #include "ash/wm/window_state.h"
21 #include "ash/wm/window_state_aura.h" 23 #include "ash/wm/window_state_aura.h"
22 #include "ash/wm/window_util.h" 24 #include "ash/wm/window_util.h"
23 #include "ash/wm/workspace_controller.h" 25 #include "ash/wm/workspace_controller.h"
24 #include "base/auto_reset.h" 26 #include "base/auto_reset.h"
25 #include "base/command_line.h" 27 #include "base/command_line.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 bool IsWindowDocked(const aura::Window* window) { 239 bool IsWindowDocked(const aura::Window* window) {
238 return (window->IsVisible() && 240 return (window->IsVisible() &&
239 !wm::GetWindowState(window)->IsMinimized() && 241 !wm::GetWindowState(window)->IsMinimized() &&
240 !IsPopupOrTransient(window)); 242 !IsPopupOrTransient(window));
241 } 243 }
242 244
243 void UndockWindow(aura::Window* window) { 245 void UndockWindow(aura::Window* window) {
244 gfx::Rect previous_bounds = window->bounds(); 246 gfx::Rect previous_bounds = window->bounds();
245 aura::Window* old_parent = window->parent(); 247 aura::Window* old_parent = window->parent();
246 aura::client::ParentWindowWithContext(window, window, gfx::Rect()); 248 aura::client::ParentWindowWithContext(window, window, gfx::Rect());
247 if (window->parent() != old_parent) 249 if (window->parent() != old_parent) {
248 wm::ReparentTransientChildrenOfChild(window, old_parent, window->parent()); 250 wm::ReparentTransientChildrenOfChild(
251 wm::WmWindowAura::Get(window), wm::WmWindowAura::Get(old_parent),
252 wm::WmWindowAura::Get(window->parent()));
253 }
249 // Start maximize or fullscreen (affecting packaged apps) animation from 254 // Start maximize or fullscreen (affecting packaged apps) animation from
250 // previous window bounds. 255 // previous window bounds.
251 window->layer()->SetBounds(previous_bounds); 256 window->layer()->SetBounds(previous_bounds);
252 } 257 }
253 258
254 // Returns width that is as close as possible to |target_width| while being 259 // Returns width that is as close as possible to |target_width| while being
255 // consistent with docked min and max restrictions and respects the |window|'s 260 // consistent with docked min and max restrictions and respects the |window|'s
256 // minimum and maximum size. 261 // minimum and maximum size.
257 int GetWindowWidthCloseTo(const aura::Window* window, int target_width) { 262 int GetWindowWidthCloseTo(const aura::Window* window, int target_width) {
258 if (!wm::GetWindowState(window)->CanResize()) { 263 if (!wm::GetWindowState(window)->CanResize()) {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 WorkspaceController* workspace_controller) 430 WorkspaceController* workspace_controller)
426 : SnapToPixelLayoutManager(dock_container), 431 : SnapToPixelLayoutManager(dock_container),
427 dock_container_(dock_container), 432 dock_container_(dock_container),
428 in_layout_(false), 433 in_layout_(false),
429 dragged_window_(nullptr), 434 dragged_window_(nullptr),
430 is_dragged_window_docked_(false), 435 is_dragged_window_docked_(false),
431 is_dragged_from_dock_(false), 436 is_dragged_from_dock_(false),
432 shelf_(nullptr), 437 shelf_(nullptr),
433 workspace_controller_(workspace_controller), 438 workspace_controller_(workspace_controller),
434 in_fullscreen_(workspace_controller_->GetWindowState() == 439 in_fullscreen_(workspace_controller_->GetWindowState() ==
435 WORKSPACE_WINDOW_STATE_FULL_SCREEN), 440 wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN),
436 docked_width_(0), 441 docked_width_(0),
437 alignment_(DOCKED_ALIGNMENT_NONE), 442 alignment_(DOCKED_ALIGNMENT_NONE),
438 preferred_alignment_(DOCKED_ALIGNMENT_NONE), 443 preferred_alignment_(DOCKED_ALIGNMENT_NONE),
439 event_source_(DOCKED_ACTION_SOURCE_UNKNOWN), 444 event_source_(DOCKED_ACTION_SOURCE_UNKNOWN),
440 last_active_window_(nullptr), 445 last_active_window_(nullptr),
441 last_action_time_(base::Time::Now()), 446 last_action_time_(base::Time::Now()),
442 background_widget_(nullptr) { 447 background_widget_(nullptr) {
443 DCHECK(dock_container); 448 DCHECK(dock_container);
444 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> 449 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())->
445 AddObserver(this); 450 AddObserver(this);
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_INSETS_CHANGED); 790 UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_INSETS_CHANGED);
786 MaybeMinimizeChildrenExcept(dragged_window_); 791 MaybeMinimizeChildrenExcept(dragged_window_);
787 } 792 }
788 793
789 void DockedWindowLayoutManager::OnFullscreenStateChanged( 794 void DockedWindowLayoutManager::OnFullscreenStateChanged(
790 bool is_fullscreen, aura::Window* root_window) { 795 bool is_fullscreen, aura::Window* root_window) {
791 if (dock_container_->GetRootWindow() != root_window) 796 if (dock_container_->GetRootWindow() != root_window)
792 return; 797 return;
793 // Entering fullscreen mode (including immersive) hides docked windows. 798 // Entering fullscreen mode (including immersive) hides docked windows.
794 in_fullscreen_ = workspace_controller_->GetWindowState() == 799 in_fullscreen_ = workspace_controller_->GetWindowState() ==
795 WORKSPACE_WINDOW_STATE_FULL_SCREEN; 800 wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN;
796 { 801 {
797 // prevent Relayout from getting called multiple times during this 802 // prevent Relayout from getting called multiple times during this
798 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); 803 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true);
799 // Use a copy of children array because a call to MinimizeDockedWindow or 804 // Use a copy of children array because a call to MinimizeDockedWindow or
800 // RestoreDockedWindow can change order. 805 // RestoreDockedWindow can change order.
801 aura::Window::Windows children(dock_container_->children()); 806 aura::Window::Windows children(dock_container_->children());
802 for (aura::Window::Windows::const_iterator iter = children.begin(); 807 for (aura::Window::Windows::const_iterator iter = children.begin();
803 iter != children.end(); ++iter) { 808 iter != children.end(); ++iter) {
804 aura::Window* window(*iter); 809 aura::Window* window(*iter);
805 if (IsPopupOrTransient(window)) 810 if (IsPopupOrTransient(window))
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 void DockedWindowLayoutManager::OnWindowVisibilityChanging( 890 void DockedWindowLayoutManager::OnWindowVisibilityChanging(
886 aura::Window* window, bool visible) { 891 aura::Window* window, bool visible) {
887 if (IsPopupOrTransient(window)) 892 if (IsPopupOrTransient(window))
888 return; 893 return;
889 int animation_type = ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT; 894 int animation_type = ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT;
890 if (visible) { 895 if (visible) {
891 animation_type = ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_DROP; 896 animation_type = ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_DROP;
892 ::wm::SetWindowVisibilityAnimationDuration( 897 ::wm::SetWindowVisibilityAnimationDuration(
893 window, base::TimeDelta::FromMilliseconds(kFadeDurationMs)); 898 window, base::TimeDelta::FromMilliseconds(kFadeDurationMs));
894 } else if (wm::GetWindowState(window)->IsMinimized()) { 899 } else if (wm::GetWindowState(window)->IsMinimized()) {
895 animation_type = WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE; 900 animation_type = wm::WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE;
896 } 901 }
897 ::wm::SetWindowVisibilityAnimationType(window, animation_type); 902 ::wm::SetWindowVisibilityAnimationType(window, animation_type);
898 } 903 }
899 904
900 void DockedWindowLayoutManager::OnWindowDestroying(aura::Window* window) { 905 void DockedWindowLayoutManager::OnWindowDestroying(aura::Window* window) {
901 if (dragged_window_ == window) { 906 if (dragged_window_ == window) {
902 FinishDragging(DOCKED_ACTION_NONE, DOCKED_ACTION_SOURCE_UNKNOWN); 907 FinishDragging(DOCKED_ACTION_NONE, DOCKED_ACTION_SOURCE_UNKNOWN);
903 DCHECK(!dragged_window_); 908 DCHECK(!dragged_window_);
904 DCHECK(!is_dragged_window_docked_); 909 DCHECK(!is_dragged_window_docked_);
905 } 910 }
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 1377
1373 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( 1378 void DockedWindowLayoutManager::OnKeyboardBoundsChanging(
1374 const gfx::Rect& keyboard_bounds) { 1379 const gfx::Rect& keyboard_bounds) {
1375 // This bounds change will have caused a change to the Shelf which does not 1380 // This bounds change will have caused a change to the Shelf which does not
1376 // propagate automatically to this class, so manually recalculate bounds. 1381 // propagate automatically to this class, so manually recalculate bounds.
1377 Relayout(); 1382 Relayout();
1378 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); 1383 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING);
1379 } 1384 }
1380 1385
1381 } // namespace ash 1386 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/default_state.cc ('k') | ash/wm/dock/docked_window_resizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698