Commit 73963960 authored by Sergey Ulanov's avatar Sergey Ulanov Committed by Commit Bot

Pass PlatformWindowInitProperties by value instead of const-ref.

Previously PlatformWindowInitProperties was passed to Ozone platform
implementations as a const reference. This doesn't allow to pass movable
parameters (e.g. handles) when creating platform windows. On Fuchsia it
is necessary to pass view_owner_request when creating a view.
view_owner_request wraps an handle, so it's not copyable. Updated all
code that works with PlatformWindowInitProperties to pass it by value.

Also updated DesktopWindowTreeHostPlatform to default to POPUP window
type for any widget types other then WINDOW and MENU.

Bug: 829980
Change-Id: I34c7a8fe957f364833a5e4eafd272794eec99b56
Reviewed-on: https://chromium-review.googlesource.com/1103223Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568153}
parent 244b51b2
......@@ -63,8 +63,8 @@ std::unique_ptr<PlatformWindow> PlatformDisplay::CreatePlatformWindow(
#elif defined(USE_OZONE)
ui::PlatformWindowInitProperties properties;
properties.bounds = bounds;
platform_window =
OzonePlatform::GetInstance()->CreatePlatformWindow(delegate, properties);
platform_window = OzonePlatform::GetInstance()->CreatePlatformWindow(
delegate, std::move(properties));
#else
NOTREACHED() << "Unsupported platform";
#endif
......
......@@ -51,7 +51,7 @@ WindowTreeHostPlatform::WindowTreeHostPlatform(const gfx::Rect& bounds)
ui::PlatformWindowInitProperties properties;
properties.bounds = bounds_;
CreateAndSetPlatformWindow(properties);
CreateAndSetPlatformWindow(std::move(properties));
}
WindowTreeHostPlatform::WindowTreeHostPlatform()
......@@ -64,10 +64,10 @@ WindowTreeHostPlatform::WindowTreeHostPlatform(
current_cursor_(ui::CursorType::kNull) {}
void WindowTreeHostPlatform::CreateAndSetPlatformWindow(
const ui::PlatformWindowInitProperties& properties) {
ui::PlatformWindowInitProperties properties) {
#if defined(USE_OZONE)
platform_window_ =
ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, properties);
platform_window_ = ui::OzonePlatform::GetInstance()->CreatePlatformWindow(
this, std::move(properties));
#elif defined(OS_WIN)
platform_window_.reset(new ui::WinWindow(this, properties.bounds));
#elif defined(OS_ANDROID)
......
......@@ -58,8 +58,7 @@ class AURA_EXPORT WindowTreeHostPlatform : public WindowTreeHost,
// Creates a ui::PlatformWindow appropriate for the current platform and
// installs it at as the PlatformWindow for this WindowTreeHostPlatform.
void CreateAndSetPlatformWindow(
const ui::PlatformWindowInitProperties& properties);
void CreateAndSetPlatformWindow(ui::PlatformWindowInitProperties properties);
void SetPlatformWindow(std::unique_ptr<ui::PlatformWindow> window);
ui::PlatformWindow* platform_window() { return platform_window_.get(); }
......
......@@ -96,7 +96,7 @@ void TestCompositorHostOzone::Show() {
properties.bounds = bounds_;
// Create a PlatformWindow to get the AcceleratedWidget backing it.
window_ = ui::OzonePlatform::GetInstance()->CreatePlatformWindow(
&window_delegate_, properties);
&window_delegate_, std::move(properties));
window_->Show();
DCHECK_NE(window_delegate_.widget(), gfx::kNullAcceleratedWidget);
......
......@@ -24,8 +24,8 @@ DemoWindow::DemoWindow(WindowManager* window_manager,
weak_ptr_factory_(this) {
PlatformWindowInitProperties properties;
properties.bounds = bounds;
platform_window_ =
OzonePlatform::GetInstance()->CreatePlatformWindow(this, properties);
platform_window_ = OzonePlatform::GetInstance()->CreatePlatformWindow(
this, std::move(properties));
platform_window_->Show();
}
......
......@@ -93,7 +93,7 @@ class OzonePlatformCast : public OzonePlatform {
}
std::unique_ptr<PlatformWindow> CreatePlatformWindow(
PlatformWindowDelegate* delegate,
const PlatformWindowInitProperties& properties) override {
PlatformWindowInitProperties properties) override {
return base::WrapUnique<PlatformWindow>(
new PlatformWindowCast(delegate, properties.bounds));
}
......
......@@ -160,7 +160,7 @@ class OzonePlatformGbm : public OzonePlatform {
std::unique_ptr<PlatformWindow> CreatePlatformWindow(
PlatformWindowDelegate* delegate,
const PlatformWindowInitProperties& properties) override {
PlatformWindowInitProperties properties) override {
GpuThreadAdapter* adapter = gpu_platform_support_host_.get();
if (using_mojo_) {
adapter = host_drm_device_.get();
......
......@@ -68,7 +68,7 @@ class OzonePlatformHeadless : public OzonePlatform {
}
std::unique_ptr<PlatformWindow> CreatePlatformWindow(
PlatformWindowDelegate* delegate,
const PlatformWindowInitProperties& properties) override {
PlatformWindowInitProperties properties) override {
return std::make_unique<HeadlessWindow>(delegate, window_manager_.get(),
properties.bounds);
}
......
......@@ -23,6 +23,7 @@
#include "ui/ozone/public/input_controller.h"
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/ozone_switches.h"
#include "ui/platform_window/platform_window_init_properties.h"
namespace ui {
......@@ -73,7 +74,7 @@ class OzonePlatformScenic : public OzonePlatform {
std::unique_ptr<PlatformWindow> CreatePlatformWindow(
PlatformWindowDelegate* delegate,
const PlatformWindowInitProperties& properties) override {
PlatformWindowInitProperties properties) override {
NOTREACHED();
return nullptr;
}
......
......@@ -62,9 +62,9 @@ class OzonePlatformWayland : public OzonePlatform {
std::unique_ptr<PlatformWindow> CreatePlatformWindow(
PlatformWindowDelegate* delegate,
const PlatformWindowInitProperties& properties) override {
PlatformWindowInitProperties properties) override {
auto window = std::make_unique<WaylandWindow>(delegate, connection_.get());
if (!window->Initialize(properties))
if (!window->Initialize(std::move(properties)))
return nullptr;
return std::move(window);
}
......
......@@ -51,7 +51,7 @@ TEST_P(WaylandPointerTest, Leave) {
PlatformWindowInitProperties properties;
properties.bounds = gfx::Rect(0, 0, 10, 10);
properties.type = PlatformWindowType::PLATFORM_WINDOW_TYPE_WINDOW;
ASSERT_TRUE(other_window.Initialize(properties));
ASSERT_TRUE(other_window.Initialize(std::move(properties)));
ASSERT_NE(other_widget, gfx::kNullAcceleratedWidget);
Sync();
......
......@@ -42,7 +42,7 @@ void WaylandTest::SetUp() {
PlatformWindowInitProperties properties;
properties.bounds = gfx::Rect(0, 0, 800, 600);
properties.type = PlatformWindowType::PLATFORM_WINDOW_TYPE_WINDOW;
ASSERT_TRUE(window_->Initialize(properties));
ASSERT_TRUE(window_->Initialize(std::move(properties)));
ASSERT_NE(widget_, gfx::kNullAcceleratedWidget);
// Wait for the client to flush all pending requests from initialization.
......
......@@ -94,7 +94,7 @@ WaylandWindow* WaylandWindow::FromSurface(wl_surface* surface) {
wl_proxy_get_user_data(reinterpret_cast<wl_proxy*>(surface)));
}
bool WaylandWindow::Initialize(const PlatformWindowInitProperties& properties) {
bool WaylandWindow::Initialize(PlatformWindowInitProperties properties) {
DCHECK(xdg_shell_objects_factory_);
bounds_ = properties.bounds;
......
......@@ -35,7 +35,7 @@ class WaylandWindow : public PlatformWindow, public PlatformEventDispatcher {
static WaylandWindow* FromSurface(wl_surface* surface);
bool Initialize(const PlatformWindowInitProperties& properties);
bool Initialize(PlatformWindowInitProperties properties);
wl_surface* surface() const { return surface_.get(); }
XDGSurfaceWrapper* xdg_surface() const { return xdg_surface_.get(); }
......
......@@ -96,7 +96,7 @@ class WaylandWindowTest : public WaylandTest {
std::unique_ptr<WaylandWindow> window =
std::make_unique<WaylandWindow>(delegate, connection_.get());
EXPECT_TRUE(window->Initialize(properties));
EXPECT_TRUE(window->Initialize(std::move(properties)));
return window;
}
......
......@@ -67,7 +67,7 @@ class OzonePlatformWindows : public OzonePlatform {
}
std::unique_ptr<PlatformWindow> CreatePlatformWindow(
PlatformWindowDelegate* delegate,
const PlatformWindowInitProperties& properties) override {
PlatformWindowInitProperties properties) override {
return std::make_unique<WindowsWindow>(delegate, properties.bounds);
}
std::unique_ptr<display::NativeDisplayDelegate> CreateNativeDisplayDelegate()
......
......@@ -64,7 +64,7 @@ class OzonePlatformX11 : public OzonePlatform {
std::unique_ptr<PlatformWindow> CreatePlatformWindow(
PlatformWindowDelegate* delegate,
const PlatformWindowInitProperties& properties) override {
PlatformWindowInitProperties properties) override {
std::unique_ptr<X11WindowOzone> window = std::make_unique<X11WindowOzone>(
window_manager_.get(), delegate, properties.bounds);
window->SetTitle(base::ASCIIToUTF16("Ozone X11"));
......
......@@ -124,7 +124,7 @@ class OZONE_EXPORT OzonePlatform {
virtual std::unique_ptr<SystemInputInjector> CreateSystemInputInjector() = 0;
virtual std::unique_ptr<PlatformWindow> CreatePlatformWindow(
PlatformWindowDelegate* delegate,
const PlatformWindowInitProperties& properties) = 0;
PlatformWindowInitProperties properties) = 0;
virtual std::unique_ptr<display::NativeDisplayDelegate>
CreateNativeDisplayDelegate() = 0;
......
......@@ -21,32 +21,30 @@ namespace views {
namespace {
void ConvertWidgetInitParamsToInitProperties(
const Widget::InitParams& params,
ui::PlatformWindowInitProperties* properties) {
DCHECK(properties);
ui::PlatformWindowInitProperties ConvertWidgetInitParamsToInitProperties(
const Widget::InitParams& params) {
ui::PlatformWindowInitProperties properties;
ui::PlatformWindowType type;
switch (params.type) {
case Widget::InitParams::TYPE_POPUP:
type = ui::PlatformWindowType::PLATFORM_WINDOW_TYPE_POPUP;
case Widget::InitParams::TYPE_WINDOW:
properties.type = ui::PlatformWindowType::PLATFORM_WINDOW_TYPE_WINDOW;
break;
case Widget::InitParams::TYPE_MENU:
type = ui::PlatformWindowType::PLATFORM_WINDOW_TYPE_MENU;
properties.type = ui::PlatformWindowType::PLATFORM_WINDOW_TYPE_MENU;
break;
case Widget::InitParams::TYPE_WINDOW:
default:
type = ui::PlatformWindowType::PLATFORM_WINDOW_TYPE_WINDOW;
properties.type = ui::PlatformWindowType::PLATFORM_WINDOW_TYPE_POPUP;
break;
}
properties->type = type;
properties->bounds = params.bounds;
properties.bounds = params.bounds;
if (params.parent && params.parent->GetHost()) {
properties->parent_widget =
params.parent->GetHost()->GetAcceleratedWidget();
}
if (params.parent && params.parent->GetHost())
properties.parent_widget = params.parent->GetHost()->GetAcceleratedWidget();
return properties;
}
} // namespace
......@@ -74,8 +72,8 @@ void DesktopWindowTreeHostPlatform::SetBoundsInDIP(
}
void DesktopWindowTreeHostPlatform::Init(const Widget::InitParams& params) {
ui::PlatformWindowInitProperties properties;
ConvertWidgetInitParamsToInitProperties(params, &properties);
ui::PlatformWindowInitProperties properties =
ConvertWidgetInitParamsToInitProperties(params);
CreateAndSetPlatformWindow(properties);
CreateCompositor(viz::FrameSinkId(), params.force_software_compositing);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment