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

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

Issue 2042503002: ozone/platform/wayland: Add support for wl_output_interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comments and use std::unique_ptr Created 4 years, 3 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_connection.h" 5 #include "ui/ozone/platform/wayland/wayland_connection.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/ozone/platform/wayland/wayland_object.h"
13 #include "ui/ozone/platform/wayland/wayland_window.h" 14 #include "ui/ozone/platform/wayland/wayland_window.h"
14 15
15 static_assert(XDG_SHELL_VERSION_CURRENT == 5, "Unsupported xdg-shell version"); 16 static_assert(XDG_SHELL_VERSION_CURRENT == 5, "Unsupported xdg-shell version");
16 17
17 namespace ui { 18 namespace ui {
18 namespace { 19 namespace {
19 const uint32_t kMaxCompositorVersion = 4; 20 const uint32_t kMaxCompositorVersion = 4;
20 const uint32_t kMaxSeatVersion = 4; 21 const uint32_t kMaxSeatVersion = 4;
21 const uint32_t kMaxShmVersion = 1; 22 const uint32_t kMaxShmVersion = 1;
22 const uint32_t kMaxXdgShellVersion = 1; 23 const uint32_t kMaxXdgShellVersion = 1;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 99
99 void WaylandConnection::AddWindow(gfx::AcceleratedWidget widget, 100 void WaylandConnection::AddWindow(gfx::AcceleratedWidget widget,
100 WaylandWindow* window) { 101 WaylandWindow* window) {
101 window_map_[widget] = window; 102 window_map_[widget] = window;
102 } 103 }
103 104
104 void WaylandConnection::RemoveWindow(gfx::AcceleratedWidget widget) { 105 void WaylandConnection::RemoveWindow(gfx::AcceleratedWidget widget) {
105 window_map_.erase(widget); 106 window_map_.erase(widget);
106 } 107 }
107 108
109 WaylandOutput* WaylandConnection::PrimaryOutput() const {
110 if (!output_list_.size())
111 return nullptr;
112 return output_list_.front().get();
113 }
114
108 void WaylandConnection::OnDispatcherListChanged() { 115 void WaylandConnection::OnDispatcherListChanged() {
109 StartProcessingEvents(); 116 StartProcessingEvents();
110 } 117 }
111 118
112 void WaylandConnection::Flush() { 119 void WaylandConnection::Flush() {
113 wl_display_flush(display_.get()); 120 wl_display_flush(display_.get());
114 scheduled_flush_ = false; 121 scheduled_flush_ = false;
115 } 122 }
116 123
117 void WaylandConnection::DispatchUiEvent(Event* event) { 124 void WaylandConnection::DispatchUiEvent(Event* event) {
118 PlatformEventSource::DispatchEvent(event); 125 PlatformEventSource::DispatchEvent(event);
119 } 126 }
120 127
121 void WaylandConnection::OnFileCanReadWithoutBlocking(int fd) { 128 void WaylandConnection::OnFileCanReadWithoutBlocking(int fd) {
122 wl_display_dispatch(display_.get()); 129 wl_display_dispatch(display_.get());
123 for (const auto& window : window_map_) 130 for (const auto& window : window_map_)
124 window.second->ApplyPendingBounds(); 131 window.second->ApplyPendingBounds();
125 } 132 }
126 133
127 void WaylandConnection::OnFileCanWriteWithoutBlocking(int fd) {} 134 void WaylandConnection::OnFileCanWriteWithoutBlocking(int fd) {}
128 135
136 const std::vector<std::unique_ptr<WaylandOutput>>&
137 WaylandConnection::GetOutputList() const {
138 return output_list_;
139 }
140
129 // static 141 // static
130 void WaylandConnection::Global(void* data, 142 void WaylandConnection::Global(void* data,
131 wl_registry* registry, 143 wl_registry* registry,
132 uint32_t name, 144 uint32_t name,
133 const char* interface, 145 const char* interface,
134 uint32_t version) { 146 uint32_t version) {
135 static const wl_seat_listener seat_listener = { 147 static const wl_seat_listener seat_listener = {
136 &WaylandConnection::Capabilities, &WaylandConnection::Name, 148 &WaylandConnection::Capabilities, &WaylandConnection::Name,
137 }; 149 };
138 static const xdg_shell_listener shell_listener = { 150 static const xdg_shell_listener shell_listener = {
(...skipping 23 matching lines...) Expand all
162 connection->shell_ = wl::Bind<xdg_shell>( 174 connection->shell_ = wl::Bind<xdg_shell>(
163 registry, name, std::min(version, kMaxXdgShellVersion)); 175 registry, name, std::min(version, kMaxXdgShellVersion));
164 if (!connection->shell_) { 176 if (!connection->shell_) {
165 LOG(ERROR) << "Failed to bind to xdg_shell global"; 177 LOG(ERROR) << "Failed to bind to xdg_shell global";
166 return; 178 return;
167 } 179 }
168 xdg_shell_add_listener(connection->shell_.get(), &shell_listener, 180 xdg_shell_add_listener(connection->shell_.get(), &shell_listener,
169 connection); 181 connection);
170 xdg_shell_use_unstable_version(connection->shell_.get(), 182 xdg_shell_use_unstable_version(connection->shell_.get(),
171 XDG_SHELL_VERSION_CURRENT); 183 XDG_SHELL_VERSION_CURRENT);
184 } else if (strcmp(interface, "wl_output") == 0) {
rjkroege 2016/09/25 14:44:31 nit: Chrome style is probably to use something fro
joone 2016/09/27 08:25:20 Done.
185 wl::Object<wl_output> output = wl::Bind<wl_output>(registry, name, 1);
186 if (!output) {
187 LOG(ERROR) << "Failed to bind to wl_output global";
188 return;
189 }
190
191 if (!connection->output_list_.empty())
192 NOTIMPLEMENTED() << "Multiple screens support is not implemented";
193
194 connection->output_list_.push_back(
195 base::WrapUnique(new WaylandOutput(output.release())));
172 } 196 }
173 197
174 connection->ScheduleFlush(); 198 connection->ScheduleFlush();
175 } 199 }
176 200
177 // static 201 // static
178 void WaylandConnection::GlobalRemove(void* data, 202 void WaylandConnection::GlobalRemove(void* data,
179 wl_registry* registry, 203 wl_registry* registry,
180 uint32_t name) { 204 uint32_t name) {
181 NOTIMPLEMENTED(); 205 NOTIMPLEMENTED();
(...skipping 25 matching lines...) Expand all
207 void WaylandConnection::Name(void* data, wl_seat* seat, const char* name) {} 231 void WaylandConnection::Name(void* data, wl_seat* seat, const char* name) {}
208 232
209 // static 233 // static
210 void WaylandConnection::Ping(void* data, xdg_shell* shell, uint32_t serial) { 234 void WaylandConnection::Ping(void* data, xdg_shell* shell, uint32_t serial) {
211 WaylandConnection* connection = static_cast<WaylandConnection*>(data); 235 WaylandConnection* connection = static_cast<WaylandConnection*>(data);
212 xdg_shell_pong(shell, serial); 236 xdg_shell_pong(shell, serial);
213 connection->ScheduleFlush(); 237 connection->ScheduleFlush();
214 } 238 }
215 239
216 } // namespace ui 240 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698