Index: services/native_viewport/platform_viewport_ozone.cc |
diff --git a/services/native_viewport/platform_viewport_x11.cc b/services/native_viewport/platform_viewport_ozone.cc |
similarity index 59% |
copy from services/native_viewport/platform_viewport_x11.cc |
copy to services/native_viewport/platform_viewport_ozone.cc |
index d45215085cebfb319776115d44dadcebeb888ead..69cba34157d6890f6fb026d07772b38abdc0c2fd 100644 |
--- a/services/native_viewport/platform_viewport_x11.cc |
+++ b/services/native_viewport/platform_viewport_ozone.cc |
@@ -1,22 +1,20 @@ |
-// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
#include "services/native_viewport/platform_viewport.h" |
-#include "base/command_line.h" |
-#include "base/message_loop/message_loop.h" |
#include "mojo/converters/geometry/geometry_type_converters.h" |
#include "mojo/converters/input_events/input_events_type_converters.h" |
#include "mojo/converters/input_events/mojo_extended_key_event_data.h" |
#include "ui/events/event.h" |
-#include "ui/events/event_utils.h" |
#include "ui/events/platform/platform_event_dispatcher.h" |
#include "ui/events/platform/platform_event_source.h" |
-#include "ui/gfx/rect.h" |
+#include "ui/ozone/public/cursor_factory_ozone.h" |
+#include "ui/ozone/public/ozone_platform.h" |
+#include "ui/ozone/public/surface_factory_ozone.h" |
#include "ui/platform_window/platform_window.h" |
#include "ui/platform_window/platform_window_delegate.h" |
-#include "ui/platform_window/x11/x11_window.h" |
namespace native_viewport { |
namespace { |
@@ -31,12 +29,16 @@ float ConvertUIWheelValueToMojoValue(int offset) { |
} |
} // namespace |
-class PlatformViewportX11 : public PlatformViewport, |
- public ui::PlatformWindowDelegate { |
+// TODO(spang): Deduplicate with PlatformViewportX11.. but there's a hack |
+// in there that prevents this. |
+class PlatformViewportOzone : public PlatformViewport, |
+ public ui::PlatformWindowDelegate { |
public: |
- explicit PlatformViewportX11(Delegate* delegate) : delegate_(delegate) {} |
+ explicit PlatformViewportOzone(Delegate* delegate) : delegate_(delegate) { |
+ ui::OzonePlatform::InitializeForUI(); |
+ } |
- ~PlatformViewportX11() override { |
+ ~PlatformViewportOzone() override { |
// Destroy the platform-window while |this| is still alive. |
platform_window_.reset(); |
} |
@@ -44,16 +46,11 @@ class PlatformViewportX11 : public PlatformViewport, |
private: |
// Overridden from PlatformViewport: |
void Init(const gfx::Rect& bounds) override { |
- CHECK(!event_source_); |
- CHECK(!platform_window_); |
- |
- event_source_ = ui::PlatformEventSource::CreateDefault(); |
+ platform_window_ = |
+ ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds); |
metrics_ = mojo::ViewportMetrics::New(); |
metrics_->size = mojo::Size::From(bounds.size()); |
- |
- platform_window_.reset(new ui::X11Window(this)); |
- platform_window_->SetBounds(bounds); |
} |
void Show() override { platform_window_->Show(); } |
@@ -62,7 +59,9 @@ class PlatformViewportX11 : public PlatformViewport, |
void Close() override { platform_window_->Close(); } |
- gfx::Size GetSize() override { return metrics_->size.To<gfx::Size>(); } |
+ gfx::Size GetSize() override { |
+ return platform_window_->GetBounds().size(); |
+ } |
void SetBounds(const gfx::Rect& bounds) override { |
platform_window_->SetBounds(bounds); |
@@ -103,37 +102,6 @@ class PlatformViewportX11 : public PlatformViewport, |
default: |
break; |
} |
- |
- // We want to emulate the WM_CHAR generation behaviour of Windows. |
- // |
- // On Linux, we've previously inserted characters by having |
- // InputMethodAuraLinux take all key down events and send a character event |
- // to the TextInputClient. This causes a mismatch in code that has to be |
- // shared between Windows and Linux, including blink code. Now that we're |
- // trying to have one way of doing things, we need to standardize on and |
- // emulate Windows character events. |
- // |
- // This is equivalent to what we're doing in the current Linux port, but |
- // done once instead of done multiple times in different places. |
- if (event->type() == ui::ET_KEY_PRESSED) { |
- ui::KeyEvent* key_press_event = static_cast<ui::KeyEvent*>(event); |
- ui::KeyEvent char_event(key_press_event->GetCharacter(), |
- key_press_event->key_code(), |
- key_press_event->flags()); |
- |
- DCHECK_EQ(key_press_event->GetCharacter(), char_event.GetCharacter()); |
- DCHECK_EQ(key_press_event->key_code(), char_event.key_code()); |
- DCHECK_EQ(key_press_event->flags(), char_event.flags()); |
- |
- char_event.SetExtendedKeyEventData( |
- make_scoped_ptr(new mojo::MojoExtendedKeyEventData( |
- key_press_event->GetLocatedWindowsKeyboardCode(), |
- key_press_event->GetText(), |
- key_press_event->GetUnmodifiedText()))); |
- char_event.set_platform_keycode(key_press_event->platform_keycode()); |
- |
- delegate_->OnEvent(mojo::Event::From(char_event)); |
- } |
} |
void OnCloseRequest() override { platform_window_->Close(); } |
@@ -150,19 +118,19 @@ class PlatformViewportX11 : public PlatformViewport, |
void OnActivationChanged(bool active) override {} |
- scoped_ptr<ui::PlatformEventSource> event_source_; |
scoped_ptr<ui::PlatformWindow> platform_window_; |
Delegate* delegate_; |
mojo::ViewportMetricsPtr metrics_; |
- DISALLOW_COPY_AND_ASSIGN(PlatformViewportX11); |
+ DISALLOW_COPY_AND_ASSIGN(PlatformViewportOzone); |
}; |
// static |
scoped_ptr<PlatformViewport> PlatformViewport::Create( |
mojo::ApplicationImpl* application_, |
Delegate* delegate) { |
- return make_scoped_ptr(new PlatformViewportX11(delegate)); |
+ return scoped_ptr<PlatformViewport>( |
+ new PlatformViewportOzone(delegate)).Pass(); |
} |
} // namespace native_viewport |