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

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

Issue 1610683003: Add initial SHM-only Wayland Ozone implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use base::SharedMemory, expand ObjectTraits macros, etc Created 4 years, 11 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
OLDNEW
(Empty)
1 // Copyright 2016 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/ozone/platform/wayland/wayland_window.h"
6
7 #include "base/strings/utf_string_conversions.h"
8 #include "ui/ozone/platform/wayland/wayland_display.h"
9 #include "ui/platform_window/platform_window_delegate.h"
10
11 namespace ui {
12
13 WaylandWindow::WaylandWindow(PlatformWindowDelegate* delegate,
14 WaylandDisplay* display,
15 const gfx::Rect& bounds)
16 : delegate_(delegate), display_(display), bounds_(bounds) {}
17
18 WaylandWindow::~WaylandWindow() {
19 if (xdg_surface_) {
20 display_->RemoveWindow(this);
21 }
22 }
23
24 bool WaylandWindow::Initialize() {
25 static const xdg_surface_listener xdg_surface_listener = {
26 .configure = &WaylandWindow::Configure, .close = &WaylandWindow::Close,
27 };
28
29 surface_.reset(wl_compositor_create_surface(display_->compositor()));
30 if (!surface_) {
31 LOG(ERROR) << "Failed to create wl_surface";
32 return false;
33 }
34 wl_surface_set_user_data(surface_.get(), this);
35 xdg_surface_.reset(
36 xdg_shell_get_xdg_surface(display_->shell(), surface_.get()));
37 if (!xdg_surface_) {
38 LOG(ERROR) << "Failed to create xdg_surface";
39 return false;
40 }
41 xdg_surface_add_listener(xdg_surface_.get(), &xdg_surface_listener, this);
42
43 display_->AddWindow(this);
44 delegate_->OnAcceleratedWidgetAvailable(surface_.id(), 1.f);
45
46 return true;
47 }
48
49 wl_surface* WaylandWindow::GetSurface() {
50 DCHECK(surface_);
51 return surface_.get();
52 }
53
54 gfx::AcceleratedWidget WaylandWindow::GetWidget() {
55 DCHECK(surface_);
56 return surface_.id();
57 }
58
59 void WaylandWindow::ApplyPendingBounds() {
60 if (pending_bounds_.IsEmpty())
61 return;
62
63 SetBounds(pending_bounds_);
64 DCHECK(xdg_surface_);
65 xdg_surface_ack_configure(xdg_surface_.get(), pending_configure_serial_);
66 pending_bounds_ = gfx::Rect();
67 }
68
69 void WaylandWindow::Show() {}
70
71 void WaylandWindow::Hide() {
72 NOTIMPLEMENTED();
73 }
74
75 void WaylandWindow::Close() {
76 NOTIMPLEMENTED();
77 }
78
79 void WaylandWindow::SetBounds(const gfx::Rect& bounds) {
80 if (bounds == bounds_)
81 return;
82 bounds_ = bounds;
83 delegate_->OnBoundsChanged(bounds);
84 }
85
86 gfx::Rect WaylandWindow::GetBounds() {
87 return bounds_;
88 }
89
90 void WaylandWindow::SetTitle(const base::string16& title) {
91 DCHECK(xdg_surface_);
92 xdg_surface_set_title(xdg_surface_.get(), UTF16ToUTF8(title).c_str());
93 }
94
95 void WaylandWindow::SetCapture() {
96 NOTIMPLEMENTED();
97 }
98
99 void WaylandWindow::ReleaseCapture() {
100 NOTIMPLEMENTED();
101 }
102
103 void WaylandWindow::ToggleFullscreen() {
104 NOTIMPLEMENTED();
105 }
106
107 void WaylandWindow::Maximize() {
108 DCHECK(xdg_surface_);
109 xdg_surface_set_maximized(xdg_surface_.get());
110 }
111
112 void WaylandWindow::Minimize() {
113 DCHECK(xdg_surface_);
114 xdg_surface_set_minimized(xdg_surface_.get());
115 }
116
117 void WaylandWindow::Restore() {
118 DCHECK(xdg_surface_);
119 xdg_surface_unset_maximized(xdg_surface_.get());
120 }
121
122 void WaylandWindow::SetCursor(PlatformCursor cursor) {
123 NOTIMPLEMENTED();
124 }
125
126 void WaylandWindow::MoveCursorTo(const gfx::Point& location) {
127 NOTIMPLEMENTED();
128 }
129
130 void WaylandWindow::ConfineCursorToBounds(const gfx::Rect& bounds) {
131 NOTIMPLEMENTED();
132 }
133
134 PlatformImeController* WaylandWindow::GetPlatformImeController() {
135 NOTIMPLEMENTED();
136 return nullptr;
137 }
138
139 void WaylandWindow::Configure(void* data,
140 xdg_surface* obj,
141 int32_t width,
142 int32_t height,
143 wl_array* states,
144 uint32_t serial) {
145 WaylandWindow* window = static_cast<WaylandWindow*>(data);
146 window->pending_bounds_ = gfx::Rect(0, 0, width, height);
147 window->pending_configure_serial_ = serial;
148 }
149
150 void WaylandWindow::Close(void* data, xdg_surface* obj) {
151 NOTIMPLEMENTED();
152 }
153
154 } // namespace ui
OLDNEW
« ui/ozone/platform/wayland/wayland_window.h ('K') | « ui/ozone/platform/wayland/wayland_window.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698