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..2bc94f9e8934cf4d24dc9f8635d8a5cbe4c4f8c6 |
--- /dev/null |
+++ b/ui/ozone/platform/wayland/wayland_screen.cc |
@@ -0,0 +1,67 @@ |
+// 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 "ui/ozone/platform/wayland/wayland_display.h" |
+ |
+namespace ui { |
+ |
+WaylandScreen::WaylandScreen(wl_registry* registry, uint32_t name) |
+ : output_(nullptr), name_(name), refresh_(0), rect_(0, 0, 0, 0) { |
+ static const wl_output_listener output_listener = { |
+ &WaylandScreen::OutputHandleGeometry, &WaylandScreen::OutputHandleMode, |
+ }; |
+ |
+ output_ = wl::Bind<wl_output>(registry, name, 1); |
Michael Forney
2016/06/10 18:12:21
I think you should bind the object in wayland_disp
joone
2016/06/14 00:04:43
Done.
|
+ if (!output_) { |
+ LOG(ERROR) << "Failed to bind to wl_output global"; |
+ return; |
+ } |
+ |
+ wl_output_add_listener(output_.get(), &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); |
+ screen->refresh_ = refresh; |
+ |
+ if (!WaylandDisplay::GetInstance()) |
+ return; |
+ |
+ WaylandDisplay::GetInstance()->OnOutputGeometryChanged(screen->name_, |
+ screen->rect_); |
+ } |
+} |
+ |
+} // namespace ui |