e_comp_wl: create global and bind session_recovery interface
authorStefan Schmidt <stefan@osg.samsung.com>
Tue, 25 Aug 2015 13:46:16 +0000 (15:46 +0200)
committerStefan Schmidt <stefan@osg.samsung.com>
Wed, 26 Aug 2015 14:09:25 +0000 (16:09 +0200)
Before we can use the session_recovery protocol extension we need to register
its global and bind the interface to our implementation.

The callback for the provide_uuid call from the client is just a stub for now.

src/bin/e_comp_wl.c

index 45a7539197c9921dd1f37470a20bd4acd068bfc3..dbc978fd4e6750724a973d0e7bda45ce5ebf49bd 100644 (file)
@@ -9,6 +9,7 @@
 #define COMPOSITOR_VERSION 3
 
 E_API int E_EVENT_WAYLAND_GLOBAL_ADD = -1;
+#include "session-recovery-server-protocol.h"
 
 /* Resource Data Mapping: (wl_resource_get_user_data)
  *
@@ -2004,6 +2005,33 @@ _e_comp_wl_subcompositor_cb_bind(struct wl_client *client, void *data EINA_UNUSE
    /* TODO: add handlers for client iconify/uniconify */
 }
 
+static void
+_e_comp_wl_sr_cb_provide_uuid(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, const char *uuid)
+{
+   DBG("Provide UUID callback called for UUID: %s", uuid);
+}
+
+static const struct session_recovery_interface _e_session_recovery_interface =
+{
+   _e_comp_wl_sr_cb_provide_uuid,
+};
+
+static void
+_e_comp_wl_session_recovery_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t version EINA_UNUSED, uint32_t id)
+{
+   struct wl_resource *res;
+
+   if (!(res = wl_resource_create(client, &session_recovery_interface, 1, id)))
+     {
+        ERR("Could not create session_recovery interface");
+        wl_client_post_no_memory(client);
+        return;
+     }
+
+   /* set implementation on resource */
+   wl_resource_set_implementation(res, &_e_session_recovery_interface, e_comp, NULL);
+}
+
 static void
 _e_comp_wl_screenshooter_cb_shoot(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *output_resource, struct wl_resource *buffer_resource)
 {
@@ -2482,6 +2510,14 @@ _e_comp_wl_compositor_create(void)
         goto comp_global_err;
      }
 
+   /* try to add session_recovery to wayland globals */
+   if (!wl_global_create(cdata->wl.disp, &session_recovery_interface, 1,
+                         e_comp, _e_comp_wl_session_recovery_cb_bind))
+     {
+        ERR("Could not add session_recovery to wayland globals: %m");
+        goto comp_global_err;
+     }
+
    cdata->screenshooter.global =
      wl_global_create(cdata->wl.disp, &screenshooter_interface, 1,
                       e_comp, _e_comp_wl_screenshooter_cb_bind);