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

Side by Side Diff: ash/common/wm/maximize_mode/maximize_mode_window_manager.cc

Issue 2250963006: Register the window in MaximizeModeWindowManager when the window is shown. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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/common/wm/maximize_mode/maximize_mode_window_manager.h ('k') | no next file » | 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/common/wm/maximize_mode/maximize_mode_window_manager.h" 5 #include "ash/common/wm/maximize_mode/maximize_mode_window_manager.h"
6 6
7 #include "ash/common/ash_switches.h" 7 #include "ash/common/ash_switches.h"
8 #include "ash/common/session/session_state_delegate.h" 8 #include "ash/common/session/session_state_delegate.h"
9 #include "ash/common/shell_window_ids.h" 9 #include "ash/common/shell_window_ids.h"
10 #include "ash/common/wm/maximize_mode/maximize_mode_event_handler.h" 10 #include "ash/common/wm/maximize_mode/maximize_mode_event_handler.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 backdrops_hidden_ = false; 92 backdrops_hidden_ = false;
93 EnableBackdropBehindTopWindowOnEachDisplay(true); 93 EnableBackdropBehindTopWindowOnEachDisplay(true);
94 SetDeferBoundsUpdates(false); 94 SetDeferBoundsUpdates(false);
95 } 95 }
96 96
97 void MaximizeModeWindowManager::OnWindowDestroying(WmWindow* window) { 97 void MaximizeModeWindowManager::OnWindowDestroying(WmWindow* window) {
98 if (IsContainerWindow(window)) { 98 if (IsContainerWindow(window)) {
99 // container window can be removed on display destruction. 99 // container window can be removed on display destruction.
100 window->RemoveObserver(this); 100 window->RemoveObserver(this);
101 observed_container_windows_.erase(window); 101 observed_container_windows_.erase(window);
102 } else if (base::ContainsValue(added_windows_, window)) {
103 // Added window was destroyed before being shown.
104 added_windows_.erase(window);
105 window->RemoveObserver(this);
102 } else { 106 } else {
103 // If a known window gets destroyed we need to remove all knowledge about 107 // If a known window gets destroyed we need to remove all knowledge about
104 // it. 108 // it.
105 ForgetWindow(window); 109 ForgetWindow(window);
106 } 110 }
107 } 111 }
108 112
109 void MaximizeModeWindowManager::OnWindowTreeChanged( 113 void MaximizeModeWindowManager::OnWindowTreeChanged(
110 WmWindow* window, 114 WmWindow* window,
111 const TreeChangeParams& params) { 115 const TreeChangeParams& params) {
112 // A window can get removed and then re-added by a drag and drop operation. 116 // A window can get removed and then re-added by a drag and drop operation.
113 if (params.new_parent && IsContainerWindow(params.new_parent) && 117 if (params.new_parent && IsContainerWindow(params.new_parent) &&
114 !base::ContainsKey(window_state_map_, params.target)) { 118 !base::ContainsKey(window_state_map_, params.target)) {
119 // Wait until the window become visible because the client
120 // may update the flag to control if the window should be added.
121 if (!params.target->IsVisible()) {
Mr4D (OOO till 08-26) 2016/08/18 01:45:45 This is confusing. You mention "wait until the win
oshima 2016/08/18 04:26:09 Updated to: // Don't register the window if t
122 if (!base::ContainsValue(added_windows_, params.target)) {
123 added_windows_.insert(params.target);
124 params.target->AddObserver(this);
125 }
126 return;
127 }
115 MaximizeAndTrackWindow(params.target); 128 MaximizeAndTrackWindow(params.target);
116 // When the state got added, the "WM_EVENT_ADDED_TO_WORKSPACE" event got 129 // When the state got added, the "WM_EVENT_ADDED_TO_WORKSPACE" event got
117 // already sent and we have to notify our state again. 130 // already sent and we have to notify our state again.
118 if (base::ContainsKey(window_state_map_, params.target)) { 131 if (base::ContainsKey(window_state_map_, params.target)) {
119 wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE); 132 wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE);
120 params.target->GetWindowState()->OnWMEvent(&event); 133 params.target->GetWindowState()->OnWMEvent(&event);
121 } 134 }
122 } 135 }
123 } 136 }
124 137
125 void MaximizeModeWindowManager::OnWindowPropertyChanged( 138 void MaximizeModeWindowManager::OnWindowPropertyChanged(
126 WmWindow* window, 139 WmWindow* window,
127 WmWindowProperty property) { 140 WmWindowProperty property) {
128 // Stop managing |window| if the always-on-top property is added. 141 // Stop managing |window| if the always-on-top property is added.
129 if (property == WmWindowProperty::ALWAYS_ON_TOP && window->IsAlwaysOnTop()) 142 if (property == WmWindowProperty::ALWAYS_ON_TOP && window->IsAlwaysOnTop())
130 ForgetWindow(window); 143 ForgetWindow(window);
131 } 144 }
132 145
133 void MaximizeModeWindowManager::OnWindowBoundsChanged( 146 void MaximizeModeWindowManager::OnWindowBoundsChanged(
134 WmWindow* window, 147 WmWindow* window,
135 const gfx::Rect& old_bounds, 148 const gfx::Rect& old_bounds,
136 const gfx::Rect& new_bounds) { 149 const gfx::Rect& new_bounds) {
137 if (!IsContainerWindow(window)) 150 if (!IsContainerWindow(window))
138 return; 151 return;
139 // Reposition all non maximizeable windows. 152 // Reposition all non maximizeable windows.
140 for (auto& pair : window_state_map_) 153 for (auto& pair : window_state_map_)
141 pair.second->UpdateWindowPosition(pair.first->GetWindowState()); 154 pair.second->UpdateWindowPosition(pair.first->GetWindowState());
142 } 155 }
143 156
157 void MaximizeModeWindowManager::OnWindowVisibilityChanged(WmWindow* window,
158 bool visible) {
159 // Skip if it's already managed.
160 if (base::ContainsKey(window_state_map_, window))
161 return;
162
163 if (IsContainerWindow(window->GetParent()) &&
164 base::ContainsValue(added_windows_, window) && visible) {
165 added_windows_.erase(window);
166 window->RemoveObserver(this);
167 MaximizeAndTrackWindow(window);
168 // When the state got added, the "WM_EVENT_ADDED_TO_WORKSPACE" event got
169 // already sent and we have to notify our state again.
170 if (base::ContainsKey(window_state_map_, window)) {
171 wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE);
172 window->GetWindowState()->OnWMEvent(&event);
173 }
Mr4D (OOO till 08-26) 2016/08/18 01:45:45 Could you put line 167-173 into a function and cal
oshima 2016/08/18 04:26:09 I believe we can move the added to workspace to Ma
174 }
175 }
176
144 void MaximizeModeWindowManager::OnDisplayAdded( 177 void MaximizeModeWindowManager::OnDisplayAdded(
145 const display::Display& display) { 178 const display::Display& display) {
146 DisplayConfigurationChanged(); 179 DisplayConfigurationChanged();
147 } 180 }
148 181
149 void MaximizeModeWindowManager::OnDisplayRemoved( 182 void MaximizeModeWindowManager::OnDisplayRemoved(
150 const display::Display& display) { 183 const display::Display& display) {
151 DisplayConfigurationChanged(); 184 DisplayConfigurationChanged();
152 } 185 }
153 186
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 for (WmWindow* root : WmShell::Get()->GetAllRootWindows()) { 315 for (WmWindow* root : WmShell::Get()->GetAllRootWindows()) {
283 WmRootWindowController* controller = root->GetRootWindowController(); 316 WmRootWindowController* controller = root->GetRootWindowController();
284 WmWindow* default_container = 317 WmWindow* default_container =
285 root->GetChildByShellWindowId(kShellWindowId_DefaultContainer); 318 root->GetChildByShellWindowId(kShellWindowId_DefaultContainer);
286 controller->SetMaximizeBackdropDelegate(base::WrapUnique( 319 controller->SetMaximizeBackdropDelegate(base::WrapUnique(
287 enable ? new WorkspaceBackdropDelegate(default_container) : nullptr)); 320 enable ? new WorkspaceBackdropDelegate(default_container) : nullptr));
288 } 321 }
289 } 322 }
290 323
291 } // namespace ash 324 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/maximize_mode/maximize_mode_window_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698