OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/ozone/platform/ozonex/ozone_platform_ozonex.h" |
| 6 |
| 7 #include "ui/events/ozone/event_factory_ozone.cc" |
| 8 #include "ui/events/platform/x11/x11_event_source.h" |
| 9 #include "ui/gfx/ozone/surface_factory_ozone.h" |
| 10 #include "ui/gfx/x/x11_types.h" |
| 11 #include "ui/display/types/chromeos/native_display_delegate.h" |
| 12 |
| 13 #include "ui/window/platform_window.h" |
| 14 |
| 15 namespace ui { |
| 16 namespace { |
| 17 |
| 18 class StubPlatformWindowDelegate : public ui::PlatformWindowDelegate { |
| 19 public: |
| 20 virtual ~StubPlatformWindowDelegate() {} |
| 21 |
| 22 virtual void OnBoundsChanged(const gfx::Rect& new_bounds) OVERRIDE {} |
| 23 |
| 24 virtual void OnDamageRect(const gfx::Rect& damaged_region) OVERRIDE {} |
| 25 |
| 26 virtual void DispatchEvent(ui::Event* event) OVERRIDE {} |
| 27 |
| 28 virtual void OnCloseRequest() OVERRIDE {} |
| 29 virtual void OnClosed() OVERRIDE {} |
| 30 |
| 31 virtual void OnWindowStateChanged( |
| 32 ui::PlatformWindowState new_state) OVERRIDE {} |
| 33 |
| 34 virtual void OnLostCapture() OVERRIDE {} |
| 35 }; |
| 36 |
| 37 class XSurfaceFactory : public gfx::SurfaceFactoryOzone { |
| 38 public: |
| 39 virtual HardwareState InitializeHardware() OVERRIDE { return INITIALIZED; } |
| 40 |
| 41 virtual void ShutdownHardware() OVERRIDE {} |
| 42 |
| 43 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE { return 1; } |
| 44 |
| 45 virtual bool LoadEGLGLES2Bindings( |
| 46 AddGLLibraryCallback add_gl_library, |
| 47 SetGLGetProcAddressProcCallback set_gl_get_proc_address) OVERRIDE { |
| 48 return false; |
| 49 } |
| 50 }; |
| 51 |
| 52 class OzonePlatformOzoneX : public OzonePlatform { |
| 53 public: |
| 54 OzonePlatformOzoneX(); |
| 55 virtual ~OzonePlatformOzoneX(); |
| 56 |
| 57 virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE; |
| 58 virtual ui::EventFactoryOzone* GetEventFactoryOzone() OVERRIDE; |
| 59 virtual ui::InputMethodContextFactoryOzone* |
| 60 GetInputMethodContextFactoryOzone() OVERRIDE; |
| 61 virtual ui::CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE; |
| 62 #if defined(OS_CHROMEOS) |
| 63 virtual scoped_ptr<ui::NativeDisplayDelegate> CreateNativeDisplayDelegate() |
| 64 OVERRIDE; |
| 65 #endif |
| 66 |
| 67 private: |
| 68 scoped_ptr<PlatformEventSource> platform_event_source_; |
| 69 EventFactoryOzone event_factory_; |
| 70 scoped_ptr<PlatformWindow> platform_window_; |
| 71 |
| 72 DISALLOW_COPY_AND_ASSIGN(OzonePlatformOzoneX); |
| 73 }; |
| 74 |
| 75 OzonePlatformOzoneX::OzonePlatformOzoneX() |
| 76 : platform_event_source_(new X11EventSource(gfx::GetXDisplay())), |
| 77 platform_window_( |
| 78 ui::CreateDefaultPlatformWindow(new StubPlatformWindowDelegate())) { |
| 79 platform_window_->SetBounds(gfx::Rect(100, 200, 600, 800)); |
| 80 platform_window_->Show(); |
| 81 } |
| 82 |
| 83 OzonePlatformOzoneX::~OzonePlatformOzoneX() { |
| 84 } |
| 85 |
| 86 gfx::SurfaceFactoryOzone* OzonePlatformOzoneX::GetSurfaceFactoryOzone() { |
| 87 return new XSurfaceFactory(); |
| 88 } |
| 89 |
| 90 ui::EventFactoryOzone* OzonePlatformOzoneX::GetEventFactoryOzone() { |
| 91 LOG(ERROR) << "HERE"; |
| 92 return &event_factory_; |
| 93 } |
| 94 |
| 95 ui::InputMethodContextFactoryOzone* |
| 96 OzonePlatformOzoneX::GetInputMethodContextFactoryOzone() { |
| 97 return NULL; |
| 98 } |
| 99 |
| 100 ui::CursorFactoryOzone* OzonePlatformOzoneX::GetCursorFactoryOzone() { |
| 101 return NULL; |
| 102 } |
| 103 |
| 104 #if defined(OS_CHROMEOS) |
| 105 scoped_ptr<ui::NativeDisplayDelegate> |
| 106 OzonePlatformOzoneX::CreateNativeDisplayDelegate() { |
| 107 return scoped_ptr<ui::NativeDisplayDelegate>(); |
| 108 } |
| 109 #endif |
| 110 |
| 111 } // namespace |
| 112 |
| 113 OzonePlatform* CreateOzonePlatformOzonex() { |
| 114 return new OzonePlatformOzoneX(); |
| 115 } |
| 116 |
| 117 } // namespace ui |
OLD | NEW |