OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ozone/platform/dri/dri_window.h" | 5 #include "ui/ozone/platform/dri/dri_window.h" |
6 | 6 |
7 #include "ui/events/event.h" | 7 #include "ui/events/event.h" |
8 #include "ui/events/ozone/evdev/event_factory_evdev.h" | 8 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
9 #include "ui/events/platform/platform_event_source.h" | 9 #include "ui/events/platform/platform_event_source.h" |
10 #include "ui/ozone/platform/dri/dri_surface_factory.h" | 10 #include "ui/ozone/platform/dri/dri_window_delegate.h" |
| 11 #include "ui/ozone/platform/dri/dri_window_manager.h" |
11 #include "ui/ozone/public/cursor_factory_ozone.h" | 12 #include "ui/ozone/public/cursor_factory_ozone.h" |
12 #include "ui/ozone/public/surface_factory_ozone.h" | |
13 #include "ui/platform_window/platform_window_delegate.h" | 13 #include "ui/platform_window/platform_window_delegate.h" |
14 | 14 |
15 namespace ui { | 15 namespace ui { |
16 | 16 |
17 DriWindow::DriWindow(PlatformWindowDelegate* delegate, | 17 DriWindow::DriWindow(PlatformWindowDelegate* delegate, |
18 const gfx::Rect& bounds, | 18 const gfx::Rect& bounds, |
19 DriSurfaceFactory* surface_factory, | 19 scoped_ptr<DriWindowDelegate> dri_window_delegate, |
20 EventFactoryEvdev* event_factory) | 20 EventFactoryEvdev* event_factory, |
21 : delegate_(delegate), bounds_(bounds), event_factory_(event_factory) { | 21 DriWindowManager* window_manager) |
22 widget_ = surface_factory->GetAcceleratedWidget(); | 22 : delegate_(delegate), |
| 23 bounds_(bounds), |
| 24 widget_(dri_window_delegate->GetAcceleratedWidget()), |
| 25 dri_window_delegate_(dri_window_delegate.get()), |
| 26 event_factory_(event_factory), |
| 27 window_manager_(window_manager) { |
| 28 window_manager_->AddWindowDelegate(widget_, dri_window_delegate.Pass()); |
| 29 } |
| 30 |
| 31 DriWindow::~DriWindow() { |
| 32 PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); |
| 33 dri_window_delegate_->Shutdown(); |
| 34 window_manager_->RemoveWindowDelegate(widget_); |
| 35 } |
| 36 |
| 37 void DriWindow::Initialize() { |
| 38 dri_window_delegate_->Initialize(); |
| 39 dri_window_delegate_->OnBoundsChanged(bounds_); |
23 delegate_->OnAcceleratedWidgetAvailable(widget_); | 40 delegate_->OnAcceleratedWidgetAvailable(widget_); |
24 PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); | 41 PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); |
25 } | 42 } |
26 | 43 |
27 DriWindow::~DriWindow() { | |
28 PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); | |
29 } | |
30 | |
31 void DriWindow::Show() {} | 44 void DriWindow::Show() {} |
32 | 45 |
33 void DriWindow::Hide() {} | 46 void DriWindow::Hide() {} |
34 | 47 |
35 void DriWindow::Close() {} | 48 void DriWindow::Close() {} |
36 | 49 |
37 void DriWindow::SetBounds(const gfx::Rect& bounds) { | 50 void DriWindow::SetBounds(const gfx::Rect& bounds) { |
38 bounds_ = bounds; | 51 bounds_ = bounds; |
39 delegate_->OnBoundsChanged(bounds); | 52 delegate_->OnBoundsChanged(bounds); |
| 53 dri_window_delegate_->OnBoundsChanged(bounds); |
40 } | 54 } |
41 | 55 |
42 gfx::Rect DriWindow::GetBounds() { | 56 gfx::Rect DriWindow::GetBounds() { |
43 return bounds_; | 57 return bounds_; |
44 } | 58 } |
45 | 59 |
46 void DriWindow::SetCapture() {} | 60 void DriWindow::SetCapture() {} |
47 | 61 |
48 void DriWindow::ReleaseCapture() {} | 62 void DriWindow::ReleaseCapture() {} |
49 | 63 |
(...skipping 22 matching lines...) Expand all Loading... |
72 return true; | 86 return true; |
73 } | 87 } |
74 | 88 |
75 uint32_t DriWindow::DispatchEvent(const PlatformEvent& ne) { | 89 uint32_t DriWindow::DispatchEvent(const PlatformEvent& ne) { |
76 Event* event = static_cast<Event*>(ne); | 90 Event* event = static_cast<Event*>(ne); |
77 delegate_->DispatchEvent(event); | 91 delegate_->DispatchEvent(event); |
78 return POST_DISPATCH_STOP_PROPAGATION; | 92 return POST_DISPATCH_STOP_PROPAGATION; |
79 } | 93 } |
80 | 94 |
81 } // namespace ui | 95 } // namespace ui |
OLD | NEW |