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

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: Update tests. 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 return window_->GetProperty(aura::client::kCanMaximizeKey); 144 return window_->GetProperty(aura::client::kCanMaximizeKey);
oshima 2014/09/10 15:59:31 can you add GetMaximizedSize check here? I think t
jackhou1 2014/09/11 00:16:54 Done.
145 } 145 }
146 146
147 bool WindowState::CanMinimize() const { 147 bool WindowState::CanMinimize() const {
148 RootWindowController* controller = RootWindowController::ForWindow(window_); 148 RootWindowController* controller = RootWindowController::ForWindow(window_);
149 if (!controller) 149 if (!controller)
150 return false; 150 return false;
151 aura::Window* lockscreen = 151 aura::Window* lockscreen =
152 controller->GetContainer(kShellWindowId_LockScreenContainersContainer); 152 controller->GetContainer(kShellWindowId_LockScreenContainersContainer);
153 if (lockscreen->Contains(window_)) 153 if (lockscreen->Contains(window_))
154 return false; 154 return false;
155 155
156 return true; 156 return true;
157 } 157 }
158 158
159 bool WindowState::CanResize() const { 159 bool WindowState::CanResize() const {
160 return window_->GetProperty(aura::client::kCanResizeKey); 160 return window_->GetProperty(aura::client::kCanResizeKey);
161 } 161 }
162 162
163 bool WindowState::CanActivate() const { 163 bool WindowState::CanActivate() const {
164 return ::wm::CanActivateWindow(window_); 164 return ::wm::CanActivateWindow(window_);
165 } 165 }
166 166
167 bool WindowState::CanSnap() const { 167 bool WindowState::CanSnap() const {
168 if (!CanResize() || window_->type() == ui::wm::WINDOW_TYPE_PANEL || 168 if (!CanResize() || window_->type() == ui::wm::WINDOW_TYPE_PANEL ||
169 ::wm::GetTransientParent(window_)) 169 ::wm::GetTransientParent(window_))
170 return false; 170 return false;
171 // If a window has a maximum size defined, snapping may make it too big. 171 // If a window cannot be maximized, assume it cannot snap either.
172 // TODO(oshima): We probably should snap if possible. 172 // TODO(oshima): We should probably snap if the maximum size is greater than
173 return window_->delegate() ? window_->delegate()->GetMaximumSize().IsEmpty() : 173 // the snapped size.
174 true; 174 return CanMaximize();
175 } 175 }
176 176
177 bool WindowState::HasRestoreBounds() const { 177 bool WindowState::HasRestoreBounds() const {
178 return window_->GetProperty(aura::client::kRestoreBoundsKey) != NULL; 178 return window_->GetProperty(aura::client::kRestoreBoundsKey) != NULL;
179 } 179 }
180 180
181 void WindowState::Maximize() { 181 void WindowState::Maximize() {
182 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 182 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
183 } 183 }
184 184
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 } 450 }
451 return settings; 451 return settings;
452 } 452 }
453 453
454 const WindowState* GetWindowState(const aura::Window* window) { 454 const WindowState* GetWindowState(const aura::Window* window) {
455 return GetWindowState(const_cast<aura::Window*>(window)); 455 return GetWindowState(const_cast<aura::Window*>(window));
456 } 456 }
457 457
458 } // namespace wm 458 } // namespace wm
459 } // namespace ash 459 } // 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