Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Side by Side Diff: ui/wayland/wayland_window.cc

Issue 7457023: Adding a Wayland basic toolkit (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixed naming for consts Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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(WaylandWidget* widget, WaylandDisplay* display,
26 WaylandWindow* parent, int32_t x, int32_t y)
27 : widget_(widget),
28 display_(display),
29 surface_(display->CreateSurface()),
30 fullscreen_(false),
31 parent_window_(parent),
32 relative_position_(x, y) {
33 wl_surface_set_user_data(surface_, this);
34 }
35
36 WaylandWindow::~WaylandWindow() {
37 if (surface_)
38 wl_surface_destroy(surface_);
39 }
40
41 void WaylandWindow::SetVisible(bool visible) {
42 if (visible) {
43 if (fullscreen_) {
44 wl_shell_set_fullscreen(display_->GetShell(), surface_);
45 } else if (!parent_window_) {
46 wl_shell_set_toplevel(display_->GetShell(), surface_);
47 } else {
48 wl_shell_set_transient(display_->GetShell(),
49 surface_,
50 parent_window_->GetSurface(),
51 relative_position_.x(),
52 relative_position_.y(),
53 0);
54 }
55 } else {
56 // TODO(dnicoara) What is the correct way of hiding a wl_surface?
57 }
58 }
59
60 bool WaylandWindow::IsVisible() const {
61 return surface_ != NULL;
62 }
63
64 void WaylandWindow::SetFullscreen(bool fullscreen) {
65 fullscreen_ = fullscreen;
66 }
67
68 bool WaylandWindow::IsFullscreen() const {
69 return fullscreen_;
70 }
71
72 WaylandWindow* WaylandWindow::GetParentWindow() const {
73 return parent_window_;
74 }
75
76 WaylandWidget* WaylandWindow::GetWidget() const {
77 return widget_;
78 }
79
80 wl_surface* WaylandWindow::GetSurface() const {
81 return surface_;
82 }
83
84 void WaylandWindow::Configure(uint32_t time, uint32_t edges,
85 int32_t x, int32_t y,
86 int32_t width, int32_t height) {
87 WaylandEvent event;
88 event.geometry_change.time = time;
89 event.geometry_change.x = x;
90 event.geometry_change.y = y;
91 event.geometry_change.width = width;
92 event.geometry_change.height = height;
93
94 widget_->OnGeometryChange(event);
95 }
96
97 } // namespace ui
OLDNEW
« ui/wayland/wayland_input_device.cc ('K') | « ui/wayland/wayland_window.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698