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 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 Loading... | |
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 |
OLD | NEW |