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

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

Issue 2260083002: Register the window in MaximizeModeWindowManager when the window is shown. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
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 24 matching lines...) Expand all
35 controller->OnSelectionEnded(); 35 controller->OnSelectionEnded();
36 } 36 }
37 37
38 } // namespace 38 } // namespace
39 39
40 MaximizeModeWindowManager::~MaximizeModeWindowManager() { 40 MaximizeModeWindowManager::~MaximizeModeWindowManager() {
41 // Overview mode needs to be ended before exiting maximize mode to prevent 41 // Overview mode needs to be ended before exiting maximize mode to prevent
42 // transforming windows which are currently in 42 // transforming windows which are currently in
43 // overview: http://crbug.com/366605 43 // overview: http://crbug.com/366605
44 CancelOverview(); 44 CancelOverview();
45 45 for (auto* window : added_windows_)
46 window->RemoveObserver(this);
47 added_windows_.clear();
46 WmShell::Get()->RemoveShellObserver(this); 48 WmShell::Get()->RemoveShellObserver(this);
47 display::Screen::GetScreen()->RemoveObserver(this); 49 display::Screen::GetScreen()->RemoveObserver(this);
48 EnableBackdropBehindTopWindowOnEachDisplay(false); 50 EnableBackdropBehindTopWindowOnEachDisplay(false);
49 RemoveWindowCreationObservers(); 51 RemoveWindowCreationObservers();
50 RestoreAllWindows(); 52 RestoreAllWindows();
51 } 53 }
52 54
53 int MaximizeModeWindowManager::GetNumberOfManagedWindows() { 55 int MaximizeModeWindowManager::GetNumberOfManagedWindows() {
54 return window_state_map_.size(); 56 return window_state_map_.size();
55 } 57 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 backdrops_hidden_ = false; 93 backdrops_hidden_ = false;
92 EnableBackdropBehindTopWindowOnEachDisplay(true); 94 EnableBackdropBehindTopWindowOnEachDisplay(true);
93 SetDeferBoundsUpdates(false); 95 SetDeferBoundsUpdates(false);
94 } 96 }
95 97
96 void MaximizeModeWindowManager::OnWindowDestroying(WmWindow* window) { 98 void MaximizeModeWindowManager::OnWindowDestroying(WmWindow* window) {
97 if (IsContainerWindow(window)) { 99 if (IsContainerWindow(window)) {
98 // container window can be removed on display destruction. 100 // container window can be removed on display destruction.
99 window->RemoveObserver(this); 101 window->RemoveObserver(this);
100 observed_container_windows_.erase(window); 102 observed_container_windows_.erase(window);
103 } else if (ContainsValue(added_windows_, window)) {
104 // Added window was destroyed before being shown.
105 added_windows_.erase(window);
106 window->RemoveObserver(this);
101 } else { 107 } else {
102 // If a known window gets destroyed we need to remove all knowledge about 108 // If a known window gets destroyed we need to remove all knowledge about
103 // it. 109 // it.
104 ForgetWindow(window); 110 ForgetWindow(window);
105 } 111 }
106 } 112 }
107 113
108 void MaximizeModeWindowManager::OnWindowTreeChanged( 114 void MaximizeModeWindowManager::OnWindowTreeChanged(
109 WmWindow* window, 115 WmWindow* window,
110 const TreeChangeParams& params) { 116 const TreeChangeParams& params) {
111 // A window can get removed and then re-added by a drag and drop operation. 117 // A window can get removed and then re-added by a drag and drop operation.
112 if (params.new_parent && IsContainerWindow(params.new_parent) && 118 if (params.new_parent && IsContainerWindow(params.new_parent) &&
113 !ContainsKey(window_state_map_, params.target)) { 119 !ContainsKey(window_state_map_, params.target)) {
120 // Don't register the window if the window is invisible. Instead,
121 // wait until it becomes visible because the client may update the
122 // flag to control if the window should be added.
123 if (!params.target->IsVisible()) {
124 if (!ContainsValue(added_windows_, params.target)) {
125 added_windows_.insert(params.target);
126 params.target->AddObserver(this);
127 }
128 return;
129 }
114 MaximizeAndTrackWindow(params.target); 130 MaximizeAndTrackWindow(params.target);
115 // When the state got added, the "WM_EVENT_ADDED_TO_WORKSPACE" event got 131 // When the state got added, the "WM_EVENT_ADDED_TO_WORKSPACE" event got
116 // already sent and we have to notify our state again. 132 // already sent and we have to notify our state again.
117 if (ContainsKey(window_state_map_, params.target)) { 133 if (ContainsKey(window_state_map_, params.target)) {
118 wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE); 134 wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE);
119 params.target->GetWindowState()->OnWMEvent(&event); 135 params.target->GetWindowState()->OnWMEvent(&event);
120 } 136 }
121 } 137 }
122 } 138 }
123 139
124 void MaximizeModeWindowManager::OnWindowPropertyChanged( 140 void MaximizeModeWindowManager::OnWindowPropertyChanged(
125 WmWindow* window, 141 WmWindow* window,
126 WmWindowProperty property) { 142 WmWindowProperty property) {
127 // Stop managing |window| if the always-on-top property is added. 143 // Stop managing |window| if the always-on-top property is added.
128 if (property == WmWindowProperty::ALWAYS_ON_TOP && window->IsAlwaysOnTop()) 144 if (property == WmWindowProperty::ALWAYS_ON_TOP && window->IsAlwaysOnTop())
129 ForgetWindow(window); 145 ForgetWindow(window);
130 } 146 }
131 147
132 void MaximizeModeWindowManager::OnWindowBoundsChanged( 148 void MaximizeModeWindowManager::OnWindowBoundsChanged(
133 WmWindow* window, 149 WmWindow* window,
134 const gfx::Rect& old_bounds, 150 const gfx::Rect& old_bounds,
135 const gfx::Rect& new_bounds) { 151 const gfx::Rect& new_bounds) {
136 if (!IsContainerWindow(window)) 152 if (!IsContainerWindow(window))
137 return; 153 return;
138 // Reposition all non maximizeable windows. 154 // Reposition all non maximizeable windows.
139 for (auto& pair : window_state_map_) 155 for (auto& pair : window_state_map_)
140 pair.second->UpdateWindowPosition(pair.first->GetWindowState()); 156 pair.second->UpdateWindowPosition(pair.first->GetWindowState());
141 } 157 }
142 158
159 void MaximizeModeWindowManager::OnWindowVisibilityChanging(WmWindow* window,
160 bool visible) {
161 // Skip if it's already managed.
162 if (ContainsKey(window_state_map_, window))
163 return;
164
165 if (IsContainerWindow(window->GetParent()) &&
166 ContainsValue(added_windows_, window) && visible) {
167 added_windows_.erase(window);
168 window->RemoveObserver(this);
169 MaximizeAndTrackWindow(window);
170 // When the state got added, the "WM_EVENT_ADDED_TO_WORKSPACE" event got
171 // already sent and we have to notify our state again.
172 if (ContainsKey(window_state_map_, window)) {
173 wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE);
174 window->GetWindowState()->OnWMEvent(&event);
175 }
176 }
177 }
178
143 void MaximizeModeWindowManager::OnDisplayAdded( 179 void MaximizeModeWindowManager::OnDisplayAdded(
144 const display::Display& display) { 180 const display::Display& display) {
145 DisplayConfigurationChanged(); 181 DisplayConfigurationChanged();
146 } 182 }
147 183
148 void MaximizeModeWindowManager::OnDisplayRemoved( 184 void MaximizeModeWindowManager::OnDisplayRemoved(
149 const display::Display& display) { 185 const display::Display& display) {
150 DisplayConfigurationChanged(); 186 DisplayConfigurationChanged();
151 } 187 }
152 188
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 for (WmWindow* root : WmShell::Get()->GetAllRootWindows()) { 317 for (WmWindow* root : WmShell::Get()->GetAllRootWindows()) {
282 WmRootWindowController* controller = root->GetRootWindowController(); 318 WmRootWindowController* controller = root->GetRootWindowController();
283 WmWindow* default_container = 319 WmWindow* default_container =
284 root->GetChildByShellWindowId(kShellWindowId_DefaultContainer); 320 root->GetChildByShellWindowId(kShellWindowId_DefaultContainer);
285 controller->SetMaximizeBackdropDelegate(base::WrapUnique( 321 controller->SetMaximizeBackdropDelegate(base::WrapUnique(
286 enable ? new WorkspaceBackdropDelegate(default_container) : nullptr)); 322 enable ? new WorkspaceBackdropDelegate(default_container) : nullptr));
287 } 323 }
288 } 324 }
289 325
290 } // namespace ash 326 } // 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