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

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

Issue 2027943002: [WIP] Make content_shell run under Wayland Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on tonikitoo's CL (included) Created 4 years, 6 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/ozone/platform/wayland/wayland_display.h" 5 #include "ui/ozone/platform/wayland/wayland_display.h"
6 6
7 #include <xdg-shell-unstable-v5-client-protocol.h> 7 #include <xdg-shell-unstable-v5-client-protocol.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "ui/display/screen.h"
13 #include "ui/ozone/platform/wayland/wayland_object.h" 14 #include "ui/ozone/platform/wayland/wayland_object.h"
15 #include "ui/ozone/platform/wayland/wayland_screen.h"
14 #include "ui/ozone/platform/wayland/wayland_window.h" 16 #include "ui/ozone/platform/wayland/wayland_window.h"
15 17
16 static_assert(XDG_SHELL_VERSION_CURRENT == 5, "Unsupported xdg-shell version"); 18 static_assert(XDG_SHELL_VERSION_CURRENT == 5, "Unsupported xdg-shell version");
17 19
18 namespace ui { 20 namespace ui {
19 namespace { 21 namespace {
20 const uint32_t kMaxCompositorVersion = 4; 22 const uint32_t kMaxCompositorVersion = 4;
21 const uint32_t kMaxSeatVersion = 4; 23 const uint32_t kMaxSeatVersion = 4;
22 const uint32_t kMaxShmVersion = 1; 24 const uint32_t kMaxShmVersion = 1;
23 const uint32_t kMaxXdgShellVersion = 1; 25 const uint32_t kMaxXdgShellVersion = 1;
24 } // namespace 26 } // namespace
25 27
28 WaylandDisplay* WaylandDisplay::instance_ = nullptr;
29
26 WaylandDisplay::WaylandDisplay() {} 30 WaylandDisplay::WaylandDisplay() {}
27 31
28 WaylandDisplay::~WaylandDisplay() {} 32 WaylandDisplay::~WaylandDisplay() {
33 for (WaylandScreen* screen : screen_list_)
34 delete screen;
35 screen_list_.clear();
36 }
29 37
30 bool WaylandDisplay::Initialize() { 38 bool WaylandDisplay::Initialize() {
31 static const wl_registry_listener registry_listener = { 39 static const wl_registry_listener registry_listener = {
32 &WaylandDisplay::Global, &WaylandDisplay::GlobalRemove, 40 &WaylandDisplay::Global, &WaylandDisplay::GlobalRemove,
33 }; 41 };
34 42
35 display_.reset(wl_display_connect(nullptr)); 43 display_.reset(wl_display_connect(nullptr));
36 if (!display_) { 44 if (!display_) {
37 LOG(ERROR) << "Failed to connect to Wayland display"; 45 LOG(ERROR) << "Failed to connect to Wayland display";
38 return false; 46 return false;
(...skipping 18 matching lines...) Expand all
57 } 65 }
58 if (!seat_) { 66 if (!seat_) {
59 LOG(ERROR) << "No wl_seat object"; 67 LOG(ERROR) << "No wl_seat object";
60 return false; 68 return false;
61 } 69 }
62 if (!shell_) { 70 if (!shell_) {
63 LOG(ERROR) << "No xdg_shell object"; 71 LOG(ERROR) << "No xdg_shell object";
64 return false; 72 return false;
65 } 73 }
66 74
75 instance_ = this;
67 return true; 76 return true;
68 } 77 }
69 78
70 bool WaylandDisplay::StartProcessingEvents() { 79 bool WaylandDisplay::StartProcessingEvents() {
71 if (watching_) 80 if (watching_)
72 return true; 81 return true;
73 82
74 DCHECK(display_); 83 DCHECK(display_);
75 wl_display_flush(display_.get()); 84 wl_display_flush(display_.get());
76 85
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } 129 }
121 130
122 void WaylandDisplay::OnFileCanReadWithoutBlocking(int fd) { 131 void WaylandDisplay::OnFileCanReadWithoutBlocking(int fd) {
123 wl_display_dispatch(display_.get()); 132 wl_display_dispatch(display_.get());
124 for (const auto& window : window_map_) 133 for (const auto& window : window_map_)
125 window.second->ApplyPendingBounds(); 134 window.second->ApplyPendingBounds();
126 } 135 }
127 136
128 void WaylandDisplay::OnFileCanWriteWithoutBlocking(int fd) {} 137 void WaylandDisplay::OnFileCanWriteWithoutBlocking(int fd) {}
129 138
139 void WaylandDisplay::OnOutputGeometryChanged(int32_t name,
140 const gfx::Rect& rect) {
141 display::Screen::GetScreen()->OnOutputGeometryChanged(name, rect);
142 if (!output_complete_closure_.is_null())
143 output_complete_closure_.Run();
144 }
145
146 void WaylandDisplay::SetOutputCompleteClosure(const base::Closure& closure) {
147 output_complete_closure_ = closure;
148 }
149
150 const std::vector<WaylandScreen*>& WaylandDisplay::GetScreenList() const {
151 return screen_list_;
152 }
153
130 // static 154 // static
131 void WaylandDisplay::Global(void* data, 155 void WaylandDisplay::Global(void* data,
132 wl_registry* registry, 156 wl_registry* registry,
133 uint32_t name, 157 uint32_t name,
134 const char* interface, 158 const char* interface,
135 uint32_t version) { 159 uint32_t version) {
136 static const wl_seat_listener seat_listener = { 160 static const wl_seat_listener seat_listener = {
137 &WaylandDisplay::Capabilities, &WaylandDisplay::Name, 161 &WaylandDisplay::Capabilities, &WaylandDisplay::Name,
138 }; 162 };
139 static const xdg_shell_listener shell_listener = { 163 static const xdg_shell_listener shell_listener = {
(...skipping 22 matching lines...) Expand all
162 } else if (!display->shell_ && strcmp(interface, "xdg_shell") == 0) { 186 } else if (!display->shell_ && strcmp(interface, "xdg_shell") == 0) {
163 display->shell_ = wl::Bind<xdg_shell>( 187 display->shell_ = wl::Bind<xdg_shell>(
164 registry, name, std::min(version, kMaxXdgShellVersion)); 188 registry, name, std::min(version, kMaxXdgShellVersion));
165 if (!display->shell_) { 189 if (!display->shell_) {
166 LOG(ERROR) << "Failed to bind to xdg_shell global"; 190 LOG(ERROR) << "Failed to bind to xdg_shell global";
167 return; 191 return;
168 } 192 }
169 xdg_shell_add_listener(display->shell_.get(), &shell_listener, display); 193 xdg_shell_add_listener(display->shell_.get(), &shell_listener, display);
170 xdg_shell_use_unstable_version(display->shell_.get(), 194 xdg_shell_use_unstable_version(display->shell_.get(),
171 XDG_SHELL_VERSION_CURRENT); 195 XDG_SHELL_VERSION_CURRENT);
196 } else if (strcmp(interface, "wl_output") == 0) {
197 WaylandScreen* screen = new WaylandScreen(registry, name);
198 if (!display->screen_list_.empty())
199 NOTIMPLEMENTED() << "Multiple screens support is not implemented";
200
201 display->screen_list_.push_back(screen);
202 display->primary_screen_ = display->screen_list_.front();
172 } 203 }
173 204
174 display->ScheduleFlush(); 205 display->ScheduleFlush();
175 } 206 }
176 207
177 // static 208 // static
178 void WaylandDisplay::GlobalRemove(void* data, 209 void WaylandDisplay::GlobalRemove(void* data,
179 wl_registry* registry, 210 wl_registry* registry,
180 uint32_t name) { 211 uint32_t name) {
181 NOTIMPLEMENTED(); 212 NOTIMPLEMENTED();
(...skipping 25 matching lines...) Expand all
207 void WaylandDisplay::Name(void* data, wl_seat* seat, const char* name) {} 238 void WaylandDisplay::Name(void* data, wl_seat* seat, const char* name) {}
208 239
209 // static 240 // static
210 void WaylandDisplay::Ping(void* data, xdg_shell* shell, uint32_t serial) { 241 void WaylandDisplay::Ping(void* data, xdg_shell* shell, uint32_t serial) {
211 WaylandDisplay* display = static_cast<WaylandDisplay*>(data); 242 WaylandDisplay* display = static_cast<WaylandDisplay*>(data);
212 xdg_shell_pong(shell, serial); 243 xdg_shell_pong(shell, serial);
213 display->ScheduleFlush(); 244 display->ScheduleFlush();
214 } 245 }
215 246
216 } // namespace ui 247 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698