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

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: rebase on master Created 4 years, 5 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;
23 } // namespace 24 } // namespace
24 25
25 WaylandConnection::WaylandConnection() {} 26 WaylandConnection::WaylandConnection() {}
26 27
27 WaylandConnection::~WaylandConnection() {} 28 WaylandConnection::~WaylandConnection() {
29 for (WaylandOutput* output : output_list_)
30 delete output;
rjkroege 2016/07/25 23:45:46 Keep WaylandOutput in a self-deleting type like st
joone 2016/09/21 21:21:22 Done.
31 output_list_.clear();
rjkroege 2016/07/25 23:45:46 redundant I would think.
joone 2016/09/21 21:21:22 Done.
32 }
28 33
29 bool WaylandConnection::Initialize() { 34 bool WaylandConnection::Initialize() {
30 static const wl_registry_listener registry_listener = { 35 static const wl_registry_listener registry_listener = {
31 &WaylandConnection::Global, &WaylandConnection::GlobalRemove, 36 &WaylandConnection::Global, &WaylandConnection::GlobalRemove,
32 }; 37 };
33 38
34 display_.reset(wl_display_connect(nullptr)); 39 display_.reset(wl_display_connect(nullptr));
35 if (!display_) { 40 if (!display_) {
36 LOG(ERROR) << "Failed to connect to Wayland display"; 41 LOG(ERROR) << "Failed to connect to Wayland display";
37 return false; 42 return false;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 103
99 void WaylandConnection::AddWindow(gfx::AcceleratedWidget widget, 104 void WaylandConnection::AddWindow(gfx::AcceleratedWidget widget,
100 WaylandWindow* window) { 105 WaylandWindow* window) {
101 window_map_[widget] = window; 106 window_map_[widget] = window;
102 } 107 }
103 108
104 void WaylandConnection::RemoveWindow(gfx::AcceleratedWidget widget) { 109 void WaylandConnection::RemoveWindow(gfx::AcceleratedWidget widget) {
105 window_map_.erase(widget); 110 window_map_.erase(widget);
106 } 111 }
107 112
113 WaylandOutput* WaylandConnection::PrimaryOutput() const {
114 if (!output_list_.size())
115 return nullptr;
116 return output_list_.front();
117 }
118
108 void WaylandConnection::OnDispatcherListChanged() { 119 void WaylandConnection::OnDispatcherListChanged() {
109 StartProcessingEvents(); 120 StartProcessingEvents();
110 } 121 }
111 122
112 void WaylandConnection::Flush() { 123 void WaylandConnection::Flush() {
113 wl_display_flush(display_.get()); 124 wl_display_flush(display_.get());
114 scheduled_flush_ = false; 125 scheduled_flush_ = false;
115 } 126 }
116 127
117 void WaylandConnection::DispatchUiEvent(Event* event) { 128 void WaylandConnection::DispatchUiEvent(Event* event) {
118 PlatformEventSource::DispatchEvent(event); 129 PlatformEventSource::DispatchEvent(event);
119 } 130 }
120 131
121 void WaylandConnection::OnFileCanReadWithoutBlocking(int fd) { 132 void WaylandConnection::OnFileCanReadWithoutBlocking(int fd) {
122 wl_display_dispatch(display_.get()); 133 wl_display_dispatch(display_.get());
123 for (const auto& window : window_map_) 134 for (const auto& window : window_map_)
124 window.second->ApplyPendingBounds(); 135 window.second->ApplyPendingBounds();
125 } 136 }
126 137
127 void WaylandConnection::OnFileCanWriteWithoutBlocking(int fd) {} 138 void WaylandConnection::OnFileCanWriteWithoutBlocking(int fd) {}
128 139
140 const std::vector<WaylandOutput*>& WaylandConnection::GetOutputList() const {
141 return output_list_;
142 }
143
129 // static 144 // static
130 void WaylandConnection::Global(void* data, 145 void WaylandConnection::Global(void* data,
131 wl_registry* registry, 146 wl_registry* registry,
132 uint32_t name, 147 uint32_t name,
133 const char* interface, 148 const char* interface,
134 uint32_t version) { 149 uint32_t version) {
135 static const wl_seat_listener seat_listener = { 150 static const wl_seat_listener seat_listener = {
136 &WaylandConnection::Capabilities, &WaylandConnection::Name, 151 &WaylandConnection::Capabilities, &WaylandConnection::Name,
137 }; 152 };
138 static const xdg_shell_listener shell_listener = { 153 static const xdg_shell_listener shell_listener = {
(...skipping 23 matching lines...) Expand all
162 connection->shell_ = wl::Bind<xdg_shell>( 177 connection->shell_ = wl::Bind<xdg_shell>(
163 registry, name, std::min(version, kMaxXdgShellVersion)); 178 registry, name, std::min(version, kMaxXdgShellVersion));
164 if (!connection->shell_) { 179 if (!connection->shell_) {
165 LOG(ERROR) << "Failed to bind to xdg_shell global"; 180 LOG(ERROR) << "Failed to bind to xdg_shell global";
166 return; 181 return;
167 } 182 }
168 xdg_shell_add_listener(connection->shell_.get(), &shell_listener, 183 xdg_shell_add_listener(connection->shell_.get(), &shell_listener,
169 connection); 184 connection);
170 xdg_shell_use_unstable_version(connection->shell_.get(), 185 xdg_shell_use_unstable_version(connection->shell_.get(),
171 XDG_SHELL_VERSION_CURRENT); 186 XDG_SHELL_VERSION_CURRENT);
187 } else if (strcmp(interface, "wl_output") == 0) {
188 wl::Object<wl_output> output = wl::Bind<wl_output>(registry, name, 1);
189 if (!output) {
190 LOG(ERROR) << "Failed to bind to wl_output global";
191 return;
192 }
193
194 WaylandOutput* wayland_output = new WaylandOutput(output.release());
195 if (!connection->output_list_.empty())
196 NOTIMPLEMENTED() << "Multiple screens support is not implemented";
197
198 connection->output_list_.push_back(wayland_output);
172 } 199 }
173 200
174 connection->ScheduleFlush(); 201 connection->ScheduleFlush();
175 } 202 }
176 203
177 // static 204 // static
178 void WaylandConnection::GlobalRemove(void* data, 205 void WaylandConnection::GlobalRemove(void* data,
179 wl_registry* registry, 206 wl_registry* registry,
180 uint32_t name) { 207 uint32_t name) {
181 NOTIMPLEMENTED(); 208 NOTIMPLEMENTED();
(...skipping 25 matching lines...) Expand all
207 void WaylandConnection::Name(void* data, wl_seat* seat, const char* name) {} 234 void WaylandConnection::Name(void* data, wl_seat* seat, const char* name) {}
208 235
209 // static 236 // static
210 void WaylandConnection::Ping(void* data, xdg_shell* shell, uint32_t serial) { 237 void WaylandConnection::Ping(void* data, xdg_shell* shell, uint32_t serial) {
211 WaylandConnection* connection = static_cast<WaylandConnection*>(data); 238 WaylandConnection* connection = static_cast<WaylandConnection*>(data);
212 xdg_shell_pong(shell, serial); 239 xdg_shell_pong(shell, serial);
213 connection->ScheduleFlush(); 240 connection->ScheduleFlush();
214 } 241 }
215 242
216 } // namespace ui 243 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698