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

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: Address comments 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') | ash/wm/window_state_unittest.cc » ('J')
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 if (window_->delegate()) {
145 gfx::Size max_size = window_->delegate()->GetMaximumSize();
146 if (max_size.width() || max_size.height())
147 return false;
148 }
149
144 return window_->GetProperty(aura::client::kCanMaximizeKey); 150 return window_->GetProperty(aura::client::kCanMaximizeKey);
oshima 2014/09/11 01:00:05 This should be window->GetProperty(aura::client::
jackhou1 2014/09/11 01:52:42 Ah I see. BTW, GetMaximumSize will return 0x200 i
145 } 151 }
146 152
147 bool WindowState::CanMinimize() const { 153 bool WindowState::CanMinimize() const {
148 RootWindowController* controller = RootWindowController::ForWindow(window_); 154 RootWindowController* controller = RootWindowController::ForWindow(window_);
149 if (!controller) 155 if (!controller)
150 return false; 156 return false;
151 aura::Window* lockscreen = 157 aura::Window* lockscreen =
152 controller->GetContainer(kShellWindowId_LockScreenContainersContainer); 158 controller->GetContainer(kShellWindowId_LockScreenContainersContainer);
153 if (lockscreen->Contains(window_)) 159 if (lockscreen->Contains(window_))
154 return false; 160 return false;
155 161
156 return true; 162 return true;
157 } 163 }
158 164
159 bool WindowState::CanResize() const { 165 bool WindowState::CanResize() const {
160 return window_->GetProperty(aura::client::kCanResizeKey); 166 return window_->GetProperty(aura::client::kCanResizeKey);
161 } 167 }
162 168
163 bool WindowState::CanActivate() const { 169 bool WindowState::CanActivate() const {
164 return ::wm::CanActivateWindow(window_); 170 return ::wm::CanActivateWindow(window_);
165 } 171 }
166 172
167 bool WindowState::CanSnap() const { 173 bool WindowState::CanSnap() const {
168 if (!CanResize() || window_->type() == ui::wm::WINDOW_TYPE_PANEL || 174 if (!CanResize() || window_->type() == ui::wm::WINDOW_TYPE_PANEL ||
169 ::wm::GetTransientParent(window_)) 175 ::wm::GetTransientParent(window_))
170 return false; 176 return false;
171 // If a window has a maximum size defined, snapping may make it too big. 177 // If a window cannot be maximized, assume it cannot snap either.
172 // TODO(oshima): We probably should snap if possible. 178 // TODO(oshima): We should probably snap if the maximum size is greater than
173 return window_->delegate() ? window_->delegate()->GetMaximumSize().IsEmpty() : 179 // the snapped size.
174 true; 180 return CanMaximize();
175 } 181 }
176 182
177 bool WindowState::HasRestoreBounds() const { 183 bool WindowState::HasRestoreBounds() const {
178 return window_->GetProperty(aura::client::kRestoreBoundsKey) != NULL; 184 return window_->GetProperty(aura::client::kRestoreBoundsKey) != NULL;
179 } 185 }
180 186
181 void WindowState::Maximize() { 187 void WindowState::Maximize() {
182 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 188 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
183 } 189 }
184 190
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 } 456 }
451 return settings; 457 return settings;
452 } 458 }
453 459
454 const WindowState* GetWindowState(const aura::Window* window) { 460 const WindowState* GetWindowState(const aura::Window* window) {
455 return GetWindowState(const_cast<aura::Window*>(window)); 461 return GetWindowState(const_cast<aura::Window*>(window));
456 } 462 }
457 463
458 } // namespace wm 464 } // namespace wm
459 } // namespace ash 465 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/wm/window_state_unittest.cc » ('j') | ash/wm/window_state_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698