Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Unified Diff: ui/ozone/platform/wayland/wayland_screen.cc

Issue 2042503002: ozone/platform/wayland: Add support for wl_output_interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Applied review comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« ui/ozone/platform/wayland/wayland_display.cc ('K') | « ui/ozone/platform/wayland/wayland_screen.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698