| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/wm/core/window_util.h" | 5 #include "ui/wm/core/window_util.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "ui/aura/client/aura_constants.h" |
| 8 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
| 9 #include "ui/compositor/layer.h" | 10 #include "ui/compositor/layer.h" |
| 10 #include "ui/compositor/layer_tree_owner.h" | 11 #include "ui/compositor/layer_tree_owner.h" |
| 11 #include "ui/wm/core/transient_window_manager.h" | 12 #include "ui/wm/core/transient_window_manager.h" |
| 12 #include "ui/wm/public/activation_client.h" | 13 #include "ui/wm/public/activation_client.h" |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 // Invokes RecreateLayer() on all the children of |to_clone|, adding the newly | 17 // Invokes RecreateLayer() on all the children of |to_clone|, adding the newly |
| 17 // cloned children to |parent|. | 18 // cloned children to |parent|. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 78 |
| 78 bool CanActivateWindow(aura::Window* window) { | 79 bool CanActivateWindow(aura::Window* window) { |
| 79 DCHECK(window); | 80 DCHECK(window); |
| 80 if (!window->GetRootWindow()) | 81 if (!window->GetRootWindow()) |
| 81 return false; | 82 return false; |
| 82 aura::client::ActivationClient* client = | 83 aura::client::ActivationClient* client = |
| 83 aura::client::GetActivationClient(window->GetRootWindow()); | 84 aura::client::GetActivationClient(window->GetRootWindow()); |
| 84 return client && client->CanActivateWindow(window); | 85 return client && client->CanActivateWindow(window); |
| 85 } | 86 } |
| 86 | 87 |
| 88 void SetWindowFullscreen(aura::Window* window, bool fullscreen) { |
| 89 DCHECK(window); |
| 90 ui::WindowShowState current_show_state = |
| 91 window->GetProperty(aura::client::kShowStateKey); |
| 92 bool is_fullscreen = current_show_state == ui::SHOW_STATE_FULLSCREEN; |
| 93 if (fullscreen == is_fullscreen) |
| 94 return; |
| 95 if (fullscreen) { |
| 96 // Save the previous show state so that we can correctly restore it after |
| 97 // exiting the fullscreen mode. |
| 98 ui::WindowShowState pre_show_state = current_show_state; |
| 99 // If the previous show state is ui::SHOW_STATE_MINIMIZED, we will use |
| 100 // the show state before the window was minimized. But if the window was |
| 101 // fullscreen before it was minimized, we will keep the |
| 102 // PreMinimizedShowState unchanged. |
| 103 if (pre_show_state == ui::SHOW_STATE_MINIMIZED) { |
| 104 pre_show_state = |
| 105 window->GetProperty(aura::client::kPreMinimizedShowStateKey); |
| 106 } |
| 107 if (pre_show_state != ui::SHOW_STATE_FULLSCREEN) { |
| 108 window->SetProperty(aura::client::kPreFullscreenShowStateKey, |
| 109 pre_show_state); |
| 110 } |
| 111 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 112 } else { |
| 113 ui::WindowShowState pre_fullscreen_show_state = |
| 114 window->GetProperty(aura::client::kPreFullscreenShowStateKey); |
| 115 DCHECK_NE(pre_fullscreen_show_state, ui::SHOW_STATE_MINIMIZED); |
| 116 window->SetProperty(aura::client::kShowStateKey, pre_fullscreen_show_state); |
| 117 window->ClearProperty(aura::client::kPreFullscreenShowStateKey); |
| 118 } |
| 119 } |
| 120 |
| 87 aura::Window* GetActivatableWindow(aura::Window* window) { | 121 aura::Window* GetActivatableWindow(aura::Window* window) { |
| 88 aura::client::ActivationClient* client = | 122 aura::client::ActivationClient* client = |
| 89 aura::client::GetActivationClient(window->GetRootWindow()); | 123 aura::client::GetActivationClient(window->GetRootWindow()); |
| 90 return client ? client->GetActivatableWindow(window) : NULL; | 124 return client ? client->GetActivatableWindow(window) : NULL; |
| 91 } | 125 } |
| 92 | 126 |
| 93 aura::Window* GetToplevelWindow(aura::Window* window) { | 127 aura::Window* GetToplevelWindow(aura::Window* window) { |
| 94 aura::client::ActivationClient* client = | 128 aura::client::ActivationClient* client = |
| 95 aura::client::GetActivationClient(window->GetRootWindow()); | 129 aura::client::GetActivationClient(window->GetRootWindow()); |
| 96 return client ? client->GetToplevelWindow(window) : NULL; | 130 return client ? client->GetToplevelWindow(window) : NULL; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 bool HasTransientAncestor(const aura::Window* window, | 175 bool HasTransientAncestor(const aura::Window* window, |
| 142 const aura::Window* ancestor) { | 176 const aura::Window* ancestor) { |
| 143 const aura::Window* transient_parent = GetTransientParent(window); | 177 const aura::Window* transient_parent = GetTransientParent(window); |
| 144 if (transient_parent == ancestor) | 178 if (transient_parent == ancestor) |
| 145 return true; | 179 return true; |
| 146 return transient_parent ? | 180 return transient_parent ? |
| 147 HasTransientAncestor(transient_parent, ancestor) : false; | 181 HasTransientAncestor(transient_parent, ancestor) : false; |
| 148 } | 182 } |
| 149 | 183 |
| 150 } // namespace wm | 184 } // namespace wm |
| OLD | NEW |