devilhorns pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=98e8183b1b57a441cd2145fe4c9a124f92675f68

commit 98e8183b1b57a441cd2145fe4c9a124f92675f68
Author: Chris Michael <cpmich...@osg.samsung.com>
Date:   Fri Apr 22 09:32:45 2016 -0400

    ecore-wl2: Port session recovery protocol to work with Ecore_Wl2
    
    This patch ports the existing session recovery protocol from
    Ecore_Wayland so that it is used inside Ecore_Wl2.
    
    @feature
    
    Signed-off-by: Chris Michael <cpmich...@osg.samsung.com>
---
 src/Makefile_Ecore_Wl2.am                          |  2 +
 src/lib/ecore_wl2/ecore_wl2_display.c              |  9 +++
 src/lib/ecore_wl2/ecore_wl2_private.h              |  6 ++
 src/lib/ecore_wl2/ecore_wl2_window.c               | 33 +++++++++++
 .../ecore_wl2/session-recovery-client-protocol.h   | 68 ++++++++++++++++++++++
 src/lib/ecore_wl2/session-recovery-protocol.c      | 23 ++++++++
 6 files changed, 141 insertions(+)

diff --git a/src/Makefile_Ecore_Wl2.am b/src/Makefile_Ecore_Wl2.am
index 80aabb6..8a55a2d 100644
--- a/src/Makefile_Ecore_Wl2.am
+++ b/src/Makefile_Ecore_Wl2.am
@@ -8,6 +8,8 @@ installed_ecorewl2mainheadersdir = 
$(includedir)/ecore-wl2-@VMAJ@
 dist_installed_ecorewl2mainheaders_DATA = lib/ecore_wl2/Ecore_Wl2.h
 
 lib_ecore_wl2_libecore_wl2_la_SOURCES = \
+lib/ecore_wl2/session-recovery-client-protocol.h \
+lib/ecore_wl2/session-recovery-protocol.c \
 lib/ecore_wl2/subsurface-client-protocol.h \
 lib/ecore_wl2/subsurface-protocol.c \
 lib/ecore_wl2/xdg-shell-client-protocol.h \
diff --git a/src/lib/ecore_wl2/ecore_wl2_display.c 
b/src/lib/ecore_wl2/ecore_wl2_display.c
index ed7ee71..27d5ad1 100644
--- a/src/lib/ecore_wl2/ecore_wl2_display.c
+++ b/src/lib/ecore_wl2/ecore_wl2_display.c
@@ -144,6 +144,13 @@ _cb_global_add(void *data, struct wl_registry *registry, 
unsigned int id, const
         EINA_INLIST_FOREACH(ewd->windows, window)
           _ecore_wl2_window_www_surface_init(window);
      }
+   else if ((!strcmp(interface, "zwp_e_session_recovery")) &&
+            (getenv("EFL_WAYLAND_SESSION_RECOVERY")))
+     {
+        ewd->wl.session_recovery =
+          wl_registry_bind(registry, id,
+                           &zwp_e_session_recovery_interface, 1);
+     }
    else if (!strcmp(interface, "wl_output"))
      _ecore_wl2_output_add(ewd, id);
    else if (!strcmp(interface, "wl_seat"))
@@ -389,6 +396,8 @@ _ecore_wl2_display_cleanup(Ecore_Wl2_Display *ewd)
 
    eina_hash_free(ewd->globals);
 
+   if (ewd->wl.session_recovery)
+     zwp_e_session_recovery_destroy(ewd->wl.session_recovery);
    if (ewd->wl.www) www_destroy(ewd->wl.www);
    if (ewd->wl.xdg_shell) xdg_shell_destroy(ewd->wl.xdg_shell);
    if (ewd->wl.wl_shell) wl_shell_destroy(ewd->wl.wl_shell);
diff --git a/src/lib/ecore_wl2/ecore_wl2_private.h 
b/src/lib/ecore_wl2/ecore_wl2_private.h
index 2ea8a08..f1bd494 100644
--- a/src/lib/ecore_wl2/ecore_wl2_private.h
+++ b/src/lib/ecore_wl2/ecore_wl2_private.h
@@ -2,6 +2,7 @@
 # define _ECORE_WL2_PRIVATE_H
 
 # include <unistd.h>
+# include <uuid/uuid.h>
 # include "Ecore_Wl2.h"
 # include "Ecore_Input.h"
 # include "www-protocol.h"
@@ -15,6 +16,8 @@
 # include "xdg-shell-client-protocol.h"
 # define XDG_VERSION 5
 
+# include "session-recovery-client-protocol.h"
+
 extern int _ecore_wl2_log_dom;
 
 # ifdef EAPI
@@ -80,6 +83,7 @@ struct _Ecore_Wl2_Display
         struct wl_shell *wl_shell;
         struct xdg_shell *xdg_shell;
         struct www *www;
+        struct zwp_e_session_recovery *session_recovery;
         int compositor_version;
      } wl;
 
@@ -137,6 +141,8 @@ struct _Ecore_Wl2_Window
    struct xdg_popup *xdg_popup;
    struct www_surface *www_surface;
 
+   uuid_t uuid;
+
    uint32_t configure_serial;
    void (*configure_ack)(struct xdg_surface *surface, uint32_t serial);
 
diff --git a/src/lib/ecore_wl2/ecore_wl2_window.c 
b/src/lib/ecore_wl2/ecore_wl2_window.c
index ad72a62..c3415ea 100644
--- a/src/lib/ecore_wl2/ecore_wl2_window.c
+++ b/src/lib/ecore_wl2/ecore_wl2_window.c
@@ -5,6 +5,25 @@
 #include "ecore_wl2_private.h"
 
 static void
+_session_recovery_uuid(void *data, struct zwp_e_session_recovery 
*session_recovery, const char *uuid)
+{
+   Ecore_Wl2_Window *win;
+   char str[37];
+
+   win = data;
+   if (!win) return;
+   if (!session_recovery) return;
+   uuid_parse(uuid, win->uuid);
+   uuid_unparse(win->uuid, str);
+   DBG("UUID event received from compositor with UUID: %s\n", str);
+}
+
+static const struct zwp_e_session_recovery_listener _session_listener =
+{
+   _session_recovery_uuid,
+};
+
+static void
 _ecore_wl2_window_configure_send(Ecore_Wl2_Window *window, int w, int h, 
unsigned int edges, Eina_Bool fs, Eina_Bool max)
 {
    Ecore_Wl2_Event_Window_Configure *ev;
@@ -360,6 +379,20 @@ ecore_wl2_window_surface_get(Ecore_Wl2_Window *window)
 
         window->surface_id =
           wl_proxy_get_id((struct wl_proxy *)window->surface);
+
+        if ((window->display->wl.session_recovery) &&
+            (getenv("EFL_WAYLAND_SESSION_RECOVERY")))
+          {
+             char uuid[37];
+
+             
zwp_e_session_recovery_add_listener(window->display->wl.session_recovery,
+                                                 &_session_listener, window);
+             if (!uuid_is_null(window->uuid))
+               {
+                  uuid_unparse(window->uuid, uuid);
+                  
zwp_e_session_recovery_provide_uuid(window->display->wl.session_recovery, uuid);
+               }
+          }
      }
 
    return window->surface;
diff --git a/src/lib/ecore_wl2/session-recovery-client-protocol.h 
b/src/lib/ecore_wl2/session-recovery-client-protocol.h
new file mode 100644
index 0000000..2405747
--- /dev/null
+++ b/src/lib/ecore_wl2/session-recovery-client-protocol.h
@@ -0,0 +1,68 @@
+#ifndef E_SESSION_RECOVERY_CLIENT_PROTOCOL_H
+#define E_SESSION_RECOVERY_CLIENT_PROTOCOL_H
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <stddef.h>
+#include "wayland-client.h"
+
+struct wl_client;
+struct wl_resource;
+
+struct zwp_e_session_recovery;
+
+extern const struct wl_interface zwp_e_session_recovery_interface;
+
+struct zwp_e_session_recovery_listener {
+       /**
+        * uuid - (none)
+        * @uuid: (none)
+        */
+       void (*uuid)(void *data,
+                    struct zwp_e_session_recovery *zwp_e_session_recovery,
+                    const char *uuid);
+};
+
+static inline int
+zwp_e_session_recovery_add_listener(struct zwp_e_session_recovery 
*zwp_e_session_recovery,
+                                   const struct 
zwp_e_session_recovery_listener *listener, void *data)
+{
+       return wl_proxy_add_listener((struct wl_proxy *) zwp_e_session_recovery,
+                                    (void (**)(void)) listener, data);
+}
+
+#define ZWP_E_SESSION_RECOVERY_PROVIDE_UUID    0
+
+static inline void
+zwp_e_session_recovery_set_user_data(struct zwp_e_session_recovery 
*zwp_e_session_recovery, void *user_data)
+{
+       wl_proxy_set_user_data((struct wl_proxy *) zwp_e_session_recovery, 
user_data);
+}
+
+static inline void *
+zwp_e_session_recovery_get_user_data(struct zwp_e_session_recovery 
*zwp_e_session_recovery)
+{
+       return wl_proxy_get_user_data((struct wl_proxy *) 
zwp_e_session_recovery);
+}
+
+static inline void
+zwp_e_session_recovery_destroy(struct zwp_e_session_recovery 
*zwp_e_session_recovery)
+{
+       wl_proxy_destroy((struct wl_proxy *) zwp_e_session_recovery);
+}
+
+static inline void
+zwp_e_session_recovery_provide_uuid(struct zwp_e_session_recovery 
*zwp_e_session_recovery, const char *uuid)
+{
+       wl_proxy_marshal((struct wl_proxy *) zwp_e_session_recovery,
+                        ZWP_E_SESSION_RECOVERY_PROVIDE_UUID, uuid);
+}
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/lib/ecore_wl2/session-recovery-protocol.c 
b/src/lib/ecore_wl2/session-recovery-protocol.c
new file mode 100644
index 0000000..32ddbcb
--- /dev/null
+++ b/src/lib/ecore_wl2/session-recovery-protocol.c
@@ -0,0 +1,23 @@
+#include <stdlib.h>
+#include <stdint.h>
+#include "wayland-util.h"
+
+
+static const struct wl_interface *types[] = {
+       NULL,
+};
+
+static const struct wl_message zwp_e_session_recovery_requests[] = {
+       { "provide_uuid", "s", types + 0 },
+};
+
+static const struct wl_message zwp_e_session_recovery_events[] = {
+       { "uuid", "s", types + 0 },
+};
+
+WL_EXPORT const struct wl_interface zwp_e_session_recovery_interface = {
+       "zwp_e_session_recovery", 1,
+       1, zwp_e_session_recovery_requests,
+       1, zwp_e_session_recovery_events,
+};
+

-- 


Reply via email to