#include "ozone/platform/ozone_platform_wayland.h"
+#include "base/at_exit.h"
+#include "base/bind.h"
#include "ozone/ui/cursor/cursor_factory_ozone_wayland.h"
#if defined(TOOLKIT_VIEWS) && !defined(OS_CHROMEOS)
#include "ozone/ui/desktop_aura/desktop_factory_wayland.h"
#endif
+#include "ozone/platform/ozone_wayland_window.h"
#include "ozone/ui/events/event_factory_ozone_wayland.h"
#include "ozone/ui/ime/input_method_context_factory_wayland.h"
#include "ozone/ui/public/ozone_channel.h"
#include "ozone/ui/public/ozone_channel_host.h"
#include "ozone/wayland/display.h"
-#include "ozone/wayland/proxy_display.h"
-#include "ui/ozone/ozone_platform.h"
+#include "ui/ozone/common/native_display_delegate_ozone.h"
+#include "ui/ozone/public/ozone_platform.h"
+#include "ui/platform_window/platform_window_delegate.h"
+
namespace ui {
// This platform is Linux with the Wayland display server.
class OzonePlatformWayland : public OzonePlatform {
public:
- OzonePlatformWayland() : wayland_proxy_display_(NULL) {}
+ OzonePlatformWayland() {
+ base::AtExitManager::RegisterTask(
+ base::Bind(&base::DeletePointer<OzonePlatformWayland>, this));
+ }
virtual ~OzonePlatformWayland() {
- delete wayland_proxy_display_;
}
// OzonePlatform:
- virtual ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE {
+ ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override {
return wayland_display_.get();
}
- virtual EventFactoryOzone* GetEventFactoryOzone() OVERRIDE {
- return event_factory_ozone_.get();
- }
- virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE {
+
+ CursorFactoryOzone* GetCursorFactoryOzone() override {
return cursor_factory_ozone_.get();
}
- virtual GpuPlatformSupportHost* GetGpuPlatformSupportHost() OVERRIDE {
+ GpuPlatformSupportHost* GetGpuPlatformSupportHost() override {
return gpu_platform_host_.get();
}
- virtual GpuPlatformSupport* GetGpuPlatformSupport() OVERRIDE {
+ GpuPlatformSupport* GetGpuPlatformSupport() override {
return gpu_platform_.get();
}
- virtual void InitializeUI() OVERRIDE {
+ scoped_ptr<PlatformWindow> CreatePlatformWindow(
+ PlatformWindowDelegate* delegate,
+ const gfx::Rect& bounds) override {
+ if (delegate) {
+ return scoped_ptr<PlatformWindow>(new OzoneWaylandWindow(delegate,
+ bounds));
+ } else {
+ // This is a hack to ensure we have the correct screen bounds at startup.
+ // DesktopFactroyWayland makes this call.
+ wayland_display_->LookAheadOutputGeometry();
+ return scoped_ptr<PlatformWindow>();
+ }
+ }
+
+ scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override {
+ return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateOzone());
+ }
+
+ void InitializeUI() override {
event_factory_ozone_.reset(
new ui::EventFactoryOzoneWayland());
gpu_platform_host_.reset(new ui::OzoneChannelHost());
+ // Needed as Browser creates accelerated widgets through SFO.
+ wayland_display_.reset(new ozonewayland::WaylandDisplay());
input_method_factory_.reset(
new ui::InputMethodContextFactoryWayland());
cursor_factory_ozone_.reset(new ui::CursorFactoryOzoneWayland());
- wayland_proxy_display_ = new ozonewayland::WaylandProxyDisplay();
}
- virtual void InitializeGPU() OVERRIDE {
+ void InitializeGPU() override {
gpu_platform_.reset(new ui::OzoneChannel());
if (!event_factory_ozone_) {
event_factory_ozone_.reset(new ui::EventFactoryOzoneWayland());
gpu_platform_.get()->InitializeRemoteDispatcher();
} else {
- // We don't need proxy display in case of Single process.
// TODO(kalyan): Find a better way to handle this.
gpu_platform_host_.get()->DeleteRemoteStateChangeHandler();
- delete wayland_proxy_display_;
- wayland_proxy_display_ = NULL;
}
- wayland_display_.reset(new ozonewayland::WaylandDisplay());
+ if (!wayland_display_)
+ wayland_display_.reset(new ozonewayland::WaylandDisplay());
+
+ if (!wayland_display_->InitializeHardware())
+ LOG(FATAL) << "failed to initialize display hardware";
}
private:
#if defined(TOOLKIT_VIEWS) && !defined(OS_CHROMEOS)
views::DesktopFactoryWayland desktop_factory_ozone_;
#endif
- ozonewayland::WaylandProxyDisplay* wayland_proxy_display_;
scoped_ptr<ui::InputMethodContextFactoryWayland> input_method_factory_;
scoped_ptr<ui::EventFactoryOzoneWayland> event_factory_ozone_;
scoped_ptr<ui::CursorFactoryOzoneWayland> cursor_factory_ozone_;