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

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

Issue 2639053002: [ozone/wayland] Implement basic keyboard handling support (Closed)
Patch Set: addressed kpschoedel's review Created 3 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
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/fake_server.h" 5 #include "ui/ozone/platform/wayland/fake_server.h"
6 6
7 #include <sys/socket.h> 7 #include <sys/socket.h>
8 #include <wayland-server.h> 8 #include <wayland-server.h>
9 #include <xdg-shell-unstable-v5-server-protocol.h> 9 #include <xdg-shell-unstable-v5-server-protocol.h>
10 10
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 auto seat = static_cast<MockSeat*>(wl_resource_get_user_data(resource)); 130 auto seat = static_cast<MockSeat*>(wl_resource_get_user_data(resource));
131 wl_resource* pointer_resource = wl_resource_create( 131 wl_resource* pointer_resource = wl_resource_create(
132 client, &wl_pointer_interface, wl_resource_get_version(resource), id); 132 client, &wl_pointer_interface, wl_resource_get_version(resource), id);
133 if (!pointer_resource) { 133 if (!pointer_resource) {
134 wl_client_post_no_memory(client); 134 wl_client_post_no_memory(client);
135 return; 135 return;
136 } 136 }
137 seat->pointer.reset(new MockPointer(pointer_resource)); 137 seat->pointer.reset(new MockPointer(pointer_resource));
138 } 138 }
139 139
140 void GetKeyboard(wl_client* client, wl_resource* resource, uint32_t id) {
141 auto seat = static_cast<MockSeat*>(wl_resource_get_user_data(resource));
142 wl_resource* keyboard_resource = wl_resource_create(
143 client, &wl_keyboard_interface, wl_resource_get_version(resource), id);
144 if (!keyboard_resource) {
145 wl_client_post_no_memory(client);
146 return;
147 }
148 seat->keyboard.reset(new MockKeyboard(keyboard_resource));
149 }
150
140 const struct wl_seat_interface seat_impl = { 151 const struct wl_seat_interface seat_impl = {
141 &GetPointer, // get_pointer 152 &GetPointer, // get_pointer
142 nullptr, // get_keyboard 153 &GetKeyboard, // get_keyboard
143 nullptr, // get_touch, 154 nullptr, // get_touch,
144 &DestroyResource, // release 155 &DestroyResource, // release
145 }; 156 };
146 157
158 // wl_keyboard
159
160 const struct wl_keyboard_interface keyboard_impl = {
161 &DestroyResource, // release
162 };
163
147 // wl_pointer 164 // wl_pointer
148 165
149 const struct wl_pointer_interface pointer_impl = { 166 const struct wl_pointer_interface pointer_impl = {
150 nullptr, // set_cursor 167 nullptr, // set_cursor
151 &DestroyResource, // release 168 &DestroyResource, // release
152 }; 169 };
153 170
154 // xdg_surface 171 // xdg_surface
155 172
156 void SetTitle(wl_client* client, wl_resource* resource, const char* title) { 173 void SetTitle(wl_client* client, wl_resource* resource, const char* title) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 return static_cast<MockSurface*>(wl_resource_get_user_data(resource)); 255 return static_cast<MockSurface*>(wl_resource_get_user_data(resource));
239 } 256 }
240 257
241 MockPointer::MockPointer(wl_resource* resource) : ServerObject(resource) { 258 MockPointer::MockPointer(wl_resource* resource) : ServerObject(resource) {
242 wl_resource_set_implementation(resource, &pointer_impl, this, 259 wl_resource_set_implementation(resource, &pointer_impl, this,
243 &ServerObject::OnResourceDestroyed); 260 &ServerObject::OnResourceDestroyed);
244 } 261 }
245 262
246 MockPointer::~MockPointer() {} 263 MockPointer::~MockPointer() {}
247 264
265 MockKeyboard::MockKeyboard(wl_resource* resource) : ServerObject(resource) {
266 wl_resource_set_implementation(resource, &keyboard_impl, this,
267 &ServerObject::OnResourceDestroyed);
268 }
269
270 MockKeyboard::~MockKeyboard() {}
271
248 void GlobalDeleter::operator()(wl_global* global) { 272 void GlobalDeleter::operator()(wl_global* global) {
249 wl_global_destroy(global); 273 wl_global_destroy(global);
250 } 274 }
251 275
252 Global::Global(const wl_interface* interface, 276 Global::Global(const wl_interface* interface,
253 const void* implementation, 277 const void* implementation,
254 uint32_t version) 278 uint32_t version)
255 : interface_(interface), 279 : interface_(interface),
256 implementation_(implementation), 280 implementation_(implementation),
257 version_(version) {} 281 version_(version) {}
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 } 428 }
405 429
406 void FakeServer::OnFileCanReadWithoutBlocking(int fd) { 430 void FakeServer::OnFileCanReadWithoutBlocking(int fd) {
407 wl_event_loop_dispatch(event_loop_, 0); 431 wl_event_loop_dispatch(event_loop_, 0);
408 wl_display_flush_clients(display_.get()); 432 wl_display_flush_clients(display_.get());
409 } 433 }
410 434
411 void FakeServer::OnFileCanWriteWithoutBlocking(int fd) {} 435 void FakeServer::OnFileCanWriteWithoutBlocking(int fd) {}
412 436
413 } // namespace wl 437 } // namespace wl
OLDNEW
« no previous file with comments | « ui/ozone/platform/wayland/fake_server.h ('k') | ui/ozone/platform/wayland/ozone_platform_wayland.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698