Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: ui/aura_shell/stacking_controller.cc

Issue 8387043: [Aura] Support always-on-top top level window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync, move AlwaysOnTonController from Shell to StackingController Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/aura_shell/stacking_controller.h" 5 #include "ui/aura_shell/stacking_controller.h"
6 6
7 #include "ui/aura/desktop.h" 7 #include "ui/aura/desktop.h"
8 #include "ui/aura/window.h" 8 #include "ui/aura/window.h"
9 #include "ui/aura_shell/always_on_top_controller.h"
9 #include "ui/aura_shell/shell.h" 10 #include "ui/aura_shell/shell.h"
10 #include "ui/aura_shell/shell_window_ids.h" 11 #include "ui/aura_shell/shell_window_ids.h"
11 12
12 namespace aura_shell { 13 namespace aura_shell {
13 namespace internal { 14 namespace internal {
14 namespace { 15 namespace {
15 16
16 aura::Window* GetContainer(int id) { 17 aura::Window* GetContainer(int id) {
17 return Shell::GetInstance()->GetContainer(id); 18 return Shell::GetInstance()->GetContainer(id);
18 } 19 }
19 20
20 // Returns true if children of |window| can be activated. 21 // Returns true if children of |window| can be activated.
21 bool SupportsChildActivation(aura::Window* window) { 22 bool SupportsChildActivation(aura::Window* window) {
22 return window->id() == kShellWindowId_DefaultContainer || 23 return window->id() == kShellWindowId_DefaultContainer ||
23 window->id() == kShellWindowId_AlwaysOnTopContainer; 24 window->id() == kShellWindowId_AlwaysOnTopContainer;
24 } 25 }
25 26
26 } // namespace 27 } // namespace
27 28
28 //////////////////////////////////////////////////////////////////////////////// 29 ////////////////////////////////////////////////////////////////////////////////
29 // StackingController, public: 30 // StackingController, public:
30 31
31 StackingController::StackingController() { 32 StackingController::StackingController() {
32 aura::Desktop::GetInstance()->SetStackingClient(this); 33 aura::Desktop::GetInstance()->SetStackingClient(this);
33 } 34 }
34 35
35 StackingController::~StackingController() { 36 StackingController::~StackingController() {
36 } 37 }
37 38
39 void StackingController::Init() {
40 always_on_top_controller_.reset(new internal::AlwaysOnTopController);
41 always_on_top_controller_->SetContainers(
42 GetContainer(internal::kShellWindowId_DefaultContainer),
43 GetContainer(internal::kShellWindowId_AlwaysOnTopContainer));
44 }
45
38 // static 46 // static
39 aura::Window* StackingController::GetActivatableWindow(aura::Window* window) { 47 aura::Window* StackingController::GetActivatableWindow(aura::Window* window) {
40 aura::Window* parent = window->parent(); 48 aura::Window* parent = window->parent();
41 aura::Window* child = window; 49 aura::Window* child = window;
42 while (parent) { 50 while (parent) {
43 if (SupportsChildActivation(parent)) 51 if (SupportsChildActivation(parent))
44 return child; 52 return child;
45 parent = parent->parent(); 53 parent = parent->parent();
46 child = child->parent(); 54 child = child->parent();
47 } 55 }
48 return false; 56 return false;
49 } 57 }
50 58
51 //////////////////////////////////////////////////////////////////////////////// 59 ////////////////////////////////////////////////////////////////////////////////
52 // StackingController, aura::StackingClient implementation: 60 // StackingController, aura::StackingClient implementation:
53 61
54 void StackingController::AddChildToDefaultParent(aura::Window* window) { 62 void StackingController::AddChildToDefaultParent(aura::Window* window) {
55 aura::Window* parent = NULL; 63 aura::Window* parent = NULL;
56 switch (window->type()) { 64 switch (window->type()) {
57 case aura::WINDOW_TYPE_NORMAL: 65 case aura::WINDOW_TYPE_NORMAL:
58 case aura::WINDOW_TYPE_POPUP: 66 case aura::WINDOW_TYPE_POPUP:
59 parent = GetContainer(internal::kShellWindowId_DefaultContainer); 67 parent = always_on_top_controller_->GetContainer(window);
60 break; 68 break;
61 case aura::WINDOW_TYPE_MENU: 69 case aura::WINDOW_TYPE_MENU:
62 case aura::WINDOW_TYPE_TOOLTIP: 70 case aura::WINDOW_TYPE_TOOLTIP:
63 parent = GetContainer(internal::kShellWindowId_MenusAndTooltipsContainer); 71 parent = GetContainer(internal::kShellWindowId_MenusAndTooltipsContainer);
64 break; 72 break;
65 default: 73 default:
66 NOTREACHED() << "Window " << window->id() 74 NOTREACHED() << "Window " << window->id()
67 << " has unhandled type " << window->type(); 75 << " has unhandled type " << window->type();
68 break; 76 break;
69 } 77 }
(...skipping 16 matching lines...) Expand all
86 } 94 }
87 return NULL; 95 return NULL;
88 } 96 }
89 97
90 98
91 //////////////////////////////////////////////////////////////////////////////// 99 ////////////////////////////////////////////////////////////////////////////////
92 // StackingController, private: 100 // StackingController, private:
93 101
94 } // namespace internal 102 } // namespace internal
95 } // namespace aura_shell 103 } // namespace aura_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698