OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/caca/ozone_platform_caca.h" | 5 #include "ui/ozone/platform/x11/ozone_platform_x11.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include <utility> |
8 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" | 8 |
9 #include "ui/events/ozone/layout/no/no_keyboard_layout_engine.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" |
| 11 #include "ui/events/platform/x11/x11_event_source_libevent.h" |
10 #include "ui/ozone/common/native_display_delegate_ozone.h" | 12 #include "ui/ozone/common/native_display_delegate_ozone.h" |
11 #include "ui/ozone/common/stub_overlay_manager.h" | 13 #include "ui/ozone/common/stub_overlay_manager.h" |
12 #include "ui/ozone/platform/caca/caca_event_source.h" | 14 #include "ui/ozone/platform/x11/x11_surface_factory.h" |
13 #include "ui/ozone/platform/caca/caca_window.h" | |
14 #include "ui/ozone/platform/caca/caca_window_manager.h" | |
15 #include "ui/ozone/public/cursor_factory_ozone.h" | |
16 #include "ui/ozone/public/gpu_platform_support.h" | 15 #include "ui/ozone/public/gpu_platform_support.h" |
17 #include "ui/ozone/public/gpu_platform_support_host.h" | 16 #include "ui/ozone/public/gpu_platform_support_host.h" |
18 #include "ui/ozone/public/input_controller.h" | 17 #include "ui/ozone/public/input_controller.h" |
19 #include "ui/ozone/public/ozone_platform.h" // nogncheck | 18 #include "ui/ozone/public/ozone_platform.h" // nogncheck |
20 #include "ui/ozone/public/system_input_injector.h" | 19 #include "ui/ozone/public/system_input_injector.h" |
| 20 #include "ui/platform_window/x11/x11_window_ozone.h" |
21 | 21 |
22 namespace ui { | 22 namespace ui { |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 class OzonePlatformCaca : public OzonePlatform { | 26 // Singleton OzonePlatform implementation for Linux X11 platform. |
| 27 class OzonePlatformX11 : public OzonePlatform { |
27 public: | 28 public: |
28 OzonePlatformCaca() {} | 29 OzonePlatformX11() {} |
29 ~OzonePlatformCaca() override {} | 30 ~OzonePlatformX11() override {} |
30 | 31 |
31 // OzonePlatform: | 32 // OzonePlatform: |
32 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { | 33 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { |
33 return window_manager_.get(); | 34 return surface_factory_ozone_.get(); |
34 } | 35 } |
35 OverlayManagerOzone* GetOverlayManager() override { | 36 |
| 37 ui::OverlayManagerOzone* GetOverlayManager() override { |
36 return overlay_manager_.get(); | 38 return overlay_manager_.get(); |
37 } | 39 } |
| 40 |
38 CursorFactoryOzone* GetCursorFactoryOzone() override { | 41 CursorFactoryOzone* GetCursorFactoryOzone() override { |
39 return cursor_factory_ozone_.get(); | 42 return cursor_factory_ozone_.get(); |
40 } | 43 } |
| 44 |
| 45 scoped_ptr<SystemInputInjector> CreateSystemInputInjector() override { |
| 46 return nullptr; |
| 47 } |
| 48 |
41 InputController* GetInputController() override { | 49 InputController* GetInputController() override { |
42 return input_controller_.get(); | 50 return input_controller_.get(); |
43 } | 51 } |
| 52 |
44 GpuPlatformSupport* GetGpuPlatformSupport() override { | 53 GpuPlatformSupport* GetGpuPlatformSupport() override { |
45 return gpu_platform_support_.get(); | 54 return gpu_platform_support_.get(); |
46 } | 55 } |
| 56 |
47 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { | 57 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { |
48 return gpu_platform_support_host_.get(); | 58 return gpu_platform_support_host_.get(); |
49 } | 59 } |
50 scoped_ptr<SystemInputInjector> CreateSystemInputInjector() override { | 60 |
51 return nullptr; // no input injection support. | |
52 } | |
53 scoped_ptr<PlatformWindow> CreatePlatformWindow( | 61 scoped_ptr<PlatformWindow> CreatePlatformWindow( |
54 PlatformWindowDelegate* delegate, | 62 PlatformWindowDelegate* delegate, |
55 const gfx::Rect& bounds) override { | 63 const gfx::Rect& bounds) override { |
56 scoped_ptr<CacaWindow> caca_window(new CacaWindow( | 64 scoped_ptr<X11WindowOzone> window = |
57 delegate, window_manager_.get(), event_source_.get(), bounds)); | 65 make_scoped_ptr(new X11WindowOzone(delegate)); |
58 if (!caca_window->Initialize()) | 66 window->SetBounds(bounds); |
59 return nullptr; | 67 window->Create(); |
60 return std::move(caca_window); | 68 return std::move(window); |
61 } | 69 } |
| 70 |
62 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override { | 71 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override { |
63 return make_scoped_ptr(new NativeDisplayDelegateOzone()); | 72 return make_scoped_ptr(new NativeDisplayDelegateOzone()); |
64 } | 73 } |
| 74 |
65 base::ScopedFD OpenClientNativePixmapDevice() const override { | 75 base::ScopedFD OpenClientNativePixmapDevice() const override { |
66 return base::ScopedFD(); | 76 return base::ScopedFD(); |
67 } | 77 } |
68 | 78 |
69 void InitializeUI() override { | 79 void InitializeUI() override { |
70 window_manager_.reset(new CacaWindowManager); | 80 event_source_.reset(new X11EventSourceLibevent(gfx::GetXDisplay())); |
| 81 surface_factory_ozone_.reset(new X11SurfaceFactory()); |
71 overlay_manager_.reset(new StubOverlayManager()); | 82 overlay_manager_.reset(new StubOverlayManager()); |
72 event_source_.reset(new CacaEventSource()); | 83 input_controller_ = CreateStubInputController(); |
73 cursor_factory_ozone_.reset(new CursorFactoryOzone()); | 84 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); |
74 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); | 85 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); |
75 input_controller_ = CreateStubInputController(); | |
76 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( | |
77 make_scoped_ptr(new NoKeyboardLayoutEngine())); | |
78 } | 86 } |
79 | 87 |
80 void InitializeGPU() override { | 88 void InitializeGPU() override { |
| 89 surface_factory_ozone_.reset(new X11SurfaceFactory()); |
81 gpu_platform_support_.reset(CreateStubGpuPlatformSupport()); | 90 gpu_platform_support_.reset(CreateStubGpuPlatformSupport()); |
82 } | 91 } |
83 | 92 |
84 private: | 93 private: |
85 scoped_ptr<CacaWindowManager> window_manager_; | 94 // Objects in the Browser process. |
86 scoped_ptr<CacaEventSource> event_source_; | 95 scoped_ptr<X11EventSourceLibevent> event_source_; |
87 scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_; | 96 scoped_ptr<OverlayManagerOzone> overlay_manager_; |
| 97 scoped_ptr<InputController> input_controller_; |
| 98 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_; |
| 99 scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_; |
| 100 |
| 101 // Objects in the GPU process. |
88 scoped_ptr<GpuPlatformSupport> gpu_platform_support_; | 102 scoped_ptr<GpuPlatformSupport> gpu_platform_support_; |
89 scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_; | |
90 scoped_ptr<InputController> input_controller_; | |
91 scoped_ptr<OverlayManagerOzone> overlay_manager_; | |
92 | 103 |
93 DISALLOW_COPY_AND_ASSIGN(OzonePlatformCaca); | 104 // Objects in both Browser and GPU process. |
| 105 scoped_ptr<X11SurfaceFactory> surface_factory_ozone_; |
| 106 |
| 107 DISALLOW_COPY_AND_ASSIGN(OzonePlatformX11); |
94 }; | 108 }; |
95 | 109 |
96 } // namespace | 110 } // namespace |
97 | 111 |
98 OzonePlatform* CreateOzonePlatformCaca() { | 112 OzonePlatform* CreateOzonePlatformX11() { |
99 return new OzonePlatformCaca; | 113 return new OzonePlatformX11; |
100 } | 114 } |
101 | 115 |
102 } // namespace ui | 116 } // namespace ui |
OLD | NEW |