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

Side by Side Diff: ash/wm/default_state.cc

Issue 1907863002: Converts DockedWindowLayoutManager to common ash/wm types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
« no previous file with comments | « ash/wm/common/wm_window_observer.h ('k') | ash/wm/dock/docked_window_layout_manager.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/default_state.h" 5 #include "ash/wm/default_state.h"
6 6
7 #include "ash/shell_window_ids.h" 7 #include "ash/shell_window_ids.h"
8 #include "ash/wm/aura/wm_window_aura.h" 8 #include "ash/wm/aura/wm_window_aura.h"
9 #include "ash/wm/common/window_animation_types.h" 9 #include "ash/wm/common/window_animation_types.h"
10 #include "ash/wm/common/window_parenting_utils.h" 10 #include "ash/wm/common/window_parenting_utils.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 WmWindow* new_root = globals->GetRootWindowForDisplayId(display.id()); 61 WmWindow* new_root = globals->GetRootWindowForDisplayId(display.id());
62 if (new_root != window_state->window()->GetRootWindow()) { 62 if (new_root != window_state->window()->GetRootWindow()) {
63 WmWindow* new_container = new_root->GetChildByShellWindowId( 63 WmWindow* new_container = new_root->GetChildByShellWindowId(
64 window_state->window()->GetParent()->GetShellWindowId()); 64 window_state->window()->GetParent()->GetShellWindowId());
65 new_container->AddChild(window_state->window()); 65 new_container->AddChild(window_state->window());
66 } 66 }
67 } 67 }
68 } 68 }
69 69
70 DockedWindowLayoutManager* GetDockedWindowLayoutManager(WmGlobals* globals) { 70 DockedWindowLayoutManager* GetDockedWindowLayoutManager(WmGlobals* globals) {
71 WmWindow* active_window = globals->GetActiveWindow(); 71 return DockedWindowLayoutManager::Get(globals->GetActiveWindow());
72 if (!active_window)
73 return nullptr;
74
75 WmWindow* dock_container =
76 active_window->GetRootWindow()->GetChildByShellWindowId(
77 kShellWindowId_DockedContainer);
78 DockedWindowLayoutManager* dock_layout =
79 static_cast<DockedWindowLayoutManager*>(
80 WmWindowAura::GetAuraWindow(dock_container)->layout_manager());
81 return dock_layout;
82 } 72 }
83 73
84 class ScopedPreferredAlignmentResetter { 74 class ScopedPreferredAlignmentResetter {
85 public: 75 public:
86 ScopedPreferredAlignmentResetter(DockedAlignment dock_alignment, 76 ScopedPreferredAlignmentResetter(DockedAlignment dock_alignment,
87 DockedWindowLayoutManager* dock_layout) 77 DockedWindowLayoutManager* dock_layout)
88 : docked_window_layout_manager_(dock_layout) { 78 : docked_window_layout_manager_(dock_layout) {
89 docked_window_layout_manager_->set_preferred_alignment(dock_alignment); 79 docked_window_layout_manager_->set_preferred_alignment(dock_alignment);
90 } 80 }
91 ~ScopedPreferredAlignmentResetter() { 81 ~ScopedPreferredAlignmentResetter() {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 window_state->GetStateType() != desired_snap_state && 126 window_state->GetStateType() != desired_snap_state &&
137 window_state->window()->GetType() != ui::wm::WINDOW_TYPE_PANEL) { 127 window_state->window()->GetType() != ui::wm::WINDOW_TYPE_PANEL) {
138 const wm::WMEvent event(desired_snap_state == 128 const wm::WMEvent event(desired_snap_state ==
139 wm::WINDOW_STATE_TYPE_LEFT_SNAPPED ? 129 wm::WINDOW_STATE_TYPE_LEFT_SNAPPED ?
140 wm::WM_EVENT_SNAP_LEFT : wm::WM_EVENT_SNAP_RIGHT); 130 wm::WM_EVENT_SNAP_LEFT : wm::WM_EVENT_SNAP_RIGHT);
141 window_state->OnWMEvent(&event); 131 window_state->OnWMEvent(&event);
142 return; 132 return;
143 } 133 }
144 134
145 if (dock_layout && 135 if (dock_layout &&
146 dock_layout->CanDockWindow(window_state->aura_window(), 136 dock_layout->CanDockWindow(window_state->window(),
147 desired_dock_alignment)) { 137 desired_dock_alignment)) {
148 if (window_state->IsDocked()) { 138 if (window_state->IsDocked()) {
149 dock_layout->MaybeSetDesiredDockedAlignment(desired_dock_alignment); 139 dock_layout->MaybeSetDesiredDockedAlignment(desired_dock_alignment);
150 return; 140 return;
151 } 141 }
152 142
153 ScopedDockedLayoutEventSourceResetter event_source_resetter(dock_layout); 143 ScopedDockedLayoutEventSourceResetter event_source_resetter(dock_layout);
154 ScopedPreferredAlignmentResetter alignmentResetter(desired_dock_alignment, 144 ScopedPreferredAlignmentResetter alignmentResetter(desired_dock_alignment,
155 dock_layout); 145 dock_layout);
156 const wm::WMEvent event(wm::WM_EVENT_DOCK); 146 const wm::WMEvent event(wm::WM_EVENT_DOCK);
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 gfx::Rect center_in_parent = GetDisplayWorkAreaBoundsInParent(window); 728 gfx::Rect center_in_parent = GetDisplayWorkAreaBoundsInParent(window);
739 center_in_parent.ClampToCenteredSize(window->GetBounds().size()); 729 center_in_parent.ClampToCenteredSize(window->GetBounds().size());
740 window_state->SetBoundsDirectAnimated(center_in_parent); 730 window_state->SetBoundsDirectAnimated(center_in_parent);
741 } 731 }
742 // Centering window is treated as if a user moved and resized the window. 732 // Centering window is treated as if a user moved and resized the window.
743 window_state->set_bounds_changed_by_user(true); 733 window_state->set_bounds_changed_by_user(true);
744 } 734 }
745 735
746 } // namespace wm 736 } // namespace wm
747 } // namespace ash 737 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/common/wm_window_observer.h ('k') | ash/wm/dock/docked_window_layout_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698