Initial support for Wayland 1.3. 34/13334/1
authorOssama Othman <ossama.othman@intel.com>
Tue, 3 Dec 2013 18:50:45 +0000 (10:50 -0800)
committerOssama Othman <ossama.othman@intel.com>
Tue, 3 Dec 2013 18:50:45 +0000 (10:50 -0800)
These changes are intended to get the layer management service to
build against Wayland 1.3.  The port is not yet complete, however.
Areas that need work are marked with a "@todo Port to Wayland 1.3"
comment.

Change-Id: I8e00ee901854dde216540fd0272b5378bc47131b
Signed-off-by: Ossama Othman <ossama.othman@intel.com>
LayerManagerPlugins/Renderers/Graphic/include/WindowSystems/WaylandBaseWindowSystem.h
LayerManagerPlugins/Renderers/Graphic/include/WindowSystems/WaylandInputDevice.h
LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/WaylandGLESTexture.cpp
LayerManagerPlugins/Renderers/Graphic/src/WindowSystems/WaylandBaseWindowSystem.cpp
LayerManagerPlugins/Renderers/Graphic/src/WindowSystems/WaylandEvdevInputEvent.cpp
LayerManagerPlugins/Renderers/Graphic/src/WindowSystems/WaylandInputDevice.cpp

index 72d3bf9..8e89d59 100644 (file)
@@ -241,7 +241,7 @@ inline int WaylandBaseWindowSystem::getWindowHeight() const
 extern "C" {
 struct native_surface
 {
-    struct wl_surface surface;
+    struct wl_surface* surface;
     WaylandBaseWindowSystem* windowSystem;
     struct wl_buffer* buffer;
     int connectionId;
@@ -271,7 +271,7 @@ struct native_surface
 
 struct native_frame_callback
 {
-    struct wl_resource resource;
+    struct wl_resource* resource;
     struct wl_list link;
 };
 
index a391aa8..9da3a90 100644 (file)
@@ -39,7 +39,7 @@ class WaylandInputDevice
 // Properties
 private:
     struct wl_display* m_wlDisplay;
-    struct wl_seat     m_wlSeat;
+    struct wl_seat*    m_wlSeat;
     bool               m_hasPointer;
     bool               m_hasKeyboard;
     bool               m_hasTouch;
@@ -52,9 +52,9 @@ private:
 
     struct
     {
-        struct wl_pointer  wlPointer;
-        struct wl_keyboard wlKeyboard;
-        struct wl_touch    wlTouch;
+        struct wl_pointer*  wlPointer;
+        struct wl_keyboard* wlKeyboard;
+        struct wl_touch*    wlTouch;
     } m_deviceInterfaces;
 
 // Methods
@@ -137,7 +137,7 @@ inline struct wl_display* WaylandInputDevice::display()
 
 inline struct wl_seat* WaylandInputDevice::seat()
 {
-    return &m_wlSeat;
+    return m_wlSeat;
 }
 
 inline bool WaylandInputDevice::hasPointer() const
@@ -157,32 +157,32 @@ inline bool WaylandInputDevice::hasTouch() const
 
 inline struct wl_pointer* WaylandInputDevice::pointerDevice()
 {
-    return &m_deviceInterfaces.wlPointer;
+    return m_deviceInterfaces.wlPointer;
 }
 
 inline struct wl_keyboard* WaylandInputDevice::keyboardDevice()
 {
-    return &m_deviceInterfaces.wlKeyboard;
+    return m_deviceInterfaces.wlKeyboard;
 }
 
 inline struct wl_touch* WaylandInputDevice::touchDevice()
 {
-    return &m_deviceInterfaces.wlTouch;
+    return m_deviceInterfaces.wlTouch;
 }
 
 inline const struct wl_pointer* WaylandInputDevice::pointerDevice() const
 {
-    return &m_deviceInterfaces.wlPointer;
+    return m_deviceInterfaces.wlPointer;
 }
 
 inline const struct wl_keyboard* WaylandInputDevice::keyboardDevice() const
 {
-    return &m_deviceInterfaces.wlKeyboard;
+    return m_deviceInterfaces.wlKeyboard;
 }
 
 inline const struct wl_touch* WaylandInputDevice::touchDevice() const
 {
-    return &m_deviceInterfaces.wlTouch;
+    return m_deviceInterfaces.wlTouch;
 }
 
 #endif /* _WAYLANDINPUTDEVICE_H_ */
index 8eeeb9f..b470509 100644 (file)
@@ -55,10 +55,18 @@ bool WaylandGLESTexture::bindSurfaceTexture(Surface* surface)
     if (nativeSurface && nativeSurface->isReadyForRendering())
     {
         struct wl_buffer* buffer = (struct wl_buffer*)surface->getNativeContent();
-        if (wl_buffer_is_shm(buffer))
+        /**
+         * @todo Port to Wayland 1.3.
+         */
+        if (0 // wl_buffer_is_shm(buffer)
+            )
         {
             /* Wayland SHM buffer */
-            unsigned int* pBuf = (unsigned int*)wl_shm_buffer_get_data(buffer);
+            /**
+             * @todo Port to Wayland 1.3.
+             */
+            unsigned int* pBuf = (unsigned int*)wl_shm_buffer_get_data(NULL // buffer
+                );
             if ((NULL != buffer) && (NULL != pBuf))
             {
                 LOG_DEBUG("WaylandGLESTexture", "SHM buffer address:" << pBuf);
@@ -125,7 +133,11 @@ void WaylandGLESTexture::createClientBuffer(Surface* surface)
     if (NULL != nativeSurface)
     {
         struct wl_buffer* buffer = (struct wl_buffer*)surface->getNativeContent();
-        if (wl_buffer_is_shm(buffer))
+        /**
+         * @todo Port to Wayland 1.3.
+         */
+        if (0 // wl_buffer_is_shm(buffer)
+            )
         {
             if (nativeSurface->texture)
             {
@@ -179,7 +191,11 @@ void WaylandGLESTexture::destroyClientBuffer(Surface* surface)
     EglWaylandPlatformSurface* nativeSurface = (EglWaylandPlatformSurface*)surface->platform;
 
     struct wl_buffer* buffer = (struct wl_buffer*)surface->getNativeContent();
-    if (wl_buffer_is_shm(buffer))
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    if (0 // wl_buffer_is_shm(buffer)
+        )
     {
         if (nativeSurface && nativeSurface->texture)
         {
index 286dd71..92943ef 100644 (file)
@@ -231,10 +231,13 @@ Surface* WaylandBaseWindowSystem::getSurfaceFromNativeSurface(struct native_surf
         {
             continue;
         }
-        if (nativePlatform->surfaceId != nativeSurface->surface.resource.object.id)
-        {
-            continue;
-        }
+        /**
+         * @todo Port to Wayland 1.3.
+         */
+        // if (nativePlatform->surfaceId != nativeSurface->surface->resource.object.id)
+        // {
+        //     continue;
+        // }
         return currentSurface;
     }
     LOG_DEBUG("WaylandBaseWindowSystem", "could not find surface for surface " << nativeSurface);
@@ -254,8 +257,12 @@ WaylandBaseWindowSystem::getNativeSurfaceFromSurface(Surface* surface)
 
     wl_list_for_each(nativeSurface, &m_nativeSurfaceList, link)
     {
-        if ((nativeSurface->connectionId == platformSurface->connectionId) &&
-            (nativeSurface->surface.resource.object.id == platformSurface->surfaceId))
+        /**
+         * @todo Port to Wayland 1.3.
+         */
+        if ((nativeSurface->connectionId == platformSurface->connectionId)//  &&
+            // (nativeSurface->surface->resource.object.id == platformSurface->surfaceId)
+            )
         {
             break; // FOUND
         }
@@ -516,11 +523,17 @@ struct native_surface* WaylandBaseWindowSystem::createNativeSurface()
         return NULL;
     }
 
-    wl_signal_init(&surface->surface.resource.destroy_signal);
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    // wl_signal_init(&surface->surface->resource.destroy_signal);
 
     wl_list_init(&surface->link);
 
-    surface->surface.resource.client = NULL;
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    // surface->surface->resource.client = NULL;
 
     surface->windowSystem = this;
     // TODO visual
@@ -550,7 +563,10 @@ uint32_t WaylandBaseWindowSystem::getTime(void)
 
 void WaylandBaseWindowSystem::destroySurfaceCallback(struct wl_resource* resource)
 {
-    struct native_surface* nativeSurface = wl_container_of(resource, nativeSurface, surface.resource);
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    struct native_surface* nativeSurface = NULL; // wl_container_of(resource, nativeSurface, surface->resource);
     WaylandBaseWindowSystem* windowSystem = static_cast<WaylandBaseWindowSystem*>((WaylandBaseWindowSystem*)nativeSurface->windowSystem);
     Surface* ilmSurface = windowSystem->getSurfaceFromNativeSurface(nativeSurface);
 
@@ -710,13 +726,17 @@ extern "C" void WaylandBaseWindowSystem::surfaceIFFrame(struct wl_client *client
         return;
     }
 
-    cb->resource.object.interface = &wl_callback_interface;
-    cb->resource.object.id = callback;
-    cb->resource.destroy = destroyFrameCallback;
-    cb->resource.client = client;
-    cb->resource.data = cb;
+    cb->resource = wl_resource_create(client, &wl_callback_interface, 1,
+                                      callback);
+    if (cb->resource == NULL) {
+        free(cb);
+        wl_resource_post_no_memory(resource);
+        return;
+    }
+
+    wl_resource_set_implementation(cb->resource, NULL, cb,
+                                   destroyFrameCallback);
 
-    wl_client_add_resource(client, &cb->resource);
     wl_list_insert(es->pending.frame_callback_list.prev, &cb->link);
 
     LOG_DEBUG("WaylandBaseWindowSystem", "surfaceIFFrame OUT");
@@ -748,7 +768,7 @@ extern "C" void WaylandBaseWindowSystem::surfaceIFCommit(struct wl_client *clien
             wl_signal_add(&buffer->resource.destroy_signal, &nativeSurface->buffer_destroy_listener);
         }
     }
-    windowSystem->attachBufferToNativeSurface(buffer, &nativeSurface->surface);
+    windowSystem->attachBufferToNativeSurface(buffer, nativeSurface->surface);
     nativeSurface->buffer = buffer;
 
     if (NULL != surface)
@@ -797,13 +817,16 @@ extern "C" void WaylandBaseWindowSystem::compositorIFCreateSurface
         return;
     }
 
-    surface->surface.resource.destroy = destroySurfaceCallback;
-    surface->windowSystem = windowSystem;
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    // surface->surface.resource.destroy = destroySurfaceCallback;
+    // surface->windowSystem = windowSystem;
 
-    surface->surface.resource.object.id = id;
-    surface->surface.resource.object.interface = &wl_surface_interface;
-    surface->surface.resource.object.implementation = (void (**)(void))&g_surfaceInterface;
-    surface->surface.resource.data = surface;
+    // surface->surface.resource.object.id = id;
+    // surface->surface.resource.object.interface = &wl_surface_interface;
+    // surface->surface.resource.object.implementation = (void (**)(void))&g_surfaceInterface;
+    // surface->surface.resource.data = surface;
 
     struct serverinfoClient* serverinfoPairNode;
 
@@ -818,7 +841,10 @@ extern "C" void WaylandBaseWindowSystem::compositorIFCreateSurface
     }
 
     windowSystem->checkForNewSurfaceNativeContent();
-    wl_client_add_resource(client, &surface->surface.resource);
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    // wl_client_add_resource(client, &surface->surface.resource);
     wl_list_insert(windowSystem->m_nativeSurfaceList.prev, &surface->link);
     LOG_DEBUG("WaylandBaseWindowSystem", "compositorIFCreateSurface OUT");
 }
@@ -855,8 +881,8 @@ void WaylandBaseWindowSystem::repaint(int msecs)
 
     wl_list_for_each_safe(cb, cnext, &m_listFrameCallback, link)
     {
-        wl_callback_send_done(&cb->resource, msecs);
-        wl_resource_destroy(&cb->resource);
+        wl_callback_send_done(cb->resource, msecs);
+        wl_resource_destroy(cb->resource);
     }
     LOG_DEBUG("WaylandBaseWindowSystem", "repaint OUT");
 }
@@ -1337,11 +1363,11 @@ void WaylandBaseWindowSystem::manageWLInputEvent(const InputDevice type,
             {
             case INPUT_STATE_PRESSED:
                 m_inputEvent->inputDevice().sendKeyPressEvent(
-                    &nativeSurface->surface, time, wlEvent->keyCode);
+                    nativeSurface->surface, time, wlEvent->keyCode);
                 break;
             case INPUT_STATE_RELEASED:
                 m_inputEvent->inputDevice().sendKeyReleaseEvent(
-                    &nativeSurface->surface, time, wlEvent->keyCode);
+                    nativeSurface->surface, time, wlEvent->keyCode);
                 break;
             case INPUT_STATE_OTHER:
             default:
@@ -1384,7 +1410,7 @@ void WaylandBaseWindowSystem::manageWLInputEvent(const InputDevice type,
                 break;
             case INPUT_STATE_MOTION:
                 m_inputEvent->inputDevice().sendMouseMotionEvent(
-                    &nativeSurface->surface, globalPos, localPos, time);
+                    nativeSurface->surface, globalPos, localPos, time);
                 break;
             case INPUT_STATE_OTHER:
             default:
@@ -1414,7 +1440,7 @@ void WaylandBaseWindowSystem::manageWLInputEvent(const InputDevice type,
             case INPUT_STATE_MOTION:
             case INPUT_STATE_RELEASED:
                 m_inputEvent->inputDevice().sendTouchPointEvent(
-                    &nativeSurface->surface, time, wlEvent->touchId,
+                    nativeSurface->surface, time, wlEvent->touchId,
                     wlEvent->touchType, ptVec[0]);
                 break;
             case INPUT_STATE_OTHER:
index 33f1547..fac99e5 100644 (file)
@@ -960,15 +960,24 @@ WaylandEvdevInputEvent::notifyKeyboardFocusIn(struct wl_array *keys,
     {
         return;
     }
-    if (!wlSeat->keyboard)
-    {
-        return;
-    }
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    // if (!wlSeat->keyboard)
+    // {
+    //     return;
+    // }
     serial = wl_display_next_serial(m_inputDevice->display());
-    wl_array_init(&wlSeat->keyboard->keys);
-    wl_array_copy(&wlSeat->keyboard->keys, keys);
-
-    struct wl_array *array = &wlSeat->keyboard->keys;
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    // wl_array_init(&wlSeat->keyboard->keys);
+    // wl_array_copy(&wlSeat->keyboard->keys, keys);
+
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    struct wl_array *array = NULL; // &wlSeat->keyboard->keys;
     for (k = (uint32_t*)array->data;
         (const char*)k < (const char*)array->data + array->size;
         ++k)
@@ -1150,9 +1159,12 @@ WaylandEvdevInputEvent::flushMotion(struct evdev_input_device *device,
         if (wlSeat)
         {
             // notify_motion
-            notifyMotion(device, time,
-                        wlSeat->pointer->x + device->rel.dx,
-                        wlSeat->pointer->y + device->rel.dy);
+            /**
+             * @todo Port to Wayland 1.3.
+             */
+            // notifyMotion(device, time,
+            //             wlSeat->pointer->x + device->rel.dx,
+            //             wlSeat->pointer->y + device->rel.dy);
         }
         device->pending_events &= ~EVDEV_RELATIVE_MOTION;
         device->rel.dx = 0;
@@ -1531,35 +1543,38 @@ WaylandEvdevInputEvent::notifyButton(struct evdev_input_device *device,
     wlSeat = inputEvent->inputDevice().seat();
     serial = wl_display_next_serial(inputEvent->inputDevice().display());
 
-    if (state == WL_POINTER_BUTTON_STATE_PRESSED)
-    {
-        if (wlSeat->pointer->button_count == 0)
-        {
-            wlSeat->pointer->grab_button = button;
-            wlSeat->pointer->grab_time = time;
-            wlSeat->pointer->grab_x = wlSeat->pointer->x;
-            wlSeat->pointer->grab_y = wlSeat->pointer->y;
-        }
-        ++wlSeat->pointer->button_count;
-    }
-    else
-    {
-        --wlSeat->pointer->button_count;
-    }
-    wlEvent.x = wl_fixed_to_int(wlSeat->pointer->x);
-    wlEvent.y = wl_fixed_to_int(wlSeat->pointer->y);
-    wlEvent.buttonState = state;
-    wlEvent.serial = serial;
-
-    inputEvent->windowSystem().manageWLInputEvent(INPUT_DEVICE_POINTER,
-        state == WL_POINTER_BUTTON_STATE_PRESSED ? INPUT_STATE_PRESSED :
-        INPUT_STATE_RELEASED, &wlEvent);
-
-    if (wlSeat->pointer->button_count == 1)
-    {
-        wlSeat->pointer->grab_serial =
-            wl_display_get_serial(inputEvent->inputDevice().display());
-    }
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    // if (state == WL_POINTER_BUTTON_STATE_PRESSED)
+    // {
+    //     if (wlSeat->pointer->button_count == 0)
+    //     {
+    //         wlSeat->pointer->grab_button = button;
+    //         wlSeat->pointer->grab_time = time;
+    //         wlSeat->pointer->grab_x = wlSeat->pointer->x;
+    //         wlSeat->pointer->grab_y = wlSeat->pointer->y;
+    //     }
+    //     ++wlSeat->pointer->button_count;
+    // }
+    // else
+    // {
+    //     --wlSeat->pointer->button_count;
+    // }
+    // wlEvent.x = wl_fixed_to_int(wlSeat->pointer->x);
+    // wlEvent.y = wl_fixed_to_int(wlSeat->pointer->y);
+    // wlEvent.buttonState = state;
+    // wlEvent.serial = serial;
+
+    // inputEvent->windowSystem().manageWLInputEvent(INPUT_DEVICE_POINTER,
+    //     state == WL_POINTER_BUTTON_STATE_PRESSED ? INPUT_STATE_PRESSED :
+    //     INPUT_STATE_RELEASED, &wlEvent);
+
+    // if (wlSeat->pointer->button_count == 1)
+    // {
+    //     wlSeat->pointer->grab_serial =
+    //         wl_display_get_serial(inputEvent->inputDevice().display());
+    // }
 }
 
 void
@@ -1594,8 +1609,11 @@ WaylandEvdevInputEvent::notifyMotion(struct evdev_input_device *device,
     if (y < 0) y = 0;
     if (y > h) y = h;
 
-    wlSeat->pointer->x = wl_fixed_from_int(x);
-    wlSeat->pointer->y = wl_fixed_from_int(y);
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    // wlSeat->pointer->x = wl_fixed_from_int(x);
+    // wlSeat->pointer->y = wl_fixed_from_int(y);
 
     wlEvent.x = x;
     wlEvent.y = y;
@@ -1624,27 +1642,33 @@ WaylandEvdevInputEvent::notifyKey(struct evdev_input_device *device,
     wlSeat = inputEvent->inputDevice().seat();
     if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
     {
-        wlSeat->keyboard->grab_key = key;
-        wlSeat->keyboard->grab_time = time;
-    }
-
-    end = (uint32_t*)(((unsigned char*)wlSeat->keyboard->keys.data) + wlSeat->keyboard->keys.size);
-    for (k = (uint32_t*)wlSeat->keyboard->keys.data; k < end; ++k)
-    {
-        if (*k == key)
-        {
-            // Ignore server-generated repeats
-            if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
-                return;
-            *k = *--end;
-        }
-    }
-    wlSeat->keyboard->keys.size = end - (uint32_t*)wlSeat->keyboard->keys.data;
-    if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
-    {
-        k = (uint32_t*)wl_array_add(&wlSeat->keyboard->keys, sizeof(*k));
-        *k = key;
-    }
+        /**
+         * @todo Port to Wayland 1.3.
+         */
+        // wlSeat->keyboard->grab_key = key;
+        // wlSeat->keyboard->grab_time = time;
+    }
+
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    // end = (uint32_t*)(((unsigned char*)wlSeat->keyboard->keys.data) + wlSeat->keyboard->keys.size);
+    // for (k = (uint32_t*)wlSeat->keyboard->keys.data; k < end; ++k)
+    // {
+    //     if (*k == key)
+    //     {
+    //         // Ignore server-generated repeats
+    //         if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
+    //             return;
+    //         *k = *--end;
+    //     }
+    // }
+    // wlSeat->keyboard->keys.size = end - (uint32_t*)wlSeat->keyboard->keys.data;
+    // if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
+    // {
+    //     k = (uint32_t*)wl_array_add(&wlSeat->keyboard->keys, sizeof(*k));
+    //     *k = key;
+    // }
 
     wlEvent.keyCode = key;
     wlEvent.keyState = state;
@@ -1711,18 +1735,21 @@ WaylandEvdevInputEvent::notifyModifiers(struct wl_seat *wlSeat, uint32_t serial)
     mods_locked = xkb_state_serialize_mods(m_xkbState.state, (xkb_state_component)XKB_STATE_LOCKED);
     group = xkb_state_serialize_mods(m_xkbState.state, (xkb_state_component)XKB_STATE_EFFECTIVE);
 
-    if (mods_depressed != wlSeat->keyboard->modifiers.mods_depressed ||
-        mods_latched != wlSeat->keyboard->modifiers.mods_latched ||
-        mods_locked != wlSeat->keyboard->modifiers.mods_locked ||
-        group != wlSeat->keyboard->modifiers.group)
-    {
-        changed = 1;
-    }
-
-    wlSeat->keyboard->modifiers.mods_depressed = mods_depressed;
-    wlSeat->keyboard->modifiers.mods_latched = mods_latched;
-    wlSeat->keyboard->modifiers.mods_locked = mods_locked;
-    wlSeat->keyboard->modifiers.group = group;
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    // if (mods_depressed != wlSeat->keyboard->modifiers.mods_depressed ||
+    //     mods_latched != wlSeat->keyboard->modifiers.mods_latched ||
+    //     mods_locked != wlSeat->keyboard->modifiers.mods_locked ||
+    //     group != wlSeat->keyboard->modifiers.group)
+    // {
+    //     changed = 1;
+    // }
+
+    // wlSeat->keyboard->modifiers.mods_depressed = mods_depressed;
+    // wlSeat->keyboard->modifiers.mods_latched = mods_latched;
+    // wlSeat->keyboard->modifiers.mods_locked = mods_locked;
+    // wlSeat->keyboard->modifiers.group = group;
 
     // And update the modifier_state for bindings
     mods_lookup = mods_depressed | mods_latched;
index 33d99e6..3f3dcdc 100644 (file)
 #include <string.h>
 #include "WindowSystems/WaylandInputDevice.h"
 
+/**
+ * @todo Port to Wayland 1.3.
+ */
+#include <wayland-client.h>
+
 /////////////////////////////////////////////////////////////////////////////
 
 static struct wl_resource*
@@ -50,16 +55,63 @@ findResourceForClient(struct wl_list *list, struct wl_client *client)
 
 /////////////////////////////////////////////////////////////////////////////
 
+/**
+ * @todo Port to Wayland 1.3.
+ */
+static const struct wl_seat_listener seat_listener = {
+    NULL, NULL
+    // seat_handle_capabilities,
+    // seat_handle_name
+};
+
+
+static void
+registry_handle_global(void *data, struct wl_registry *registry, uint32_t id,
+                       const char *interface, uint32_t version)
+{
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    void * user_data = NULL;
+
+    if (strcmp(interface, "wl_seat") == 0) {
+        wl_seat ** seat = (wl_seat **) data;
+        *seat = (wl_seat *) wl_registry_bind(registry, id, &wl_seat_interface,
+                                             version);
+
+        wl_seat_add_listener(*seat, &seat_listener, user_data);
+    }
+}
+
+static void
+registry_handle_global_remove(void *data, struct wl_registry *registry,
+                              uint32_t name)
+{
+}
+
+static const struct wl_registry_listener registry_listener = {
+    registry_handle_global,
+    registry_handle_global_remove
+};
+
+/////////////////////////////////////////////////////////////////////////////
+
 WaylandInputDevice::WaylandInputDevice(struct wl_display *display)
 : m_wlDisplay(display)
+, m_wlSeat(0)
 , m_hasPointer(false)
 , m_hasKeyboard(false)
 , m_hasTouch(false)
 , m_nTp(0)
 {
-    wl_seat_init(&m_wlSeat);
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    wl_registry * const registry = wl_display_get_registry(display);
+    wl_registry_add_listener(registry, &registry_listener, this);
+
     wl_display_add_global(m_wlDisplay,
-                            &wl_seat_interface,
+                          &wl_seat_interface,
                             this,
                             WaylandInputDevice::bindInputDevice);
 }
@@ -75,8 +127,7 @@ WaylandInputDevice::initPointerDevice()
     if (m_hasPointer)
         return;
 
-    wl_pointer_init(&m_deviceInterfaces.wlPointer);
-    wl_seat_set_pointer(&m_wlSeat, &m_deviceInterfaces.wlPointer);
+    m_deviceInterfaces.wlPointer = wl_seat_get_pointer(m_wlSeat);
 
     m_hasPointer = true;
     LOG_INFO("WaylandInputDevice", "Available pointer");
@@ -88,8 +139,7 @@ WaylandInputDevice::initKeyboardDevice()
     if (m_hasKeyboard)
         return;
 
-    wl_keyboard_init(&m_deviceInterfaces.wlKeyboard);
-    wl_seat_set_keyboard(&m_wlSeat, &m_deviceInterfaces.wlKeyboard);
+    m_deviceInterfaces.wlKeyboard = wl_seat_get_keyboard(m_wlSeat);
 
     m_hasKeyboard = true;
     LOG_INFO("WaylandInputDevice", "Available keyboard");
@@ -101,8 +151,7 @@ WaylandInputDevice::initTouchDevice()
     if (m_hasTouch)
         return;
 
-    wl_touch_init(&m_deviceInterfaces.wlTouch);
-    wl_seat_set_touch(&m_wlSeat, &m_deviceInterfaces.wlTouch);
+    m_deviceInterfaces.wlTouch = wl_seat_get_touch(m_wlSeat);
 
     m_hasTouch = true;
     LOG_INFO("WaylandInputDevice", "Available touch");
@@ -112,13 +161,13 @@ void
 WaylandInputDevice::releaseDevices()
 {
     if (m_hasPointer)
-        wl_pointer_release(&m_deviceInterfaces.wlPointer);
+        wl_pointer_release(m_deviceInterfaces.wlPointer);
 
     if (m_hasKeyboard)
-        wl_keyboard_release(&m_deviceInterfaces.wlKeyboard);
+        wl_keyboard_release(m_deviceInterfaces.wlKeyboard);
 
     if (m_hasTouch)
-        wl_touch_release(&m_deviceInterfaces.wlTouch);
+        wl_touch_release(m_deviceInterfaces.wlTouch);
 }
 
 void
@@ -145,7 +194,10 @@ WaylandInputDevice::bindInputDevice(struct wl_client *client,
     struct wl_seat *seat = inputDevice->seat();
 
     resource->destroy = WaylandInputDevice::destroyResource;
-    wl_list_insert(&seat->base_resource_list, &resource->link);
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    // wl_list_insert(&seat->base_resource_list, &resource->link);
 
     uint32_t caps = 0;
 
@@ -163,14 +215,17 @@ void
 WaylandInputDevice::destroyResource(struct wl_resource *resource)
 {
     WaylandInputDevice *inputDevice = static_cast<WaylandInputDevice*>(resource->data);
-    if (inputDevice->keyboardDevice()->focus_resource == resource)
-    {
-        inputDevice->keyboardDevice()->focus_resource = 0;
-    }
-    if (inputDevice->pointerDevice()->focus_resource == resource)
-    {
-        inputDevice->pointerDevice()->focus_resource = 0;
-    }
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    // if (inputDevice->keyboardDevice()->focus_resource == resource)
+    // {
+    //     inputDevice->keyboardDevice()->focus_resource = 0;
+    // }
+    // if (inputDevice->pointerDevice()->focus_resource == resource)
+    // {
+    //     inputDevice->pointerDevice()->focus_resource = 0;
+    // }
 
     inputDevice->cleanupDataDeviceForClient(resource->client, true);
 
@@ -204,7 +259,10 @@ WaylandInputDevice::getPointer(struct wl_client *client,
                                                        0,
                                                        id,
                                                        pointer);
-    wl_list_insert(&pointer->resource_list, &clientResource->link);
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    // wl_list_insert(&pointer->resource_list, &clientResource->link);
     clientResource->destroy = WaylandInputDevice::destroyDeviceResource;
 }
 
@@ -220,7 +278,10 @@ WaylandInputDevice::getKeyboard(struct wl_client *client,
                                                        0,
                                                        id,
                                                        keyboard);
-    wl_list_insert(&keyboard->resource_list, &clientResource->link);
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    // wl_list_insert(&keyboard->resource_list, &clientResource->link);
     clientResource->destroy = WaylandInputDevice::destroyDeviceResource;
 }
 
@@ -236,7 +297,10 @@ WaylandInputDevice::getTouch(struct wl_client *client,
                                                        0,
                                                        id,
                                                        touch);
-    wl_list_insert(&touch->resource_list, &clientResource->link);
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    // wl_list_insert(&touch->resource_list, &clientResource->link);
     clientResource->destroy = WaylandInputDevice::destroyDeviceResource;
 }
 
@@ -248,12 +312,15 @@ WaylandInputDevice::sendMousePressEvent(const Point& globalPos,
 {
     sendMouseMotionEvent(globalPos, localPos, time);
     wl_pointer *pointer = pointerDevice();
-    pointer->button_count++;
-    const struct wl_pointer_grab_interface *interface = pointer->grab->interface;
-    interface->button(pointer->grab,
-                      time,
-                      button,
-                      WL_POINTER_BUTTON_STATE_PRESSED);
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    // pointer->button_count++;
+    // const struct wl_pointer_grab_interface *interface = pointer->grab->interface;
+    // interface->button(pointer->grab,
+    //                   time,
+    //                   button,
+    //                   WL_POINTER_BUTTON_STATE_PRESSED);
 }
 
 void
@@ -264,12 +331,15 @@ WaylandInputDevice::sendMouseReleaseEvent(const Point& globalPos,
 {
     sendMouseMotionEvent(globalPos, localPos, time);
     wl_pointer *pointer = pointerDevice();
-    pointer->button_count--;
-    const struct wl_pointer_grab_interface *interface = pointer->grab->interface;
-    interface->button(pointer->grab,
-                      time,
-                      button,
-                      WL_POINTER_BUTTON_STATE_RELEASED);
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    // pointer->button_count--;
+    // const struct wl_pointer_grab_interface *interface = pointer->grab->interface;
+    // interface->button(pointer->grab,
+    //                   time,
+    //                   button,
+    //                   WL_POINTER_BUTTON_STATE_RELEASED);
 }
 
 void
@@ -288,13 +358,16 @@ WaylandInputDevice::sendMouseMotionEvent(const Point& globalPos,
                                          uint32_t time)
 {
     wl_pointer *pointer = pointerDevice();
-    const struct wl_pointer_grab_interface *interface = pointer->grab->interface;
-    pointer->x = wl_fixed_from_double(globalPos.x);
-    pointer->y = wl_fixed_from_double(globalPos.y);
-    interface->motion(pointer->grab,
-                      time,
-                      wl_fixed_from_double(localPos.x),
-                      wl_fixed_from_double(localPos.y));
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    // const struct wl_pointer_grab_interface *interface = pointer->grab->interface;
+    // pointer->x = wl_fixed_from_double(globalPos.x);
+    // pointer->y = wl_fixed_from_double(globalPos.y);
+    // interface->motion(pointer->grab,
+    //                   time,
+    //                   wl_fixed_from_double(localPos.x),
+    //                   wl_fixed_from_double(localPos.y));
 }
 
 void
@@ -302,16 +375,19 @@ WaylandInputDevice::sendKeyPressEvent(struct wl_surface* surface,
                                       uint32_t time, uint32_t code)
 {
     wl_keyboard *keyboard = keyboardDevice();
-    if (!keyboard->focus)
-    {
-        setKeyboardFocus(surface);
-    }
-    if (keyboard->focus_resource)
-    {
-        uint32_t serial = wl_display_next_serial(m_wlDisplay);
-        wl_keyboard_send_key(keyboard->focus_resource,
-                             serial, time, code, 1);
-    }
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    // if (!keyboard->focus)
+    // {
+    //     setKeyboardFocus(surface);
+    // }
+    // if (keyboard->focus_resource)
+    // {
+    //     uint32_t serial = wl_display_next_serial(m_wlDisplay);
+    //     wl_keyboard_send_key(keyboard->focus_resource,
+    //                          serial, time, code, 1);
+    // }
 }
 
 void
@@ -319,12 +395,15 @@ WaylandInputDevice::sendKeyReleaseEvent(struct wl_surface* /*surface*/,
                                         uint32_t time, uint32_t code)
 {
     wl_keyboard *keyboard = keyboardDevice();
-    if (keyboard->focus_resource)
-    {
-        uint32_t serial = wl_display_next_serial(m_wlDisplay);
-        wl_keyboard_send_key(keyboard->focus_resource,
-                            serial, time, code, 0);
-    }
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    // if (keyboard->focus_resource)
+    // {
+    //     uint32_t serial = wl_display_next_serial(m_wlDisplay);
+    //     wl_keyboard_send_key(keyboard->focus_resource,
+    //                         serial, time, code, 0);
+    // }
 }
 
 void
@@ -341,11 +420,14 @@ WaylandInputDevice::sendTouchPointEvent(struct wl_surface* surface, uint32_t tim
         }
         if (m_wlTouchFocusResource && m_wlTouchFocus)
         {
-            wl_touch_send_down(m_wlTouchFocusResource,
-                                0 /*serial*/, time,
-                                &m_wlTouchFocus->resource, touchId,
-                                wl_fixed_from_double(touchPos.x),
-                                wl_fixed_from_double(touchPos.y));
+            /**
+             * @todo Port to Wayland 1.3.
+             */
+            // wl_touch_send_down(m_wlTouchFocusResource,
+            //                     0 /*serial*/, time,
+            //                     &m_wlTouchFocus->resource, touchId,
+            //                     wl_fixed_from_double(touchPos.x),
+            //                     wl_fixed_from_double(touchPos.y));
         }
         break;
     case WL_TOUCH_MOTION:
@@ -379,7 +461,10 @@ void
 WaylandInputDevice::sendTouchFrameEvent()
 {
     wl_touch *touch = touchDevice();
-    wl_resource *resource = touch->focus_resource;
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    wl_resource *resource = NULL; // touch->focus_resource;
     if (resource)
     {
         wl_touch_send_frame(resource);
@@ -390,7 +475,10 @@ void
 WaylandInputDevice::sendTouchCancelEvent()
 {
     wl_touch *touch = touchDevice();
-    wl_resource *resource = touch->focus_resource;
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    wl_resource *resource = NULL; // touch->focus_resource;
     if (resource)
     {
         wl_touch_send_cancel(resource);
@@ -402,22 +490,28 @@ WaylandInputDevice::setMouseFocus(struct wl_surface* surface,
                                     const Point& globalPos,
                                     const Point& localPos)
 {
+    /**
+     * @todo Port to Wayland 1.3.
+     */
     wl_pointer* pointer = pointerDevice();
-    pointer->x = wl_fixed_from_double(globalPos.x);
-    pointer->y = wl_fixed_from_double(globalPos.y);
-    pointer->current = surface;
-    pointer->current_x = wl_fixed_from_double(localPos.x);
-    pointer->current_y = wl_fixed_from_double(localPos.y);
-    pointer->grab->interface->focus(pointer->grab,
-                                    surface,
-                                    wl_fixed_from_double(localPos.x),
-                                    wl_fixed_from_double(localPos.y));
+    // pointer->x = wl_fixed_from_double(globalPos.x);
+    // pointer->y = wl_fixed_from_double(globalPos.y);
+    // pointer->current = surface;
+    // pointer->current_x = wl_fixed_from_double(localPos.x);
+    // pointer->current_y = wl_fixed_from_double(localPos.y);
+    // pointer->grab->interface->focus(pointer->grab,
+    //                                 surface,
+    //                                 wl_fixed_from_double(localPos.x),
+    //                                 wl_fixed_from_double(localPos.y));
 }
 
 void
 WaylandInputDevice::setKeyboardFocus(struct wl_surface* surface)
 {
-    wl_keyboard_set_focus(keyboardDevice(), surface);
+    /**
+     * @todo Port to Wayland 1.3.
+     */
+    // wl_keyboard_set_focus(keyboardDevice(), surface);
 }
 
 void
@@ -430,30 +524,36 @@ WaylandInputDevice::setTouchFocus(struct wl_surface* surface)
 
     if (surface)
     {
-        resource = findResourceForClient(&m_wlSeat.touch->resource_list,
-                                        surface->resource.client);
+        /**
+         * @todo Port to Wayland 1.3.
+         */
+        resource = NULL; // findResourceForClient(m_wlSeat.touch->resource_list,
+                         //                surface->resource.client);
         if (!resource)
         {
             return;
         }
-        m_wlSeat.touch->focus = surface;
-        m_wlSeat.touch->focus_resource = resource;
+        // m_wlSeat->touch->focus = surface;
+        // m_wlSeat->touch->focus_resource = resource;
     }
     else
     {
-        m_wlSeat.touch->focus = NULL;
-        m_wlSeat.touch->focus_resource = NULL;
+        // m_wlSeat->touch->focus = NULL;
+        // m_wlSeat->touch->focus_resource = NULL;
     }
 }
 
 void
 WaylandInputDevice::sendModifiers(uint32_t serial)
 {
+    /**
+     * @todo Port to Wayland 1.3.
+     */
     struct wl_keyboard *keyboard = keyboardDevice();
-    struct wl_keyboard_grab *grab = keyboard->grab;
-    grab->interface->modifiers(grab, serial,
-                                keyboard->modifiers.mods_depressed,
-                                keyboard->modifiers.mods_latched,
-                                keyboard->modifiers.mods_locked,
-                                keyboard->modifiers.group);
+    // struct wl_keyboard_grab *grab = keyboard->grab;
+    // grab->interface->modifiers(grab, serial,
+    //                             keyboard->modifiers.mods_depressed,
+    //                             keyboard->modifiers.mods_latched,
+    //                             keyboard->modifiers.mods_locked,
+    //                             keyboard->modifiers.group);
 }