OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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/wayland/wayland_window.h" |
| 6 |
| 7 #include <wayland-egl.h> |
| 8 |
| 9 #include "ui/wayland/events/wayland_event.h" |
| 10 #include "ui/wayland/wayland_display.h" |
| 11 #include "ui/wayland/wayland_widget.h" |
| 12 |
| 13 WaylandWindow::WaylandWindow(WaylandWidget* widget, WaylandDisplay* display) |
| 14 : widget_(widget), |
| 15 display_(display), |
| 16 surface_(display->CreateSurface()), |
| 17 fullscreen_(false), |
| 18 parent_window_(NULL), |
| 19 relative_position_() { |
| 20 wl_surface_set_user_data(surface_, this); |
| 21 } |
| 22 |
| 23 WaylandWindow::WaylandWindow(WaylandWidget* widget, WaylandDisplay* display, |
| 24 WaylandWindow* parent, int32_t x, int32_t y) |
| 25 : widget_(widget), |
| 26 display_(display), |
| 27 surface_(display->CreateSurface()), |
| 28 fullscreen_(false), |
| 29 parent_window_(parent), |
| 30 relative_position_(x, y) { |
| 31 wl_surface_set_user_data(surface_, this); |
| 32 } |
| 33 |
| 34 WaylandWindow::~WaylandWindow() { |
| 35 if (surface_) |
| 36 wl_surface_destroy(surface_); |
| 37 } |
| 38 |
| 39 void WaylandWindow::SetVisible(bool visible) { |
| 40 if (visible) { |
| 41 if (fullscreen_) { |
| 42 wl_shell_set_fullscreen(display_->GetShell(), surface_); |
| 43 } else if (!parent_window_) { |
| 44 wl_shell_set_toplevel(display_->GetShell(), surface_); |
| 45 } else { |
| 46 wl_shell_set_transient(display_->GetShell(), |
| 47 surface_, |
| 48 parent_window_->GetSurface(), |
| 49 relative_position_.x, |
| 50 relative_position_.y, |
| 51 0); |
| 52 } |
| 53 } else { |
| 54 // TODO(dnicoara) What is the correct way of hiding a wl_surface? |
| 55 } |
| 56 } |
| 57 |
| 58 bool WaylandWindow::IsVisible() const { |
| 59 return surface_ != NULL; |
| 60 } |
| 61 |
| 62 void WaylandWindow::SetFullscreen(bool fullscreen) { |
| 63 fullscreen_ = fullscreen; |
| 64 } |
| 65 |
| 66 bool WaylandWindow::IsFullscreen() const { |
| 67 return fullscreen_; |
| 68 } |
| 69 |
| 70 WaylandWindow* WaylandWindow::GetParentWindow() const { |
| 71 return parent_window_; |
| 72 } |
| 73 |
| 74 WaylandWidget* WaylandWindow::GetWidget() const { |
| 75 return widget_; |
| 76 } |
| 77 |
| 78 wl_surface* WaylandWindow::GetSurface() const { |
| 79 return surface_; |
| 80 } |
| 81 |
| 82 void WaylandWindow::Configure(uint32_t time, uint32_t edges, |
| 83 int32_t x, int32_t y, |
| 84 int32_t width, int32_t height) { |
| 85 WaylandEvent event; |
| 86 event.geometry_change.time = time; |
| 87 event.geometry_change.x = x; |
| 88 event.geometry_change.y = y; |
| 89 event.geometry_change.width = width; |
| 90 event.geometry_change.height = height; |
| 91 |
| 92 widget_->OnGeometryChange(event); |
| 93 } |
OLD | NEW |