| 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()) |
| 204 return; |
| 205 fullscreen_type_ = type; |
| 206 } |
| 207 |
| 194 void WindowState::SetPreAutoManageWindowBounds( | 208 void WindowState::SetPreAutoManageWindowBounds( |
| 195 const gfx::Rect& bounds) { | 209 const gfx::Rect& bounds) { |
| 196 pre_auto_manage_window_bounds_.reset(new gfx::Rect(bounds)); | 210 pre_auto_manage_window_bounds_.reset(new gfx::Rect(bounds)); |
| 197 } | 211 } |
| 198 | 212 |
| 199 void WindowState::AddObserver(WindowStateObserver* observer) { | 213 void WindowState::AddObserver(WindowStateObserver* observer) { |
| 200 observer_list_.AddObserver(observer); | 214 observer_list_.AddObserver(observer); |
| 201 } | 215 } |
| 202 | 216 |
| 203 void WindowState::RemoveObserver(WindowStateObserver* observer) { | 217 void WindowState::RemoveObserver(WindowStateObserver* observer) { |
| 204 observer_list_.RemoveObserver(observer); | 218 observer_list_.RemoveObserver(observer); |
| 205 } | 219 } |
| 206 | 220 |
| 207 void WindowState::SetTrackedByWorkspace(bool tracked_by_workspace) { | 221 void WindowState::SetTrackedByWorkspace(bool tracked_by_workspace) { |
| 208 if (tracked_by_workspace_ == tracked_by_workspace) | 222 if (tracked_by_workspace_ == tracked_by_workspace) |
| 209 return; | 223 return; |
| 210 bool old = tracked_by_workspace_; | 224 bool old = tracked_by_workspace_; |
| 211 tracked_by_workspace_ = tracked_by_workspace; | 225 tracked_by_workspace_ = tracked_by_workspace; |
| 212 FOR_EACH_OBSERVER(WindowStateObserver, observer_list_, | 226 FOR_EACH_OBSERVER(WindowStateObserver, observer_list_, |
| 213 OnTrackedByWorkspaceChanged(this, old)); | 227 OnTrackedByWorkspaceChanged(this, old)); |
| 214 } | 228 } |
| 215 | 229 |
| 216 void WindowState::OnWindowPropertyChanged(aura::Window* window, | 230 void WindowState::OnWindowPropertyChanged(aura::Window* window, |
| 217 const void* key, | 231 const void* key, |
| 218 intptr_t old) { | 232 intptr_t old) { |
| 219 DCHECK_EQ(window, window_); | 233 DCHECK_EQ(window, window_); |
| 220 if (key == aura::client::kShowStateKey) { | 234 if (key == aura::client::kShowStateKey) { |
| 221 window_show_type_ = ToWindowShowType(GetShowState()); | 235 window_show_type_ = ToWindowShowType(GetShowState()); |
| 236 if (window_show_type_ != ash::wm::SHOW_TYPE_FULLSCREEN && |
| 237 window_show_type_ != ash::wm::SHOW_TYPE_MINIMIZED) { |
| 238 fullscreen_type_ = FULLSCREEN_TYPE_DEFAULT; |
| 239 } |
| 240 |
| 222 ui::WindowShowState old_state = static_cast<ui::WindowShowState>(old); | 241 ui::WindowShowState old_state = static_cast<ui::WindowShowState>(old); |
| 223 // TODO(oshima): Notify only when the state has changed. | 242 // TODO(oshima): Notify only when the state has changed. |
| 224 // Doing so break a few tests now. | 243 // Doing so break a few tests now. |
| 225 FOR_EACH_OBSERVER( | 244 FOR_EACH_OBSERVER( |
| 226 WindowStateObserver, observer_list_, | 245 WindowStateObserver, observer_list_, |
| 227 OnWindowShowTypeChanged(this, ToWindowShowType(old_state))); | 246 OnWindowShowTypeChanged(this, ToWindowShowType(old_state))); |
| 228 } | 247 } |
| 229 } | 248 } |
| 230 | 249 |
| 231 void WindowState::OnWindowDestroying(aura::Window* window) { | 250 void WindowState::OnWindowDestroying(aura::Window* window) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 } | 288 } |
| 270 return settings; | 289 return settings; |
| 271 } | 290 } |
| 272 | 291 |
| 273 const WindowState* GetWindowState(const aura::Window* window) { | 292 const WindowState* GetWindowState(const aura::Window* window) { |
| 274 return GetWindowState(const_cast<aura::Window*>(window)); | 293 return GetWindowState(const_cast<aura::Window*>(window)); |
| 275 } | 294 } |
| 276 | 295 |
| 277 } // namespace wm | 296 } // namespace wm |
| 278 } // namespace ash | 297 } // namespace ash |
| OLD | NEW |