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/views/corewm/window_util.h" | 5 #include "ui/views/corewm/window_util.h" |
6 | 6 |
| 7 #include "ui/aura/client/activation_client.h" |
| 8 #include "ui/aura/root_window.h" |
7 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
8 #include "ui/compositor/layer.h" | 10 #include "ui/compositor/layer.h" |
9 | 11 |
10 namespace views { | 12 namespace views { |
11 namespace corewm { | 13 namespace corewm { |
12 | 14 |
| 15 void ActivateWindow(aura::Window* window) { |
| 16 DCHECK(window); |
| 17 DCHECK(window->GetRootWindow()); |
| 18 aura::client::GetActivationClient(window->GetRootWindow())->ActivateWindow( |
| 19 window); |
| 20 } |
| 21 |
| 22 void DeactivateWindow(aura::Window* window) { |
| 23 DCHECK(window); |
| 24 DCHECK(window->GetRootWindow()); |
| 25 aura::client::GetActivationClient(window->GetRootWindow())->DeactivateWindow( |
| 26 window); |
| 27 } |
| 28 |
| 29 bool IsActiveWindow(aura::Window* window) { |
| 30 DCHECK(window); |
| 31 if (!window->GetRootWindow()) |
| 32 return false; |
| 33 aura::client::ActivationClient* client = |
| 34 aura::client::GetActivationClient(window->GetRootWindow()); |
| 35 return client && client->GetActiveWindow() == window; |
| 36 } |
| 37 |
| 38 bool CanActivateWindow(aura::Window* window) { |
| 39 DCHECK(window); |
| 40 if (!window->GetRootWindow()) |
| 41 return false; |
| 42 aura::client::ActivationClient* client = |
| 43 aura::client::GetActivationClient(window->GetRootWindow()); |
| 44 return client && client->CanActivateWindow(window); |
| 45 } |
| 46 |
| 47 aura::Window* GetActivatableWindow(aura::Window* window) { |
| 48 aura::client::ActivationClient* client = |
| 49 aura::client::GetActivationClient(window->GetRootWindow()); |
| 50 return client ? client->GetActivatableWindow(window) : NULL; |
| 51 } |
| 52 |
13 void DeepDeleteLayers(ui::Layer* layer) { | 53 void DeepDeleteLayers(ui::Layer* layer) { |
14 std::vector<ui::Layer*> children = layer->children(); | 54 std::vector<ui::Layer*> children = layer->children(); |
15 for (std::vector<ui::Layer*>::const_iterator it = children.begin(); | 55 for (std::vector<ui::Layer*>::const_iterator it = children.begin(); |
16 it != children.end(); | 56 it != children.end(); |
17 ++it) { | 57 ++it) { |
18 ui::Layer* child = *it; | 58 ui::Layer* child = *it; |
19 DeepDeleteLayers(child); | 59 DeepDeleteLayers(child); |
20 } | 60 } |
21 delete layer; | 61 delete layer; |
22 } | 62 } |
23 | 63 |
24 ui::Layer* RecreateWindowLayers(aura::Window* window, bool set_bounds) { | 64 ui::Layer* RecreateWindowLayers(aura::Window* window, bool set_bounds) { |
25 const gfx::Rect bounds = window->bounds(); | 65 const gfx::Rect bounds = window->bounds(); |
26 ui::Layer* old_layer = window->RecreateLayer(); | 66 ui::Layer* old_layer = window->RecreateLayer(); |
27 DCHECK(old_layer); | 67 DCHECK(old_layer); |
28 for (aura::Window::Windows::const_iterator it = window->children().begin(); | 68 for (aura::Window::Windows::const_iterator it = window->children().begin(); |
29 it != window->children().end(); | 69 it != window->children().end(); |
30 ++it) { | 70 ++it) { |
31 // Maintain the hierarchy of the detached layers. | 71 // Maintain the hierarchy of the detached layers. |
32 old_layer->Add(RecreateWindowLayers(*it, set_bounds)); | 72 old_layer->Add(RecreateWindowLayers(*it, set_bounds)); |
33 } | 73 } |
34 if (set_bounds) | 74 if (set_bounds) |
35 window->SetBounds(bounds); | 75 window->SetBounds(bounds); |
36 return old_layer; | 76 return old_layer; |
37 } | 77 } |
38 | 78 |
39 } // namespace corewm | 79 } // namespace corewm |
40 } // namespace views | 80 } // namespace views |
OLD | NEW |