| Index: ui/wayland/wayland_screen.cc
|
| diff --git a/ui/wayland/wayland_screen.cc b/ui/wayland/wayland_screen.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e7b6b22a9db6bd2c17e65bf7175c757b1bdbbf47
|
| --- /dev/null
|
| +++ b/ui/wayland/wayland_screen.cc
|
| @@ -0,0 +1,78 @@
|
| +// Copyright (c) 2011 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 "wayland_screen.h"
|
| +
|
| +#include <wayland-client.h>
|
| +
|
| +#include "wayland_display.h"
|
| +
|
| +WaylandScreen::WaylandScreen(WaylandDisplay* display, uint32_t id)
|
| + : output_(NULL),
|
| + display_(display) {
|
| + output_ = wl_output_create(display_->GetNativeDisplay(), id, 1);
|
| + wl_output_add_listener(output_, &output_listener, this);
|
| +}
|
| +
|
| +WaylandScreen::~WaylandScreen() {
|
| + if (output_) {
|
| + wl_output_destroy(output_);
|
| + }
|
| +}
|
| +
|
| +Rectangle WaylandScreen::GetAllocation() const {
|
| + Rectangle allocation;
|
| + allocation.x = position_.x;
|
| + allocation.y = position_.y;
|
| +
|
| + // Find the active mode and pass its dimensions
|
| + for (Modes::const_iterator it = modes_.begin(); it != modes_.end(); it++) {
|
| + if ((*it).flags & WL_OUTPUT_MODE_CURRENT) {
|
| + allocation.width = (*it).width;
|
| + allocation.height = (*it).height;
|
| + break;
|
| + }
|
| + }
|
| +
|
| + return allocation;
|
| +}
|
| +
|
| +//static
|
| +const struct wl_output_listener WaylandScreen::output_listener = {
|
| + WaylandScreen::OutputHandleGeometry,
|
| + WaylandScreen::OutputHandleMode,
|
| +};
|
| +
|
| +// static
|
| +void WaylandScreen::OutputHandleGeometry(void* data,
|
| + struct 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) {
|
| + WaylandScreen* screen = static_cast<WaylandScreen*>(data);
|
| + screen->position_.x = x;
|
| + screen->position_.y = y;
|
| +}
|
| +
|
| +// static
|
| +void WaylandScreen::OutputHandleMode(void* data,
|
| + struct wl_output* wl_output,
|
| + uint32_t flags,
|
| + int32_t width,
|
| + int32_t height,
|
| + int32_t refresh) {
|
| + WaylandScreen* screen = static_cast<WaylandScreen*>(data);
|
| +
|
| + Mode mode;
|
| + mode.width = width;
|
| + mode.height = height;
|
| + mode.refresh = refresh;
|
| + mode.flags = flags;
|
| +
|
| + screen->modes_.push_back(mode);
|
| +}
|
|
|