Chromium Code Reviews| Index: ui/ozone/platform/wayland/wayland_screen.cc |
| diff --git a/ui/ozone/platform/wayland/wayland_screen.cc b/ui/ozone/platform/wayland/wayland_screen.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3fc20304e5b9eba7d4c9545a4d2865591367d8a0 |
| --- /dev/null |
| +++ b/ui/ozone/platform/wayland/wayland_screen.cc |
| @@ -0,0 +1,73 @@ |
| +// Copyright 2016 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 "ui/ozone/platform/wayland/wayland_screen.h" |
| + |
| +#include <wayland-client.h> |
| + |
| +#include "base/run_loop.h" |
| +#include "ui/display/screen.h" |
| +#include "ui/ozone/platform/wayland/wayland_display.h" |
| + |
| +namespace ui { |
| + |
| +WaylandScreen::WaylandScreen(wl_registry* registry, |
|
Michael Forney
2016/06/14 23:44:54
registry is unused.
joone
2016/06/20 22:22:42
Removed.
|
| + uint32_t name, |
| + wl_output* output) |
| + : output_(output), name_(name), rect_(0, 0, 0, 0) { |
| + static const wl_output_listener output_listener = { |
| + &WaylandScreen::OutputHandleGeometry, &WaylandScreen::OutputHandleMode, |
| + }; |
| + wl_output_add_listener(output, &output_listener, this); |
| +} |
| + |
| +WaylandScreen::~WaylandScreen() {} |
| + |
| +// static |
| +void WaylandScreen::OutputHandleGeometry(void* data, |
| + wl_output* output, |
| + int32_t x, |
| + int32_t y, |
| + int32_t physical_width, |
| + int32_t physical_height, |
| + int32_t subpixel, |
| + const char* make, |
| + const char* model, |
| + int32_t output_transform) { |
| + WaylandScreen* screen = static_cast<WaylandScreen*>(data); |
| + screen->rect_.set_origin(gfx::Point(x, y)); |
| +} |
| + |
| +// static |
| +void WaylandScreen::OutputHandleMode(void* data, |
| + wl_output* wl_output, |
| + uint32_t flags, |
| + int32_t width, |
| + int32_t height, |
| + int32_t refresh) { |
| + WaylandScreen* screen = static_cast<WaylandScreen*>(data); |
| + |
| + if (flags & WL_OUTPUT_MODE_CURRENT) { |
| + screen->rect_.set_width(width); |
| + screen->rect_.set_height(height); |
| + |
| + if (display::Screen::GetScreen()) |
| + display::Screen::GetScreen()->OnOutputGeometryChanged(screen->name_, |
| + screen->rect_); |
| + screen->OutputReadyForUse(); |
| + } |
| +} |
| + |
| +void WaylandScreen::WaitforOutputAvailable() { |
|
rjkroege
2016/06/14 23:29:48
Do you need to use a RunLoop? It is better to avoi
joone
2016/06/20 22:22:42
RunLoop can be used in the test case so I will rem
|
| + base::RunLoop run_loop; |
| + output_complete_closure_ = run_loop.QuitClosure(); |
| + run_loop.Run(); |
|
Michael Forney
2016/06/14 23:25:33
I think base::WaitableEvent may be more appropriat
joone
2016/06/16 22:44:23
I tried to use base::WaitableEvent instead of base
|
| +} |
| + |
| +void WaylandScreen::OutputReadyForUse() { |
| + if (!output_complete_closure_.is_null()) |
| + output_complete_closure_.Run(); |
| +} |
| + |
| +} // namespace ui |