| Index: ui/wayland/wayland_window.cc
|
| diff --git a/ui/wayland/wayland_window.cc b/ui/wayland/wayland_window.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1fd11d9eb16fd3235fd17b1486ecd84fdf0959dd
|
| --- /dev/null
|
| +++ b/ui/wayland/wayland_window.cc
|
| @@ -0,0 +1,97 @@
|
| +// 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 "ui/wayland/wayland_window.h"
|
| +
|
| +#include <wayland-egl.h>
|
| +
|
| +#include "ui/wayland/events/wayland_event.h"
|
| +#include "ui/wayland/wayland_display.h"
|
| +#include "ui/wayland/wayland_widget.h"
|
| +
|
| +namespace ui {
|
| +
|
| +WaylandWindow::WaylandWindow(WaylandWidget* widget, WaylandDisplay* display)
|
| + : widget_(widget),
|
| + display_(display),
|
| + surface_(display->CreateSurface()),
|
| + fullscreen_(false),
|
| + parent_window_(NULL),
|
| + relative_position_() {
|
| + wl_surface_set_user_data(surface_, this);
|
| +}
|
| +
|
| +WaylandWindow::WaylandWindow(WaylandWidget* widget, WaylandDisplay* display,
|
| + WaylandWindow* parent, int32_t x, int32_t y)
|
| + : widget_(widget),
|
| + display_(display),
|
| + surface_(display->CreateSurface()),
|
| + fullscreen_(false),
|
| + parent_window_(parent),
|
| + relative_position_(x, y) {
|
| + wl_surface_set_user_data(surface_, this);
|
| +}
|
| +
|
| +WaylandWindow::~WaylandWindow() {
|
| + if (surface_)
|
| + wl_surface_destroy(surface_);
|
| +}
|
| +
|
| +void WaylandWindow::SetVisible(bool visible) {
|
| + if (visible) {
|
| + if (fullscreen_) {
|
| + wl_shell_set_fullscreen(display_->GetShell(), surface_);
|
| + } else if (!parent_window_) {
|
| + wl_shell_set_toplevel(display_->GetShell(), surface_);
|
| + } else {
|
| + wl_shell_set_transient(display_->GetShell(),
|
| + surface_,
|
| + parent_window_->GetSurface(),
|
| + relative_position_.x(),
|
| + relative_position_.y(),
|
| + 0);
|
| + }
|
| + } else {
|
| + // TODO(dnicoara) What is the correct way of hiding a wl_surface?
|
| + }
|
| +}
|
| +
|
| +bool WaylandWindow::IsVisible() const {
|
| + return surface_ != NULL;
|
| +}
|
| +
|
| +void WaylandWindow::SetFullscreen(bool fullscreen) {
|
| + fullscreen_ = fullscreen;
|
| +}
|
| +
|
| +bool WaylandWindow::IsFullscreen() const {
|
| + return fullscreen_;
|
| +}
|
| +
|
| +WaylandWindow* WaylandWindow::GetParentWindow() const {
|
| + return parent_window_;
|
| +}
|
| +
|
| +WaylandWidget* WaylandWindow::GetWidget() const {
|
| + return widget_;
|
| +}
|
| +
|
| +wl_surface* WaylandWindow::GetSurface() const {
|
| + return surface_;
|
| +}
|
| +
|
| +void WaylandWindow::Configure(uint32_t time, uint32_t edges,
|
| + int32_t x, int32_t y,
|
| + int32_t width, int32_t height) {
|
| + WaylandEvent event;
|
| + event.geometry_change.time = time;
|
| + event.geometry_change.x = x;
|
| + event.geometry_change.y = y;
|
| + event.geometry_change.width = width;
|
| + event.geometry_change.height = height;
|
| +
|
| + widget_->OnGeometryChange(event);
|
| +}
|
| +
|
| +} // namespace ui
|
|
|