Chromium Code Reviews| 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 auto current_state = window->GetProperty(aura::client::kShowStateKey); | |
|
sky
2017/01/24 21:56:33
It isn't obvious what the type is here, please use
Peng
2017/01/24 22:13:03
Done.
| |
| 91 bool is_fullscreen = current_state == ui::SHOW_STATE_FULLSCREEN; | |
| 92 if (fullscreen == is_fullscreen) | |
| 93 return; | |
| 94 if (fullscreen) { | |
| 95 // Save the previous show state so that we can correctly restore it after | |
| 96 // exiting the fullscreen mode. | |
| 97 auto pre_state = current_state; | |
|
sky
2017/01/24 21:56:33
pre_show_state.
Peng
2017/01/24 22:13:03
Done.
| |
| 98 // If the previous show state is ui::SHOW_STATE_MINIMIZED, we will use | |
| 99 // the show state before the window was minimized. But if the window was | |
| 100 // fullscreen before it was minimized, we will keep the | |
| 101 // PreMinimizedShowState unchanged. | |
| 102 if (pre_state == ui::SHOW_STATE_MINIMIZED) | |
| 103 pre_state = window->GetProperty(aura::client::kPreMinimizedShowStateKey); | |
| 104 if (pre_state != ui::SHOW_STATE_FULLSCREEN) | |
| 105 window->SetProperty(aura::client::kPreFullscreenShowStateKey, pre_state); | |
| 106 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | |
| 107 } else { | |
| 108 auto pre_fullscreen_state = | |
|
sky
2017/01/24 21:56:33
pre_fullscreen_show_state. And same comment about
Peng
2017/01/24 22:13:03
Done.
| |
| 109 window->GetProperty(aura::client::kPreFullscreenShowStateKey); | |
| 110 DCHECK_NE(pre_fullscreen_state, ui::SHOW_STATE_MINIMIZED); | |
| 111 window->SetProperty(aura::client::kShowStateKey, pre_fullscreen_state); | |
| 112 window->ClearProperty(aura::client::kPreFullscreenShowStateKey); | |
| 113 } | |
| 114 } | |
| 115 | |
| 87 aura::Window* GetActivatableWindow(aura::Window* window) { | 116 aura::Window* GetActivatableWindow(aura::Window* window) { |
| 88 aura::client::ActivationClient* client = | 117 aura::client::ActivationClient* client = |
| 89 aura::client::GetActivationClient(window->GetRootWindow()); | 118 aura::client::GetActivationClient(window->GetRootWindow()); |
| 90 return client ? client->GetActivatableWindow(window) : NULL; | 119 return client ? client->GetActivatableWindow(window) : NULL; |
| 91 } | 120 } |
| 92 | 121 |
| 93 aura::Window* GetToplevelWindow(aura::Window* window) { | 122 aura::Window* GetToplevelWindow(aura::Window* window) { |
| 94 aura::client::ActivationClient* client = | 123 aura::client::ActivationClient* client = |
| 95 aura::client::GetActivationClient(window->GetRootWindow()); | 124 aura::client::GetActivationClient(window->GetRootWindow()); |
| 96 return client ? client->GetToplevelWindow(window) : NULL; | 125 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, | 170 bool HasTransientAncestor(const aura::Window* window, |
| 142 const aura::Window* ancestor) { | 171 const aura::Window* ancestor) { |
| 143 const aura::Window* transient_parent = GetTransientParent(window); | 172 const aura::Window* transient_parent = GetTransientParent(window); |
| 144 if (transient_parent == ancestor) | 173 if (transient_parent == ancestor) |
| 145 return true; | 174 return true; |
| 146 return transient_parent ? | 175 return transient_parent ? |
| 147 HasTransientAncestor(transient_parent, ancestor) : false; | 176 HasTransientAncestor(transient_parent, ancestor) : false; |
| 148 } | 177 } |
| 149 | 178 |
| 150 } // namespace wm | 179 } // namespace wm |
| OLD | NEW |