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

Unified Diff: ui/ozone/platform/wayland/fake_server.cc

Issue 1712103002: ozone/platform/wayland: Implement pointer handling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/ozone/platform/wayland/fake_server.h ('k') | ui/ozone/platform/wayland/wayland.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/platform/wayland/fake_server.cc
diff --git a/ui/ozone/platform/wayland/fake_server.cc b/ui/ozone/platform/wayland/fake_server.cc
index 128ff049ba2fd76f1413af692fda2a5461ac9b06..0465728b1b20ae3a7be2c4f54c7d609181dead67 100644
--- a/ui/ozone/platform/wayland/fake_server.cc
+++ b/ui/ozone/platform/wayland/fake_server.cc
@@ -17,6 +17,7 @@ namespace wl {
namespace {
const uint32_t kCompositorVersion = 4;
+const uint32_t kSeatVersion = 4;
const uint32_t kXdgShellVersion = 1;
void DestroyResource(wl_client* client, wl_resource* resource) {
@@ -121,6 +122,33 @@ const struct xdg_shell_interface xdg_shell_impl = {
&Pong, // pong
};
+// wl_seat
+
+void GetPointer(wl_client* client, wl_resource* resource, uint32_t id) {
+ auto seat = static_cast<MockSeat*>(wl_resource_get_user_data(resource));
+ wl_resource* pointer_resource = wl_resource_create(
+ client, &wl_pointer_interface, wl_resource_get_version(resource), id);
+ if (!pointer_resource) {
+ wl_client_post_no_memory(client);
+ return;
+ }
+ seat->pointer.reset(new MockPointer(pointer_resource));
+}
+
+const struct wl_seat_interface seat_impl = {
+ &GetPointer, // get_pointer
+ nullptr, // get_keyboard
+ nullptr, // get_touch,
+ &DestroyResource, // release
+};
+
+// wl_pointer
+
+const struct wl_pointer_interface pointer_impl = {
+ nullptr, // set_cursor
+ &DestroyResource, // release
+};
+
// xdg_surface
void SetTitle(wl_client* client, wl_resource* resource, const char* title) {
@@ -208,6 +236,13 @@ MockSurface* MockSurface::FromResource(wl_resource* resource) {
return static_cast<MockSurface*>(wl_resource_get_user_data(resource));
}
+MockPointer::MockPointer(wl_resource* resource) : ServerObject(resource) {
+ wl_resource_set_implementation(resource, &pointer_impl, this,
+ &ServerObject::OnResourceDestroyed);
+}
+
+MockPointer::~MockPointer() {}
+
void GlobalDeleter::operator()(wl_global* global) {
wl_global_destroy(global);
}
@@ -260,6 +295,10 @@ void MockCompositor::AddSurface(scoped_ptr<MockSurface> surface) {
surfaces_.push_back(std::move(surface));
}
+MockSeat::MockSeat() : Global(&wl_seat_interface, &seat_impl, kSeatVersion) {}
+
+MockSeat::~MockSeat() {}
+
MockXdgShell::MockXdgShell()
: Global(&xdg_shell_interface, &xdg_shell_impl, kXdgShellVersion) {}
@@ -295,6 +334,8 @@ bool FakeServer::Start() {
return false;
if (!compositor_.Initialize(display_.get()))
return false;
+ if (!seat_.Initialize(display_.get()))
+ return false;
if (!xdg_shell_.Initialize(display_.get()))
return false;
« no previous file with comments | « ui/ozone/platform/wayland/fake_server.h ('k') | ui/ozone/platform/wayland/wayland.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698