OLD | NEW |
---|---|
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 Loading... | |
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 !window_->delegate()) { | |
147 return false; | |
148 } | |
149 | |
Mr4D (OOO till 08-26)
2014/09/11 20:24:17
A window which can be maximized and has a maximum
oshima
2014/09/11 20:32:14
potentially yes, but that conflicts when the displ
| |
150 gfx::Size max_size = window_->delegate()->GetMaximumSize(); | |
151 return !max_size.width() && !max_size.height(); | |
145 } | 152 } |
146 | 153 |
147 bool WindowState::CanMinimize() const { | 154 bool WindowState::CanMinimize() const { |
148 RootWindowController* controller = RootWindowController::ForWindow(window_); | 155 RootWindowController* controller = RootWindowController::ForWindow(window_); |
149 if (!controller) | 156 if (!controller) |
150 return false; | 157 return false; |
151 aura::Window* lockscreen = | 158 aura::Window* lockscreen = |
152 controller->GetContainer(kShellWindowId_LockScreenContainersContainer); | 159 controller->GetContainer(kShellWindowId_LockScreenContainersContainer); |
153 if (lockscreen->Contains(window_)) | 160 if (lockscreen->Contains(window_)) |
154 return false; | 161 return false; |
155 | 162 |
156 return true; | 163 return true; |
157 } | 164 } |
158 | 165 |
159 bool WindowState::CanResize() const { | 166 bool WindowState::CanResize() const { |
160 return window_->GetProperty(aura::client::kCanResizeKey); | 167 return window_->GetProperty(aura::client::kCanResizeKey); |
161 } | 168 } |
162 | 169 |
163 bool WindowState::CanActivate() const { | 170 bool WindowState::CanActivate() const { |
164 return ::wm::CanActivateWindow(window_); | 171 return ::wm::CanActivateWindow(window_); |
165 } | 172 } |
166 | 173 |
167 bool WindowState::CanSnap() const { | 174 bool WindowState::CanSnap() const { |
168 if (!CanResize() || window_->type() == ui::wm::WINDOW_TYPE_PANEL || | 175 if (!CanResize() || window_->type() == ui::wm::WINDOW_TYPE_PANEL || |
169 ::wm::GetTransientParent(window_)) | 176 ::wm::GetTransientParent(window_)) |
170 return false; | 177 return false; |
171 // If a window has a maximum size defined, snapping may make it too big. | 178 // If a window cannot be maximized, assume it cannot snap either. |
172 // TODO(oshima): We probably should snap if possible. | 179 // TODO(oshima): We should probably snap if the maximum size is greater than |
173 return window_->delegate() ? window_->delegate()->GetMaximumSize().IsEmpty() : | 180 // the snapped size. |
174 true; | 181 return CanMaximize(); |
175 } | 182 } |
176 | 183 |
177 bool WindowState::HasRestoreBounds() const { | 184 bool WindowState::HasRestoreBounds() const { |
178 return window_->GetProperty(aura::client::kRestoreBoundsKey) != NULL; | 185 return window_->GetProperty(aura::client::kRestoreBoundsKey) != NULL; |
179 } | 186 } |
180 | 187 |
181 void WindowState::Maximize() { | 188 void WindowState::Maximize() { |
182 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 189 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
183 } | 190 } |
184 | 191 |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
450 } | 457 } |
451 return settings; | 458 return settings; |
452 } | 459 } |
453 | 460 |
454 const WindowState* GetWindowState(const aura::Window* window) { | 461 const WindowState* GetWindowState(const aura::Window* window) { |
455 return GetWindowState(const_cast<aura::Window*>(window)); | 462 return GetWindowState(const_cast<aura::Window*>(window)); |
456 } | 463 } |
457 | 464 |
458 } // namespace wm | 465 } // namespace wm |
459 } // namespace ash | 466 } // namespace ash |
OLD | NEW |