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/widget/desktop_aura/desktop_native_widget_aura.h" | 5 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "ui/aura/client/activation_client.h" | 9 #include "ui/aura/client/activation_client.h" |
10 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 top_level_handler->top_level_widget_ = new Widget(); | 98 top_level_handler->top_level_widget_ = new Widget(); |
99 top_level_handler->top_level_widget_->Init(init_params); | 99 top_level_handler->top_level_widget_->Init(init_params); |
100 | 100 |
101 top_level_handler->top_level_widget_->SetFullscreen(full_screen); | 101 top_level_handler->top_level_widget_->SetFullscreen(full_screen); |
102 top_level_handler->top_level_widget_->Show(); | 102 top_level_handler->top_level_widget_->Show(); |
103 | 103 |
104 aura::Window* native_window = | 104 aura::Window* native_window = |
105 top_level_handler->top_level_widget_->GetNativeView(); | 105 top_level_handler->top_level_widget_->GetNativeView(); |
106 child_window->AddObserver(top_level_handler); | 106 child_window->AddObserver(top_level_handler); |
107 native_window->AddObserver(top_level_handler); | 107 native_window->AddObserver(top_level_handler); |
| 108 top_level_handler->child_window_ = child_window; |
108 return native_window; | 109 return native_window; |
109 } | 110 } |
110 | 111 |
111 // aura::WindowObserver overrides | 112 // aura::WindowObserver overrides |
112 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE { | 113 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE { |
113 window->RemoveObserver(this); | 114 window->RemoveObserver(this); |
114 | 115 |
115 // If the widget is being destroyed by the OS then we should not try and | 116 // If the widget is being destroyed by the OS then we should not try and |
116 // destroy it again. | 117 // destroy it again. |
117 if (top_level_widget_ && | 118 if (top_level_widget_ && |
118 window == top_level_widget_->GetNativeView()) { | 119 window == top_level_widget_->GetNativeView()) { |
119 top_level_widget_ = NULL; | 120 top_level_widget_ = NULL; |
120 return; | 121 return; |
121 } | 122 } |
122 | 123 |
123 if (top_level_widget_) { | 124 if (top_level_widget_) { |
124 DCHECK(top_level_widget_->GetNativeView()); | 125 DCHECK(top_level_widget_->GetNativeView()); |
125 top_level_widget_->GetNativeView()->RemoveObserver(this); | 126 top_level_widget_->GetNativeView()->RemoveObserver(this); |
126 // When we receive a notification that the child of the window created | 127 // When we receive a notification that the child of the window created |
127 // above is being destroyed we go ahead and initiate the destruction of | 128 // above is being destroyed we go ahead and initiate the destruction of |
128 // the corresponding widget. | 129 // the corresponding widget. |
129 top_level_widget_->Close(); | 130 top_level_widget_->Close(); |
130 top_level_widget_ = NULL; | 131 top_level_widget_ = NULL; |
131 } | 132 } |
132 delete this; | 133 delete this; |
133 } | 134 } |
134 | 135 |
| 136 virtual void OnWindowBoundsChanged(aura::Window* window, |
| 137 const gfx::Rect& old_bounds, |
| 138 const gfx::Rect& new_bounds) OVERRIDE { |
| 139 if (top_level_widget_ && window == child_window_) |
| 140 top_level_widget_->SetSize(new_bounds.size()); |
| 141 } |
| 142 |
135 private: | 143 private: |
136 DesktopNativeWidgetTopLevelHandler() | 144 DesktopNativeWidgetTopLevelHandler() |
137 : top_level_widget_(NULL) {} | 145 : top_level_widget_(NULL), |
| 146 child_window_(NULL) {} |
138 | 147 |
139 virtual ~DesktopNativeWidgetTopLevelHandler() {} | 148 virtual ~DesktopNativeWidgetTopLevelHandler() {} |
140 | 149 |
141 Widget* top_level_widget_; | 150 Widget* top_level_widget_; |
| 151 aura::Window* child_window_; |
142 | 152 |
143 DISALLOW_COPY_AND_ASSIGN(DesktopNativeWidgetTopLevelHandler); | 153 DISALLOW_COPY_AND_ASSIGN(DesktopNativeWidgetTopLevelHandler); |
144 }; | 154 }; |
145 | 155 |
146 class DesktopNativeWidgetAuraWindowTreeClient : | 156 class DesktopNativeWidgetAuraWindowTreeClient : |
147 public aura::client::WindowTreeClient { | 157 public aura::client::WindowTreeClient { |
148 public: | 158 public: |
149 explicit DesktopNativeWidgetAuraWindowTreeClient( | 159 explicit DesktopNativeWidgetAuraWindowTreeClient( |
150 aura::Window* root_window) | 160 aura::Window* root_window) |
151 : root_window_(root_window) { | 161 : root_window_(root_window) { |
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1116 input_method_event_filter_->SetInputMethodPropertyInRootWindow( | 1126 input_method_event_filter_->SetInputMethodPropertyInRootWindow( |
1117 root_window_->window()); | 1127 root_window_->window()); |
1118 root_window_event_filter_->AddHandler(input_method_event_filter_.get()); | 1128 root_window_event_filter_->AddHandler(input_method_event_filter_.get()); |
1119 } | 1129 } |
1120 | 1130 |
1121 void DesktopNativeWidgetAura::UpdateWindowTransparency() { | 1131 void DesktopNativeWidgetAura::UpdateWindowTransparency() { |
1122 content_window_->SetTransparent(ShouldUseNativeFrame()); | 1132 content_window_->SetTransparent(ShouldUseNativeFrame()); |
1123 } | 1133 } |
1124 | 1134 |
1125 } // namespace views | 1135 } // namespace views |
OLD | NEW |