OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_tree_host_ozone.h" | 5 #include "ui/aura/window_tree_host_ozone.h" |
6 | 6 |
7 #include "ui/aura/window_event_dispatcher.h" | 7 #include "ui/aura/window_event_dispatcher.h" |
8 #include "ui/events/platform/platform_event_source.h" | |
9 #include "ui/ozone/public/cursor_factory_ozone.h" | 8 #include "ui/ozone/public/cursor_factory_ozone.h" |
10 #include "ui/ozone/public/event_factory_ozone.h" | 9 #include "ui/ozone/public/event_factory_ozone.h" |
11 #include "ui/ozone/public/surface_factory_ozone.h" | 10 #include "ui/ozone/public/ozone_platform.h" |
| 11 #include "ui/platform_window/platform_window.h" |
12 | 12 |
13 namespace aura { | 13 namespace aura { |
14 | 14 |
15 WindowTreeHostOzone::WindowTreeHostOzone(const gfx::Rect& bounds) | 15 WindowTreeHostOzone::WindowTreeHostOzone(const gfx::Rect& bounds) |
16 : widget_(0), | 16 : widget_(gfx::kNullAcceleratedWidget) { |
17 bounds_(bounds) { | 17 platform_window_ = |
18 ui::SurfaceFactoryOzone* surface_factory = | 18 ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds); |
19 ui::SurfaceFactoryOzone::GetInstance(); | |
20 widget_ = surface_factory->GetAcceleratedWidget(); | |
21 | |
22 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); | |
23 CreateCompositor(GetAcceleratedWidget()); | |
24 } | 19 } |
25 | 20 |
26 WindowTreeHostOzone::~WindowTreeHostOzone() { | 21 WindowTreeHostOzone::~WindowTreeHostOzone() { |
27 ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); | |
28 DestroyCompositor(); | 22 DestroyCompositor(); |
29 DestroyDispatcher(); | 23 DestroyDispatcher(); |
30 } | 24 } |
31 | 25 |
32 bool WindowTreeHostOzone::CanDispatchEvent(const ui::PlatformEvent& ne) { | 26 void WindowTreeHostOzone::OnBoundsChanged(const gfx::Rect& new_bounds) { |
33 CHECK(ne); | 27 // TOOD(spang): Should we determine which parts changed? |
34 ui::Event* event = static_cast<ui::Event*>(ne); | 28 OnHostResized(new_bounds.size()); |
35 if (event->IsMouseEvent() || event->IsScrollEvent()) | 29 OnHostMoved(new_bounds.origin()); |
36 return ui::CursorFactoryOzone::GetInstance()->GetCursorWindow() == widget_; | |
37 | |
38 return true; | |
39 } | 30 } |
40 | 31 |
41 uint32_t WindowTreeHostOzone::DispatchEvent(const ui::PlatformEvent& ne) { | 32 void WindowTreeHostOzone::OnDamageRect(const gfx::Rect& damaged_region) { |
42 ui::Event* event = static_cast<ui::Event*>(ne); | 33 } |
43 ui::EventDispatchDetails details ALLOW_UNUSED = SendEventToProcessor(event); | 34 |
44 return ui::POST_DISPATCH_STOP_PROPAGATION; | 35 void WindowTreeHostOzone::DispatchEvent(ui::Event* event) { |
| 36 SendEventToProcessor(event); |
| 37 } |
| 38 |
| 39 void WindowTreeHostOzone::OnCloseRequest() { |
| 40 OnHostCloseRequested(); |
| 41 } |
| 42 |
| 43 void WindowTreeHostOzone::OnClosed() { |
| 44 } |
| 45 |
| 46 void WindowTreeHostOzone::OnWindowStateChanged( |
| 47 ui::PlatformWindowState new_state) { |
| 48 } |
| 49 |
| 50 void WindowTreeHostOzone::OnLostCapture() { |
| 51 } |
| 52 |
| 53 void WindowTreeHostOzone::OnAcceleratedWidgetAvailable( |
| 54 gfx::AcceleratedWidget widget) { |
| 55 widget_ = widget; |
| 56 CreateCompositor(widget_); |
45 } | 57 } |
46 | 58 |
47 ui::EventSource* WindowTreeHostOzone::GetEventSource() { | 59 ui::EventSource* WindowTreeHostOzone::GetEventSource() { |
48 return this; | 60 return this; |
49 } | 61 } |
50 | 62 |
51 gfx::AcceleratedWidget WindowTreeHostOzone::GetAcceleratedWidget() { | 63 gfx::AcceleratedWidget WindowTreeHostOzone::GetAcceleratedWidget() { |
52 return widget_; | 64 return widget_; |
53 } | 65 } |
54 | 66 |
55 void WindowTreeHostOzone::Show() { NOTIMPLEMENTED(); } | 67 void WindowTreeHostOzone::Show() { |
| 68 platform_window_->Show(); |
| 69 } |
56 | 70 |
57 void WindowTreeHostOzone::Hide() { NOTIMPLEMENTED(); } | 71 void WindowTreeHostOzone::Hide() { |
| 72 platform_window_->Hide(); |
| 73 } |
58 | 74 |
59 gfx::Rect WindowTreeHostOzone::GetBounds() const { return bounds_; } | 75 gfx::Rect WindowTreeHostOzone::GetBounds() const { |
| 76 return platform_window_->GetBounds(); |
| 77 } |
60 | 78 |
61 void WindowTreeHostOzone::SetBounds(const gfx::Rect& bounds) { | 79 void WindowTreeHostOzone::SetBounds(const gfx::Rect& bounds) { |
62 bool origin_changed = bounds_.origin() != bounds.origin(); | 80 platform_window_->SetBounds(bounds); |
63 bool size_changed = bounds_.size() != bounds.size(); | |
64 bounds_ = bounds; | |
65 if (size_changed) | |
66 OnHostResized(bounds_.size()); | |
67 if (origin_changed) | |
68 OnHostMoved(bounds_.origin()); | |
69 } | 81 } |
70 | 82 |
71 gfx::Point WindowTreeHostOzone::GetLocationOnNativeScreen() const { | 83 gfx::Point WindowTreeHostOzone::GetLocationOnNativeScreen() const { |
72 return bounds_.origin(); | 84 return platform_window_->GetBounds().origin(); |
73 } | 85 } |
74 | 86 |
75 void WindowTreeHostOzone::SetCapture() { NOTIMPLEMENTED(); } | 87 void WindowTreeHostOzone::SetCapture() { |
| 88 platform_window_->SetCapture(); |
| 89 } |
76 | 90 |
77 void WindowTreeHostOzone::ReleaseCapture() { NOTIMPLEMENTED(); } | 91 void WindowTreeHostOzone::ReleaseCapture() { |
| 92 platform_window_->ReleaseCapture(); |
| 93 } |
78 | 94 |
79 void WindowTreeHostOzone::PostNativeEvent( | 95 void WindowTreeHostOzone::PostNativeEvent( |
80 const base::NativeEvent& native_event) { | 96 const base::NativeEvent& native_event) { |
81 NOTIMPLEMENTED(); | 97 NOTIMPLEMENTED(); |
82 } | 98 } |
83 | 99 |
84 void WindowTreeHostOzone::SetCursorNative(gfx::NativeCursor cursor) { | 100 void WindowTreeHostOzone::SetCursorNative(gfx::NativeCursor cursor) { |
85 ui::CursorFactoryOzone::GetInstance()->SetCursor(GetAcceleratedWidget(), | 101 ui::CursorFactoryOzone::GetInstance()->SetCursor(GetAcceleratedWidget(), |
86 cursor.platform()); | 102 cursor.platform()); |
87 } | 103 } |
(...skipping 16 matching lines...) Expand all Loading... |
104 return new WindowTreeHostOzone(bounds); | 120 return new WindowTreeHostOzone(bounds); |
105 } | 121 } |
106 | 122 |
107 // static | 123 // static |
108 gfx::Size WindowTreeHost::GetNativeScreenSize() { | 124 gfx::Size WindowTreeHost::GetNativeScreenSize() { |
109 NOTIMPLEMENTED(); | 125 NOTIMPLEMENTED(); |
110 return gfx::Size(); | 126 return gfx::Size(); |
111 } | 127 } |
112 | 128 |
113 } // namespace aura | 129 } // namespace aura |
OLD | NEW |