Chromium Code Reviews| 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 namespace ui { | |
| 14 | |
| 15 WaylandWindow::WaylandWindow(WaylandWidget* widget, WaylandDisplay* display) | |
| 16 : widget_(widget), | |
| 17 display_(display), | |
| 18 surface_(display->CreateSurface()), | |
| 19 fullscreen_(false), | |
| 20 parent_window_(NULL), | |
| 21 relative_position_() { | |
| 22 wl_surface_set_user_data(surface_, this); | |
| 23 } | |
| 24 | |
| 25 WaylandWindow::WaylandWindow( | |
| 26 WaylandWidget* widget, | |
| 27 WaylandDisplay* display, | |
| 28 WaylandWindow* parent, | |
| 29 int32_t x, | |
| 30 int32_t y) | |
| 31 : widget_(widget), | |
| 32 display_(display), | |
| 33 surface_(display->CreateSurface()), | |
| 34 fullscreen_(false), | |
| 35 parent_window_(parent), | |
| 36 relative_position_(x, y) { | |
| 37 wl_surface_set_user_data(surface_, this); | |
| 38 } | |
| 39 | |
| 40 WaylandWindow::~WaylandWindow() { | |
| 41 if (surface_) | |
| 42 wl_surface_destroy(surface_); | |
| 43 } | |
| 44 | |
| 45 void WaylandWindow::SetVisible(bool visible) { | |
| 46 if (visible) { | |
| 47 if (fullscreen_) { | |
| 48 wl_shell_set_fullscreen(display_->GetShell(), surface_); | |
| 49 } else if (!parent_window_) { | |
| 50 wl_shell_set_toplevel(display_->GetShell(), surface_); | |
| 51 } else { | |
| 52 wl_shell_set_transient(display_->GetShell(), | |
| 53 surface_, | |
| 54 parent_window_->GetSurface(), | |
| 55 relative_position_.x(), | |
| 56 relative_position_.y(), | |
| 57 0); | |
| 58 } | |
| 59 } else { | |
| 60 // TODO(dnicoara) What is the correct way of hiding a wl_surface? | |
| 61 } | |
| 62 } | |
| 63 | |
| 64 bool WaylandWindow::IsVisible() const { | |
| 65 return surface_ != NULL; | |
| 66 } | |
| 67 | |
| 68 void WaylandWindow::SetFullscreen(bool fullscreen) { | |
| 69 fullscreen_ = fullscreen; | |
| 70 } | |
| 71 | |
| 72 bool WaylandWindow::IsFullscreen() const { | |
| 73 return fullscreen_; | |
| 74 } | |
| 75 | |
| 76 WaylandWindow* WaylandWindow::GetParentWindow() const { | |
| 77 return parent_window_; | |
| 78 } | |
| 79 | |
| 80 WaylandWidget* WaylandWindow::GetWidget() const { | |
| 81 return widget_; | |
| 82 } | |
| 83 | |
| 84 wl_surface* WaylandWindow::GetSurface() const { | |
| 85 return surface_; | |
| 86 } | |
| 87 | |
| 88 void WaylandWindow::Configure( | |
| 89 uint32_t time, | |
|
tfarina
2011/07/25 18:34:27
You can write this as:
void WaylandWindow::Config
| |
| 90 uint32_t edges, | |
| 91 int32_t x, | |
| 92 int32_t y, | |
| 93 int32_t width, | |
| 94 int32_t height) { | |
| 95 WaylandEvent event; | |
| 96 event.geometry_change.time = time; | |
| 97 event.geometry_change.x = x; | |
| 98 event.geometry_change.y = y; | |
| 99 event.geometry_change.width = width; | |
| 100 event.geometry_change.height = height; | |
| 101 | |
| 102 widget_->OnGeometryChange(event); | |
| 103 } | |
| 104 | |
| 105 } // namespace ui | |
| OLD | NEW |