| 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.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<X11Window> window = make_scoped_ptr(new X11Window(delegate)); |
| 57 delegate, window_manager_.get(), event_source_.get(), bounds)); | 65 window->SetBounds(bounds); |
| 58 if (!caca_window->Initialize()) | 66 window->Create(); |
| 59 return nullptr; | 67 return std::move(window); |
| 60 return std::move(caca_window); | |
| 61 } | 68 } |
| 69 |
| 62 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override { | 70 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override { |
| 63 return make_scoped_ptr(new NativeDisplayDelegateOzone()); | 71 return make_scoped_ptr(new NativeDisplayDelegateOzone()); |
| 64 } | 72 } |
| 73 |
| 65 base::ScopedFD OpenClientNativePixmapDevice() const override { | 74 base::ScopedFD OpenClientNativePixmapDevice() const override { |
| 66 return base::ScopedFD(); | 75 return base::ScopedFD(); |
| 67 } | 76 } |
| 68 | 77 |
| 69 void InitializeUI() override { | 78 void InitializeUI() override { |
| 70 window_manager_.reset(new CacaWindowManager); | 79 event_source_.reset(new X11EventSourceLibevent(gfx::GetXDisplay())); |
| 80 surface_factory_ozone_.reset(new X11SurfaceFactory()); |
| 71 overlay_manager_.reset(new StubOverlayManager()); | 81 overlay_manager_.reset(new StubOverlayManager()); |
| 72 event_source_.reset(new CacaEventSource()); | 82 input_controller_ = CreateStubInputController(); |
| 73 cursor_factory_ozone_.reset(new CursorFactoryOzone()); | 83 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); |
| 74 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); | 84 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); |
| 75 input_controller_ = CreateStubInputController(); | |
| 76 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( | |
| 77 make_scoped_ptr(new NoKeyboardLayoutEngine())); | |
| 78 } | 85 } |
| 79 | 86 |
| 80 void InitializeGPU() override { | 87 void InitializeGPU() override { |
| 88 surface_factory_ozone_.reset(new X11SurfaceFactory()); |
| 81 gpu_platform_support_.reset(CreateStubGpuPlatformSupport()); | 89 gpu_platform_support_.reset(CreateStubGpuPlatformSupport()); |
| 82 } | 90 } |
| 83 | 91 |
| 84 private: | 92 private: |
| 85 scoped_ptr<CacaWindowManager> window_manager_; | 93 // Objects in the Browser process. |
| 86 scoped_ptr<CacaEventSource> event_source_; | 94 scoped_ptr<X11EventSourceLibevent> event_source_; |
| 87 scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_; | 95 scoped_ptr<OverlayManagerOzone> overlay_manager_; |
| 96 scoped_ptr<InputController> input_controller_; |
| 97 scoped_ptr<BitmapCursorFactoryOzone> cursor_factory_ozone_; |
| 98 scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_; |
| 99 |
| 100 // Objects in the GPU process. |
| 88 scoped_ptr<GpuPlatformSupport> gpu_platform_support_; | 101 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 | 102 |
| 93 DISALLOW_COPY_AND_ASSIGN(OzonePlatformCaca); | 103 // Objects in both Browser and GPU process. |
| 104 scoped_ptr<X11SurfaceFactory> surface_factory_ozone_; |
| 105 |
| 106 DISALLOW_COPY_AND_ASSIGN(OzonePlatformX11); |
| 94 }; | 107 }; |
| 95 | 108 |
| 96 } // namespace | 109 } // namespace |
| 97 | 110 |
| 98 OzonePlatform* CreateOzonePlatformCaca() { | 111 OzonePlatform* CreateOzonePlatformX11() { |
| 99 return new OzonePlatformCaca; | 112 return new OzonePlatformX11; |
| 100 } | 113 } |
| 101 | 114 |
| 102 } // namespace ui | 115 } // namespace ui |
| OLD | NEW |