OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/ozone/platform/wayland/wayland_screen.h" |
| 6 |
| 7 #include <wayland-client.h> |
| 8 |
| 9 #include "ui/ozone/platform/wayland/wayland_display.h" |
| 10 |
| 11 namespace ui { |
| 12 |
| 13 WaylandScreen::WaylandScreen(wl_registry* registry, uint32_t name) |
| 14 : output_(nullptr), name_(name), refresh_(0), rect_(0, 0, 0, 0) { |
| 15 static const wl_output_listener output_listener = { |
| 16 &WaylandScreen::OutputHandleGeometry, &WaylandScreen::OutputHandleMode, |
| 17 }; |
| 18 |
| 19 output_ = wl::Bind<wl_output>(registry, name, 1); |
| 20 if (!output_) { |
| 21 LOG(ERROR) << "Failed to bind to wl_output global"; |
| 22 return; |
| 23 } |
| 24 |
| 25 wl_output_add_listener(output_.get(), &output_listener, this); |
| 26 } |
| 27 |
| 28 WaylandScreen::~WaylandScreen() {} |
| 29 |
| 30 // static |
| 31 void WaylandScreen::OutputHandleGeometry(void* data, |
| 32 wl_output* output, |
| 33 int32_t x, |
| 34 int32_t y, |
| 35 int32_t physical_width, |
| 36 int32_t physical_height, |
| 37 int32_t subpixel, |
| 38 const char* make, |
| 39 const char* model, |
| 40 int32_t output_transform) { |
| 41 WaylandScreen* screen = static_cast<WaylandScreen*>(data); |
| 42 screen->rect_.set_origin(gfx::Point(x, y)); |
| 43 } |
| 44 |
| 45 // static |
| 46 void WaylandScreen::OutputHandleMode(void* data, |
| 47 wl_output* wl_output, |
| 48 uint32_t flags, |
| 49 int32_t width, |
| 50 int32_t height, |
| 51 int32_t refresh) { |
| 52 WaylandScreen* screen = static_cast<WaylandScreen*>(data); |
| 53 |
| 54 if (flags & WL_OUTPUT_MODE_CURRENT) { |
| 55 screen->rect_.set_width(width); |
| 56 screen->rect_.set_height(height); |
| 57 screen->refresh_ = refresh; |
| 58 |
| 59 if (!WaylandDisplay::GetInstance()) |
| 60 return; |
| 61 |
| 62 WaylandDisplay::GetInstance()->OutputSizeChanged(screen->name_, width, |
| 63 height); |
| 64 } |
| 65 } |
| 66 |
| 67 } // namespace ui |
OLD | NEW |