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

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: comment 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
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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 WorkspaceController* workspace_controller) 423 WorkspaceController* workspace_controller)
419 : SnapToPixelLayoutManager(dock_container), 424 : SnapToPixelLayoutManager(dock_container),
420 dock_container_(dock_container), 425 dock_container_(dock_container),
421 in_layout_(false), 426 in_layout_(false),
422 dragged_window_(nullptr), 427 dragged_window_(nullptr),
423 is_dragged_window_docked_(false), 428 is_dragged_window_docked_(false),
424 is_dragged_from_dock_(false), 429 is_dragged_from_dock_(false),
425 shelf_(nullptr), 430 shelf_(nullptr),
426 workspace_controller_(workspace_controller), 431 workspace_controller_(workspace_controller),
427 in_fullscreen_(workspace_controller_->GetWindowState() == 432 in_fullscreen_(workspace_controller_->GetWindowState() ==
428 WORKSPACE_WINDOW_STATE_FULL_SCREEN), 433 wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN),
429 docked_width_(0), 434 docked_width_(0),
430 alignment_(DOCKED_ALIGNMENT_NONE), 435 alignment_(DOCKED_ALIGNMENT_NONE),
431 preferred_alignment_(DOCKED_ALIGNMENT_NONE), 436 preferred_alignment_(DOCKED_ALIGNMENT_NONE),
432 event_source_(DOCKED_ACTION_SOURCE_UNKNOWN), 437 event_source_(DOCKED_ACTION_SOURCE_UNKNOWN),
433 last_active_window_(nullptr), 438 last_active_window_(nullptr),
434 last_action_time_(base::Time::Now()), 439 last_action_time_(base::Time::Now()),
435 background_widget_(nullptr) { 440 background_widget_(nullptr) {
436 DCHECK(dock_container); 441 DCHECK(dock_container);
437 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> 442 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())->
438 AddObserver(this); 443 AddObserver(this);
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_INSETS_CHANGED); 783 UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_INSETS_CHANGED);
779 MaybeMinimizeChildrenExcept(dragged_window_); 784 MaybeMinimizeChildrenExcept(dragged_window_);
780 } 785 }
781 786
782 void DockedWindowLayoutManager::OnFullscreenStateChanged( 787 void DockedWindowLayoutManager::OnFullscreenStateChanged(
783 bool is_fullscreen, aura::Window* root_window) { 788 bool is_fullscreen, aura::Window* root_window) {
784 if (dock_container_->GetRootWindow() != root_window) 789 if (dock_container_->GetRootWindow() != root_window)
785 return; 790 return;
786 // Entering fullscreen mode (including immersive) hides docked windows. 791 // Entering fullscreen mode (including immersive) hides docked windows.
787 in_fullscreen_ = workspace_controller_->GetWindowState() == 792 in_fullscreen_ = workspace_controller_->GetWindowState() ==
788 WORKSPACE_WINDOW_STATE_FULL_SCREEN; 793 wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN;
789 { 794 {
790 // prevent Relayout from getting called multiple times during this 795 // prevent Relayout from getting called multiple times during this
791 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); 796 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true);
792 // Use a copy of children array because a call to MinimizeDockedWindow or 797 // Use a copy of children array because a call to MinimizeDockedWindow or
793 // RestoreDockedWindow can change order. 798 // RestoreDockedWindow can change order.
794 aura::Window::Windows children(dock_container_->children()); 799 aura::Window::Windows children(dock_container_->children());
795 for (aura::Window::Windows::const_iterator iter = children.begin(); 800 for (aura::Window::Windows::const_iterator iter = children.begin();
796 iter != children.end(); ++iter) { 801 iter != children.end(); ++iter) {
797 aura::Window* window(*iter); 802 aura::Window* window(*iter);
798 if (IsPopupOrTransient(window)) 803 if (IsPopupOrTransient(window))
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 void DockedWindowLayoutManager::OnWindowVisibilityChanging( 883 void DockedWindowLayoutManager::OnWindowVisibilityChanging(
879 aura::Window* window, bool visible) { 884 aura::Window* window, bool visible) {
880 if (IsPopupOrTransient(window)) 885 if (IsPopupOrTransient(window))
881 return; 886 return;
882 int animation_type = ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT; 887 int animation_type = ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT;
883 if (visible) { 888 if (visible) {
884 animation_type = ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_DROP; 889 animation_type = ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_DROP;
885 ::wm::SetWindowVisibilityAnimationDuration( 890 ::wm::SetWindowVisibilityAnimationDuration(
886 window, base::TimeDelta::FromMilliseconds(kFadeDurationMs)); 891 window, base::TimeDelta::FromMilliseconds(kFadeDurationMs));
887 } else if (wm::GetWindowState(window)->IsMinimized()) { 892 } else if (wm::GetWindowState(window)->IsMinimized()) {
888 animation_type = WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE; 893 animation_type = wm::WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE;
889 } 894 }
890 ::wm::SetWindowVisibilityAnimationType(window, animation_type); 895 ::wm::SetWindowVisibilityAnimationType(window, animation_type);
891 } 896 }
892 897
893 void DockedWindowLayoutManager::OnWindowDestroying(aura::Window* window) { 898 void DockedWindowLayoutManager::OnWindowDestroying(aura::Window* window) {
894 if (dragged_window_ == window) { 899 if (dragged_window_ == window) {
895 FinishDragging(DOCKED_ACTION_NONE, DOCKED_ACTION_SOURCE_UNKNOWN); 900 FinishDragging(DOCKED_ACTION_NONE, DOCKED_ACTION_SOURCE_UNKNOWN);
896 DCHECK(!dragged_window_); 901 DCHECK(!dragged_window_);
897 DCHECK(!is_dragged_window_docked_); 902 DCHECK(!is_dragged_window_docked_);
898 } 903 }
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 1370
1366 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( 1371 void DockedWindowLayoutManager::OnKeyboardBoundsChanging(
1367 const gfx::Rect& keyboard_bounds) { 1372 const gfx::Rect& keyboard_bounds) {
1368 // This bounds change will have caused a change to the Shelf which does not 1373 // This bounds change will have caused a change to the Shelf which does not
1369 // propagate automatically to this class, so manually recalculate bounds. 1374 // propagate automatically to this class, so manually recalculate bounds.
1370 Relayout(); 1375 Relayout();
1371 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); 1376 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING);
1372 } 1377 }
1373 1378
1374 } // namespace ash 1379 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698