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

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

Issue 557693002: [Ash] Only snap windows that can maximize. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Return true if there is no delegate. Created 6 years, 3 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 | « no previous file | ash/wm/window_state_unittest.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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/window_state.h" 5 #include "ash/wm/window_state.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/screen_util.h" 9 #include "ash/screen_util.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 bool WindowState::IsActive() const { 134 bool WindowState::IsActive() const {
135 return IsActiveWindow(window_); 135 return IsActiveWindow(window_);
136 } 136 }
137 137
138 bool WindowState::IsDocked() const { 138 bool WindowState::IsDocked() const {
139 return window_->parent() && 139 return window_->parent() &&
140 window_->parent()->id() == kShellWindowId_DockedContainer; 140 window_->parent()->id() == kShellWindowId_DockedContainer;
141 } 141 }
142 142
143 bool WindowState::CanMaximize() const { 143 bool WindowState::CanMaximize() const {
144 return window_->GetProperty(aura::client::kCanMaximizeKey); 144 // Window must have the kCanMaximizeKey and have no maximum width or height.
145 if (!window()->GetProperty(aura::client::kCanMaximizeKey))
146 return false;
147
148 if (!window()->delegate())
149 return true;
150
151 gfx::Size max_size = window_->delegate()->GetMaximumSize();
152 return !max_size.width() && !max_size.height();
145 } 153 }
146 154
147 bool WindowState::CanMinimize() const { 155 bool WindowState::CanMinimize() const {
148 RootWindowController* controller = RootWindowController::ForWindow(window_); 156 RootWindowController* controller = RootWindowController::ForWindow(window_);
149 if (!controller) 157 if (!controller)
150 return false; 158 return false;
151 aura::Window* lockscreen = 159 aura::Window* lockscreen =
152 controller->GetContainer(kShellWindowId_LockScreenContainersContainer); 160 controller->GetContainer(kShellWindowId_LockScreenContainersContainer);
153 if (lockscreen->Contains(window_)) 161 if (lockscreen->Contains(window_))
154 return false; 162 return false;
155 163
156 return true; 164 return true;
157 } 165 }
158 166
159 bool WindowState::CanResize() const { 167 bool WindowState::CanResize() const {
160 return window_->GetProperty(aura::client::kCanResizeKey); 168 return window_->GetProperty(aura::client::kCanResizeKey);
161 } 169 }
162 170
163 bool WindowState::CanActivate() const { 171 bool WindowState::CanActivate() const {
164 return ::wm::CanActivateWindow(window_); 172 return ::wm::CanActivateWindow(window_);
165 } 173 }
166 174
167 bool WindowState::CanSnap() const { 175 bool WindowState::CanSnap() const {
168 if (!CanResize() || window_->type() == ui::wm::WINDOW_TYPE_PANEL || 176 if (!CanResize() || window_->type() == ui::wm::WINDOW_TYPE_PANEL ||
169 ::wm::GetTransientParent(window_)) 177 ::wm::GetTransientParent(window_))
170 return false; 178 return false;
171 // If a window has a maximum size defined, snapping may make it too big. 179 // If a window cannot be maximized, assume it cannot snap either.
172 // TODO(oshima): We probably should snap if possible. 180 // TODO(oshima): We should probably snap if the maximum size is greater than
173 return window_->delegate() ? window_->delegate()->GetMaximumSize().IsEmpty() : 181 // the snapped size.
174 true; 182 return CanMaximize();
175 } 183 }
176 184
177 bool WindowState::HasRestoreBounds() const { 185 bool WindowState::HasRestoreBounds() const {
178 return window_->GetProperty(aura::client::kRestoreBoundsKey) != NULL; 186 return window_->GetProperty(aura::client::kRestoreBoundsKey) != NULL;
179 } 187 }
180 188
181 void WindowState::Maximize() { 189 void WindowState::Maximize() {
182 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 190 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
183 } 191 }
184 192
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 } 458 }
451 return settings; 459 return settings;
452 } 460 }
453 461
454 const WindowState* GetWindowState(const aura::Window* window) { 462 const WindowState* GetWindowState(const aura::Window* window) {
455 return GetWindowState(const_cast<aura::Window*>(window)); 463 return GetWindowState(const_cast<aura::Window*>(window));
456 } 464 }
457 465
458 } // namespace wm 466 } // namespace wm
459 } // namespace ash 467 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/wm/window_state_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698