ecore-wl2: make session recovery listener global
authorMike Blumenkrantz <zmike@osg.samsung.com>
Fri, 13 Jan 2017 16:34:07 +0000 (11:34 -0500)
committerMike Blumenkrantz <zmike@osg.samsung.com>
Fri, 13 Jan 2017 16:33:59 +0000 (11:33 -0500)
global proxies have a single instance and do not work with
multiple listeners

@fix

src/lib/ecore_wl2/ecore_wl2_display.c
src/lib/ecore_wl2/ecore_wl2_window.c

index e25aa75..139e2ff 100644 (file)
@@ -70,6 +70,19 @@ static const struct zxdg_shell_v6_listener _zxdg_shell_listener =
 };
 
 static void
+_session_recovery_create_uuid(void *data EINA_UNUSED, struct zwp_e_session_recovery *session_recovery EINA_UNUSED, struct wl_surface *surface, const char *uuid)
+{
+   Ecore_Wl2_Window *win = wl_surface_get_user_data(surface);
+
+   eina_stringshare_replace(&win->uuid, uuid);
+}
+
+static const struct zwp_e_session_recovery_listener _session_listener =
+{
+   _session_recovery_create_uuid,
+};
+
+static void
 _cb_global_event_free(void *data EINA_UNUSED, void *event)
 {
    Ecore_Wl2_Event_Global *ev;
@@ -185,6 +198,8 @@ _cb_global_add(void *data, struct wl_registry *registry, unsigned int id, const
         ewd->wl.session_recovery =
           wl_registry_bind(registry, id,
                            &zwp_e_session_recovery_interface, 1);
+        zwp_e_session_recovery_add_listener(ewd->wl.session_recovery,
+                                            &_session_listener, ewd);
      }
    else if (!strcmp(interface, "zwp_teamwork"))
      {
index 444b5c3..327185c 100644 (file)
@@ -35,18 +35,6 @@ _ecore_wl_window_semi_free(Ecore_Wl2_Window *window)
    window->surface_id = -1;
 }
 
-static void
-_session_recovery_create_uuid(void *data, struct zwp_e_session_recovery *session_recovery EINA_UNUSED, struct wl_surface *surface EINA_UNUSED, const char *uuid)
-{
-   Ecore_Wl2_Window *win = data;
-
-   eina_stringshare_replace(&win->uuid, uuid);
-}
-
-static const struct zwp_e_session_recovery_listener _session_listener =
-{
-   _session_recovery_create_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)
@@ -592,13 +580,10 @@ _ecore_wl2_window_surface_create(Ecore_Wl2_Window *window)
              ERR("Failed to create surface for window");
              return;
           }
+        wl_surface_set_user_data(window->surface, window);
 
         window->surface_id =
           wl_proxy_get_id((struct wl_proxy *)window->surface);
-
-        if (window->display->wl.session_recovery)
-          zwp_e_session_recovery_add_listener(window->display->wl.session_recovery,
-                                              &_session_listener, window);
      }
 }