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/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
8 #include "ash/screen_ash.h" | 8 #include "ash/screen_ash.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/wm/window_properties.h" | 10 #include "ash/wm/window_properties.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 namespace wm { | 21 namespace wm { |
22 | 22 |
23 // static | 23 // static |
24 bool WindowState::IsMaximizedOrFullscreenState(ui::WindowShowState show_state) { | 24 bool WindowState::IsMaximizedOrFullscreenState(ui::WindowShowState show_state) { |
25 return show_state == ui::SHOW_STATE_FULLSCREEN || | 25 return show_state == ui::SHOW_STATE_FULLSCREEN || |
26 show_state == ui::SHOW_STATE_MAXIMIZED; | 26 show_state == ui::SHOW_STATE_MAXIMIZED; |
27 } | 27 } |
28 | 28 |
29 WindowState::WindowState(aura::Window* window) | 29 WindowState::WindowState(aura::Window* window) |
30 : window_(window), | 30 : window_(window), |
| 31 fullscreen_type_(FULLSCREEN_TYPE_DEFAULT), |
31 tracked_by_workspace_(true), | 32 tracked_by_workspace_(true), |
32 window_position_managed_(false), | 33 window_position_managed_(false), |
33 bounds_changed_by_user_(false), | 34 bounds_changed_by_user_(false), |
34 panel_attached_(true), | 35 panel_attached_(true), |
35 continue_drag_after_reparent_(false), | 36 continue_drag_after_reparent_(false), |
36 ignored_by_shelf_(false), | 37 ignored_by_shelf_(false), |
37 can_consume_system_keys_(false), | 38 can_consume_system_keys_(false), |
38 top_row_keys_are_function_keys_(false), | 39 top_row_keys_are_function_keys_(false), |
39 always_restores_to_restore_bounds_(false), | 40 always_restores_to_restore_bounds_(false), |
40 window_show_type_(ToWindowShowType(GetShowState())) { | 41 window_show_type_(ToWindowShowType(GetShowState())) { |
(...skipping 12 matching lines...) Expand all Loading... |
53 } | 54 } |
54 | 55 |
55 bool WindowState::IsMaximized() const { | 56 bool WindowState::IsMaximized() const { |
56 return GetShowState() == ui::SHOW_STATE_MAXIMIZED; | 57 return GetShowState() == ui::SHOW_STATE_MAXIMIZED; |
57 } | 58 } |
58 | 59 |
59 bool WindowState::IsFullscreen() const { | 60 bool WindowState::IsFullscreen() const { |
60 return GetShowState() == ui::SHOW_STATE_FULLSCREEN; | 61 return GetShowState() == ui::SHOW_STATE_FULLSCREEN; |
61 } | 62 } |
62 | 63 |
| 64 bool WindowState::IsImmersiveFullscreen() const { |
| 65 if (!IsFullscreen()) |
| 66 return false; |
| 67 return fullscreen_type_ == FULLSCREEN_TYPE_IMMERSIVE_MINIMAL_CHROME || |
| 68 fullscreen_type_ == FULLSCREEN_TYPE_IMMERSIVE_NO_CHROME; |
| 69 } |
| 70 |
63 bool WindowState::IsMaximizedOrFullscreen() const { | 71 bool WindowState::IsMaximizedOrFullscreen() const { |
64 return IsMaximizedOrFullscreenState(GetShowState()); | 72 return IsMaximizedOrFullscreenState(GetShowState()); |
65 } | 73 } |
66 | 74 |
67 bool WindowState::IsNormalShowState() const { | 75 bool WindowState::IsNormalShowState() const { |
68 ui::WindowShowState state = window_->GetProperty(aura::client::kShowStateKey); | 76 ui::WindowShowState state = window_->GetProperty(aura::client::kShowStateKey); |
69 return state == ui::SHOW_STATE_NORMAL || state == ui::SHOW_STATE_DEFAULT; | 77 return state == ui::SHOW_STATE_NORMAL || state == ui::SHOW_STATE_DEFAULT; |
70 } | 78 } |
71 | 79 |
72 bool WindowState::IsActive() const { | 80 bool WindowState::IsActive() const { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 192 |
185 void WindowState::SetRestoreBoundsInParent(const gfx::Rect& bounds) { | 193 void WindowState::SetRestoreBoundsInParent(const gfx::Rect& bounds) { |
186 SetRestoreBoundsInScreen( | 194 SetRestoreBoundsInScreen( |
187 ScreenAsh::ConvertRectToScreen(window_->parent(), bounds)); | 195 ScreenAsh::ConvertRectToScreen(window_->parent(), bounds)); |
188 } | 196 } |
189 | 197 |
190 void WindowState::ClearRestoreBounds() { | 198 void WindowState::ClearRestoreBounds() { |
191 window_->ClearProperty(aura::client::kRestoreBoundsKey); | 199 window_->ClearProperty(aura::client::kRestoreBoundsKey); |
192 } | 200 } |
193 | 201 |
| 202 void WindowState::SetFullscreenType(FullscreenType type) { |
| 203 if (!IsFullscreen() || fullscreen_type_ == type) |
| 204 return; |
| 205 FullscreenType old = fullscreen_type_; |
| 206 fullscreen_type_ = type; |
| 207 FOR_EACH_OBSERVER(WindowStateObserver, observer_list_, |
| 208 OnWindowFullscreenTypeChanged(this, old)); |
| 209 } |
| 210 |
194 void WindowState::SetPreAutoManageWindowBounds( | 211 void WindowState::SetPreAutoManageWindowBounds( |
195 const gfx::Rect& bounds) { | 212 const gfx::Rect& bounds) { |
196 pre_auto_manage_window_bounds_.reset(new gfx::Rect(bounds)); | 213 pre_auto_manage_window_bounds_.reset(new gfx::Rect(bounds)); |
197 } | 214 } |
198 | 215 |
199 void WindowState::AddObserver(WindowStateObserver* observer) { | 216 void WindowState::AddObserver(WindowStateObserver* observer) { |
200 observer_list_.AddObserver(observer); | 217 observer_list_.AddObserver(observer); |
201 } | 218 } |
202 | 219 |
203 void WindowState::RemoveObserver(WindowStateObserver* observer) { | 220 void WindowState::RemoveObserver(WindowStateObserver* observer) { |
204 observer_list_.RemoveObserver(observer); | 221 observer_list_.RemoveObserver(observer); |
205 } | 222 } |
206 | 223 |
207 void WindowState::SetTrackedByWorkspace(bool tracked_by_workspace) { | 224 void WindowState::SetTrackedByWorkspace(bool tracked_by_workspace) { |
208 if (tracked_by_workspace_ == tracked_by_workspace) | 225 if (tracked_by_workspace_ == tracked_by_workspace) |
209 return; | 226 return; |
210 bool old = tracked_by_workspace_; | 227 bool old = tracked_by_workspace_; |
211 tracked_by_workspace_ = tracked_by_workspace; | 228 tracked_by_workspace_ = tracked_by_workspace; |
212 FOR_EACH_OBSERVER(WindowStateObserver, observer_list_, | 229 FOR_EACH_OBSERVER(WindowStateObserver, observer_list_, |
213 OnTrackedByWorkspaceChanged(this, old)); | 230 OnTrackedByWorkspaceChanged(this, old)); |
214 } | 231 } |
215 | 232 |
216 void WindowState::OnWindowPropertyChanged(aura::Window* window, | 233 void WindowState::OnWindowPropertyChanged(aura::Window* window, |
217 const void* key, | 234 const void* key, |
218 intptr_t old) { | 235 intptr_t old) { |
219 DCHECK_EQ(window, window_); | 236 DCHECK_EQ(window, window_); |
220 if (key == aura::client::kShowStateKey) { | 237 if (key == aura::client::kShowStateKey) { |
221 window_show_type_ = ToWindowShowType(GetShowState()); | 238 window_show_type_ = ToWindowShowType(GetShowState()); |
| 239 if (window_show_type_ != ash::wm::SHOW_TYPE_FULLSCREEN && |
| 240 window_show_type_ != ash::wm::SHOW_TYPE_MINIMIZED) { |
| 241 fullscreen_type_ = FULLSCREEN_TYPE_DEFAULT; |
| 242 } |
| 243 |
222 ui::WindowShowState old_state = static_cast<ui::WindowShowState>(old); | 244 ui::WindowShowState old_state = static_cast<ui::WindowShowState>(old); |
223 // TODO(oshima): Notify only when the state has changed. | 245 // TODO(oshima): Notify only when the state has changed. |
224 // Doing so break a few tests now. | 246 // Doing so break a few tests now. |
225 FOR_EACH_OBSERVER( | 247 FOR_EACH_OBSERVER( |
226 WindowStateObserver, observer_list_, | 248 WindowStateObserver, observer_list_, |
227 OnWindowShowTypeChanged(this, ToWindowShowType(old_state))); | 249 OnWindowShowTypeChanged(this, ToWindowShowType(old_state))); |
228 } | 250 } |
229 } | 251 } |
230 | 252 |
231 void WindowState::OnWindowDestroying(aura::Window* window) { | 253 void WindowState::OnWindowDestroying(aura::Window* window) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 } | 291 } |
270 return settings; | 292 return settings; |
271 } | 293 } |
272 | 294 |
273 const WindowState* GetWindowState(const aura::Window* window) { | 295 const WindowState* GetWindowState(const aura::Window* window) { |
274 return GetWindowState(const_cast<aura::Window*>(window)); | 296 return GetWindowState(const_cast<aura::Window*>(window)); |
275 } | 297 } |
276 | 298 |
277 } // namespace wm | 299 } // namespace wm |
278 } // namespace ash | 300 } // namespace ash |
OLD | NEW |