OLD | NEW |
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/window.h" | 5 #include "ui/aura/window.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "ui/aura/client/stacking_client.h" | 12 #include "ui/aura/client/stacking_client.h" |
13 #include "ui/aura/event.h" | 13 #include "ui/aura/event.h" |
14 #include "ui/aura/event_filter.h" | 14 #include "ui/aura/event_filter.h" |
15 #include "ui/aura/layout_manager.h" | 15 #include "ui/aura/layout_manager.h" |
16 #include "ui/aura/root_window.h" | 16 #include "ui/aura/root_window.h" |
17 #include "ui/aura/window_delegate.h" | 17 #include "ui/aura/window_delegate.h" |
18 #include "ui/aura/window_observer.h" | 18 #include "ui/aura/window_observer.h" |
19 #include "ui/aura/window_types.h" | |
20 #include "ui/base/animation/multi_animation.h" | 19 #include "ui/base/animation/multi_animation.h" |
21 #include "ui/gfx/canvas_skia.h" | 20 #include "ui/gfx/canvas_skia.h" |
22 #include "ui/gfx/compositor/compositor.h" | 21 #include "ui/gfx/compositor/compositor.h" |
23 #include "ui/gfx/screen.h" | 22 #include "ui/gfx/screen.h" |
24 | 23 |
25 namespace aura { | 24 namespace aura { |
26 | 25 |
27 namespace { | 26 namespace { |
28 | 27 |
29 Window* GetParentForWindow(Window* window, Window* suggested_parent) { | 28 Window* GetParentForWindow(Window* window, Window* suggested_parent) { |
30 if (suggested_parent) | 29 if (suggested_parent) |
31 return suggested_parent; | 30 return suggested_parent; |
32 if (client::GetStackingClient()) | 31 if (client::GetStackingClient()) |
33 return client::GetStackingClient()->GetDefaultParent(window); | 32 return client::GetStackingClient()->GetDefaultParent(window); |
34 return RootWindow::GetInstance(); | 33 return RootWindow::GetInstance(); |
35 } | 34 } |
36 | 35 |
37 } // namespace | 36 } // namespace |
38 | 37 |
39 Window::Window(WindowDelegate* delegate) | 38 Window::Window(WindowDelegate* delegate) |
40 : type_(WINDOW_TYPE_UNKNOWN), | 39 : type_(client::WINDOW_TYPE_UNKNOWN), |
41 delegate_(delegate), | 40 delegate_(delegate), |
42 parent_(NULL), | 41 parent_(NULL), |
43 transient_parent_(NULL), | 42 transient_parent_(NULL), |
44 id_(-1), | 43 id_(-1), |
45 user_data_(NULL), | 44 user_data_(NULL), |
46 stops_event_propagation_(false), | 45 stops_event_propagation_(false), |
47 ignore_events_(false) { | 46 ignore_events_(false) { |
48 } | 47 } |
49 | 48 |
50 Window::~Window() { | 49 Window::~Window() { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 87 |
89 void Window::Init(ui::Layer::LayerType layer_type) { | 88 void Window::Init(ui::Layer::LayerType layer_type) { |
90 layer_.reset(new ui::Layer(layer_type)); | 89 layer_.reset(new ui::Layer(layer_type)); |
91 layer_->SetVisible(false); | 90 layer_->SetVisible(false); |
92 layer_->set_delegate(this); | 91 layer_->set_delegate(this); |
93 UpdateLayerName(name_); | 92 UpdateLayerName(name_); |
94 | 93 |
95 RootWindow::GetInstance()->WindowInitialized(this); | 94 RootWindow::GetInstance()->WindowInitialized(this); |
96 } | 95 } |
97 | 96 |
98 void Window::SetType(WindowType type) { | 97 void Window::SetType(client::WindowType type) { |
99 // Cannot change type after the window is initialized. | 98 // Cannot change type after the window is initialized. |
100 DCHECK(!layer()); | 99 DCHECK(!layer()); |
101 type_ = type; | 100 type_ = type; |
102 } | 101 } |
103 | 102 |
104 void Window::SetName(const std::string& name) { | 103 void Window::SetName(const std::string& name) { |
105 name_ = name; | 104 name_ = name; |
106 | 105 |
107 if (layer()) | 106 if (layer()) |
108 UpdateLayerName(name_); | 107 UpdateLayerName(name_); |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 if (id_ != -1) { | 550 if (id_ != -1) { |
552 char id_buf[10]; | 551 char id_buf[10]; |
553 base::snprintf(id_buf, sizeof(id_buf), " %d", id_); | 552 base::snprintf(id_buf, sizeof(id_buf), " %d", id_); |
554 layer_name.append(id_buf); | 553 layer_name.append(id_buf); |
555 } | 554 } |
556 layer()->set_name(layer_name); | 555 layer()->set_name(layer_name); |
557 #endif | 556 #endif |
558 } | 557 } |
559 | 558 |
560 } // namespace aura | 559 } // namespace aura |
OLD | NEW |