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

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

Issue 2027943002: [WIP] Make content_shell run under Wayland Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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..0d6b1be815383550d6a5859775fb0248d6e97055
--- /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);
+ 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()->OutputSizeChanged(screen->name_, width,
+ height);
+ }
+}
+
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698