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_native_widget_aura.h" | 5 #include "ui/views/widget/desktop_native_widget_aura.h" |
6 | 6 |
7 #include "ui/aura/root_window_host.h" | |
7 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
8 #include "ui/base/hit_test.h" | 9 #include "ui/base/hit_test.h" |
10 #include "ui/compositor/layer.h" | |
9 #include "ui/views/widget/desktop_root_window_host.h" | 11 #include "ui/views/widget/desktop_root_window_host.h" |
10 | 12 |
11 namespace views { | 13 namespace views { |
12 | 14 |
13 //////////////////////////////////////////////////////////////////////////////// | 15 //////////////////////////////////////////////////////////////////////////////// |
14 // DesktopNativeWidgetAura, public: | 16 // DesktopNativeWidgetAura, public: |
15 | 17 |
16 DesktopNativeWidgetAura::DesktopNativeWidgetAura( | 18 DesktopNativeWidgetAura::DesktopNativeWidgetAura( |
17 internal::NativeWidgetDelegate* delegate) | 19 internal::NativeWidgetDelegate* delegate) |
18 : ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), | 20 : ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 | 63 |
62 gfx::NativeWindow DesktopNativeWidgetAura::GetNativeWindow() const { | 64 gfx::NativeWindow DesktopNativeWidgetAura::GetNativeWindow() const { |
63 return window_; | 65 return window_; |
64 } | 66 } |
65 | 67 |
66 Widget* DesktopNativeWidgetAura::GetTopLevelWidget() { | 68 Widget* DesktopNativeWidgetAura::GetTopLevelWidget() { |
67 return GetWidget(); | 69 return GetWidget(); |
68 } | 70 } |
69 | 71 |
70 const ui::Compositor* DesktopNativeWidgetAura::GetCompositor() const { | 72 const ui::Compositor* DesktopNativeWidgetAura::GetCompositor() const { |
71 return NULL; | 73 return window_->layer()->GetCompositor(); |
72 } | 74 } |
73 | 75 |
74 ui::Compositor* DesktopNativeWidgetAura::GetCompositor() { | 76 ui::Compositor* DesktopNativeWidgetAura::GetCompositor() { |
75 return NULL; | 77 return window_->layer()->GetCompositor(); |
76 } | 78 } |
77 | 79 |
78 void DesktopNativeWidgetAura::CalculateOffsetToAncestorWithLayer( | 80 void DesktopNativeWidgetAura::CalculateOffsetToAncestorWithLayer( |
79 gfx::Point* offset, | 81 gfx::Point* offset, |
80 ui::Layer** layer_parent) { | 82 ui::Layer** layer_parent) { |
81 } | 83 } |
82 | 84 |
83 void DesktopNativeWidgetAura::ViewRemoved(View* view) { | 85 void DesktopNativeWidgetAura::ViewRemoved(View* view) { |
84 } | 86 } |
85 | 87 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 } | 152 } |
151 | 153 |
152 void DesktopNativeWidgetAura::InitModalType(ui::ModalType modal_type) { | 154 void DesktopNativeWidgetAura::InitModalType(ui::ModalType modal_type) { |
153 } | 155 } |
154 | 156 |
155 gfx::Rect DesktopNativeWidgetAura::GetWindowBoundsInScreen() const { | 157 gfx::Rect DesktopNativeWidgetAura::GetWindowBoundsInScreen() const { |
156 return gfx::Rect(100, 100); | 158 return gfx::Rect(100, 100); |
157 } | 159 } |
158 | 160 |
159 gfx::Rect DesktopNativeWidgetAura::GetClientAreaBoundsInScreen() const { | 161 gfx::Rect DesktopNativeWidgetAura::GetClientAreaBoundsInScreen() const { |
160 return gfx::Rect(100, 100); | 162 return desktop_root_window_host_->GetClientAreaBoundsInScreen(); |
161 } | 163 } |
162 | 164 |
163 gfx::Rect DesktopNativeWidgetAura::GetRestoredBounds() const { | 165 gfx::Rect DesktopNativeWidgetAura::GetRestoredBounds() const { |
164 return gfx::Rect(100, 100); | 166 return gfx::Rect(100, 100); |
165 } | 167 } |
166 | 168 |
167 void DesktopNativeWidgetAura::SetBounds(const gfx::Rect& bounds) { | 169 void DesktopNativeWidgetAura::SetBounds(const gfx::Rect& bounds) { |
168 } | 170 } |
169 | 171 |
170 void DesktopNativeWidgetAura::SetSize(const gfx::Size& size) { | 172 void DesktopNativeWidgetAura::SetSize(const gfx::Size& size) { |
171 } | 173 } |
172 | 174 |
173 void DesktopNativeWidgetAura::StackAbove(gfx::NativeView native_view) { | 175 void DesktopNativeWidgetAura::StackAbove(gfx::NativeView native_view) { |
174 } | 176 } |
175 | 177 |
176 void DesktopNativeWidgetAura::StackAtTop() { | 178 void DesktopNativeWidgetAura::StackAtTop() { |
177 } | 179 } |
178 | 180 |
179 void DesktopNativeWidgetAura::StackBelow(gfx::NativeView native_view) { | 181 void DesktopNativeWidgetAura::StackBelow(gfx::NativeView native_view) { |
180 } | 182 } |
181 | 183 |
182 void DesktopNativeWidgetAura::SetShape(gfx::NativeRegion shape) { | 184 void DesktopNativeWidgetAura::SetShape(gfx::NativeRegion shape) { |
183 } | 185 } |
184 | 186 |
185 void DesktopNativeWidgetAura::Close() { | 187 void DesktopNativeWidgetAura::Close() { |
188 desktop_root_window_host_->Close(); | |
186 } | 189 } |
187 | 190 |
188 void DesktopNativeWidgetAura::CloseNow() { | 191 void DesktopNativeWidgetAura::CloseNow() { |
192 desktop_root_window_host_->CloseNow(); | |
189 } | 193 } |
190 | 194 |
191 void DesktopNativeWidgetAura::Show() { | 195 void DesktopNativeWidgetAura::Show() { |
196 desktop_root_window_host_->AsRootWindowHost()->Show(); | |
192 } | 197 } |
193 | 198 |
194 void DesktopNativeWidgetAura::Hide() { | 199 void DesktopNativeWidgetAura::Hide() { |
200 desktop_root_window_host_->AsRootWindowHost()->Hide(); | |
195 } | 201 } |
196 | 202 |
197 void DesktopNativeWidgetAura::ShowMaximizedWithBounds( | 203 void DesktopNativeWidgetAura::ShowMaximizedWithBounds( |
198 const gfx::Rect& restored_bounds) { | 204 const gfx::Rect& restored_bounds) { |
199 } | 205 } |
200 | 206 |
201 void DesktopNativeWidgetAura::ShowWithWindowState(ui::WindowShowState state) { | 207 void DesktopNativeWidgetAura::ShowWithWindowState(ui::WindowShowState state) { |
202 desktop_root_window_host_->ShowWindowWithState(state); | 208 desktop_root_window_host_->ShowWindowWithState(state); |
203 } | 209 } |
204 | 210 |
205 bool DesktopNativeWidgetAura::IsVisible() const { | 211 bool DesktopNativeWidgetAura::IsVisible() const { |
206 return false; | 212 return desktop_root_window_host_->IsVisible(); |
207 } | 213 } |
208 | 214 |
209 void DesktopNativeWidgetAura::Activate() { | 215 void DesktopNativeWidgetAura::Activate() { |
210 } | 216 } |
211 | 217 |
212 void DesktopNativeWidgetAura::Deactivate() { | 218 void DesktopNativeWidgetAura::Deactivate() { |
213 } | 219 } |
214 | 220 |
215 bool DesktopNativeWidgetAura::IsActive() const { | 221 bool DesktopNativeWidgetAura::IsActive() const { |
216 return true; | 222 return true; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
256 return false; | 262 return false; |
257 } | 263 } |
258 | 264 |
259 void DesktopNativeWidgetAura::RunShellDrag(View* view, | 265 void DesktopNativeWidgetAura::RunShellDrag(View* view, |
260 const ui::OSExchangeData& data, | 266 const ui::OSExchangeData& data, |
261 const gfx::Point& location, | 267 const gfx::Point& location, |
262 int operation) { | 268 int operation) { |
263 } | 269 } |
264 | 270 |
265 void DesktopNativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) { | 271 void DesktopNativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) { |
272 if (window_) | |
273 window_->SchedulePaintInRect(rect); | |
266 } | 274 } |
267 | 275 |
268 void DesktopNativeWidgetAura::SetCursor(gfx::NativeCursor cursor) { | 276 void DesktopNativeWidgetAura::SetCursor(gfx::NativeCursor cursor) { |
269 } | 277 } |
270 | 278 |
271 void DesktopNativeWidgetAura::ClearNativeFocus() { | 279 void DesktopNativeWidgetAura::ClearNativeFocus() { |
272 } | 280 } |
273 | 281 |
274 void DesktopNativeWidgetAura::FocusNativeView(gfx::NativeView native_view) { | 282 void DesktopNativeWidgetAura::FocusNativeView(gfx::NativeView native_view) { |
275 } | 283 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
362 } | 370 } |
363 | 371 |
364 //////////////////////////////////////////////////////////////////////////////// | 372 //////////////////////////////////////////////////////////////////////////////// |
365 // DesktopNativeWidgetAura, ui::EventHandler implementation: | 373 // DesktopNativeWidgetAura, ui::EventHandler implementation: |
366 | 374 |
367 ui::EventResult DesktopNativeWidgetAura::OnKeyEvent(ui::KeyEvent* event) { | 375 ui::EventResult DesktopNativeWidgetAura::OnKeyEvent(ui::KeyEvent* event) { |
368 return ui::ER_UNHANDLED; | 376 return ui::ER_UNHANDLED; |
369 } | 377 } |
370 | 378 |
371 ui::EventResult DesktopNativeWidgetAura::OnMouseEvent(ui::MouseEvent* event) { | 379 ui::EventResult DesktopNativeWidgetAura::OnMouseEvent(ui::MouseEvent* event) { |
372 return ui::ER_UNHANDLED; | 380 DCHECK(window_->IsVisible()); |
381 if (event->type() == ui::ET_MOUSEWHEEL) { | |
382 return native_widget_delegate_->OnMouseEvent(*event) ? | |
Peter Kasting
2012/09/07 22:32:15
Random drive-by nit: Can these delegate functions
| |
383 ui::ER_HANDLED : ui::ER_UNHANDLED; | |
384 } | |
385 | |
386 if (event->type() == ui::ET_SCROLL) { | |
387 if (native_widget_delegate_->OnMouseEvent(*event)) | |
388 return ui::ER_HANDLED; | |
389 | |
390 // Convert unprocessed scroll events into wheel events. | |
391 ui::MouseWheelEvent mwe(*static_cast<ui::ScrollEvent*>(event)); | |
392 return native_widget_delegate_->OnMouseEvent(mwe) ? | |
393 ui::ER_HANDLED : ui::ER_UNHANDLED; | |
394 } | |
395 return native_widget_delegate_->OnMouseEvent(*event) ? | |
396 ui::ER_HANDLED : ui::ER_UNHANDLED; | |
373 } | 397 } |
374 | 398 |
375 ui::TouchStatus DesktopNativeWidgetAura::OnTouchEvent(ui::TouchEvent* event) { | 399 ui::TouchStatus DesktopNativeWidgetAura::OnTouchEvent(ui::TouchEvent* event) { |
376 return ui::TOUCH_STATUS_UNKNOWN; | 400 return ui::TOUCH_STATUS_UNKNOWN; |
377 } | 401 } |
378 | 402 |
379 ui::EventResult DesktopNativeWidgetAura::OnGestureEvent( | 403 ui::EventResult DesktopNativeWidgetAura::OnGestureEvent( |
380 ui::GestureEvent* event) { | 404 ui::GestureEvent* event) { |
381 return ui::ER_UNHANDLED; | 405 return ui::ER_UNHANDLED; |
382 } | 406 } |
383 | 407 |
384 } // namespace views | 408 } // namespace views |
OLD | NEW |