wl client pixmaps now use a different method for creating the pixmap id
authorMike Blumenkrantz <zmike@osg.samsung.com>
Tue, 21 Apr 2015 19:19:20 +0000 (15:19 -0400)
committerMike Blumenkrantz <zmike@osg.samsung.com>
Tue, 21 Apr 2015 19:19:20 +0000 (15:19 -0400)
src/bin/e_comp_wl.c
src/bin/e_comp_wl.h
src/bin/e_comp_wl_input.c
src/bin/e_pixmap.c
src/bin/e_win.c
src/modules/wl_desktop_shell/e_mod_main.c

index eacd9a7..7e3620f 100644 (file)
@@ -1156,12 +1156,10 @@ _e_comp_wl_surface_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_re
 static void
 _e_comp_wl_surface_cb_attach(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *buffer_resource, int32_t sx, int32_t sy)
 {
-   E_Pixmap *ep;
    E_Client *ec;
    E_Comp_Wl_Buffer *buffer = NULL;
 
-   if (!(ep = wl_resource_get_user_data(resource))) return;
-   if (!(ec = e_pixmap_client_get(ep))) return;
+   if (!(ec = wl_resource_get_user_data(resource))) return;
    if (e_object_is_del(E_OBJECT(ec))) return;
 
    if (buffer_resource)
@@ -1184,12 +1182,10 @@ _e_comp_wl_surface_cb_attach(struct wl_client *client EINA_UNUSED, struct wl_res
 static void
 _e_comp_wl_surface_cb_damage(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, int32_t x, int32_t y, int32_t w, int32_t h)
 {
-   E_Pixmap *ep;
    E_Client *ec;
    Eina_Rectangle *dmg = NULL;
 
-   if (!(ep = wl_resource_get_user_data(resource))) return;
-   if (!(ec = e_pixmap_client_get(ep))) return;
+   if (!(ec = wl_resource_get_user_data(resource))) return;
    if (e_object_is_del(E_OBJECT(ec))) return;
 
    if (!(dmg = eina_rectangle_new(x, y, w, h))) return;
@@ -1213,12 +1209,10 @@ _e_comp_wl_frame_cb_destroy(struct wl_resource *resource)
 static void
 _e_comp_wl_surface_cb_frame(struct wl_client *client, struct wl_resource *resource, uint32_t callback)
 {
-   E_Pixmap *ep;
    E_Client *ec;
    struct wl_resource *res;
 
-   if (!(ep = wl_resource_get_user_data(resource))) return;
-   if (!(ec = e_pixmap_client_get(ep))) return;
+   if (!(ec = wl_resource_get_user_data(resource))) return;
    if (e_object_is_del(E_OBJECT(ec))) return;
 
    /* create frame callback */
@@ -1238,11 +1232,9 @@ _e_comp_wl_surface_cb_frame(struct wl_client *client, struct wl_resource *resour
 static void
 _e_comp_wl_surface_cb_opaque_region_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *region_resource)
 {
-   E_Pixmap *ep;
    E_Client *ec;
 
-   if (!(ep = wl_resource_get_user_data(resource))) return;
-   if (!(ec = e_pixmap_client_get(ep))) return;
+   if (!(ec = wl_resource_get_user_data(resource))) return;
    if (e_object_is_del(E_OBJECT(ec))) return;
 
    if (region_resource)
@@ -1267,11 +1259,9 @@ _e_comp_wl_surface_cb_opaque_region_set(struct wl_client *client EINA_UNUSED, st
 static void
 _e_comp_wl_surface_cb_input_region_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *region_resource)
 {
-   E_Pixmap *ep;
    E_Client *ec;
 
-   if (!(ep = wl_resource_get_user_data(resource))) return;
-   if (!(ec = e_pixmap_client_get(ep))) return;
+   if (!(ec = wl_resource_get_user_data(resource))) return;
    if (e_object_is_del(E_OBJECT(ec))) return;
 
    if (region_resource)
@@ -1293,12 +1283,10 @@ _e_comp_wl_surface_cb_input_region_set(struct wl_client *client EINA_UNUSED, str
 static void
 _e_comp_wl_surface_cb_commit(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
 {
-   E_Pixmap *ep;
    E_Client *ec, *subc;
    Eina_List *l;
 
-   if (!(ep = wl_resource_get_user_data(resource))) return;
-   if (!(ec = e_pixmap_client_get(ep))) return;
+   if (!(ec = wl_resource_get_user_data(resource))) return;
    if (e_object_is_del(E_OBJECT(ec))) return;
 
    if (e_comp_wl_subsurface_commit(ec)) return;
@@ -1338,22 +1326,22 @@ static const struct wl_surface_interface _e_surface_interface =
 };
 
 static void
+_e_comp_wl_surface_render_stop(E_Client *ec)
+{
+   /* FIXME: this may be fine after e_pixmap can create textures for wl clients? */
+   //if ((!ec->internal) && (!e_comp_gl_get()))
+     ec->dead = ec->hidden = 1;
+   evas_object_hide(ec->frame);
+}
+
+static void
 _e_comp_wl_surface_destroy(struct wl_resource *resource)
 {
-   E_Pixmap *ep;
    E_Client *ec;
 
-   if (!(ep = wl_resource_get_user_data(resource))) return;
-
-   /* try to get the e_client from this pixmap */
-   if (!(ec = e_pixmap_client_get(ep)))
-     return;
+   if (!(ec = wl_resource_get_user_data(resource))) return;
 
-   /* FIXME: this should be fine after e_pixmap can create textures for wl clients */
-   //if ((!ec->internal) && (!e_comp_gl_get()))
-   if (!ec->internal)
-     ec->dead = ec->hidden = 1;
-   evas_object_hide(ec->frame);
+   _e_comp_wl_surface_render_stop(ec);
    e_object_del(E_OBJECT(ec));
 }
 
@@ -1361,9 +1349,7 @@ static void
 _e_comp_wl_compositor_cb_surface_create(struct wl_client *client, struct wl_resource *resource, uint32_t id)
 {
    struct wl_resource *res;
-   E_Pixmap *ep;
-   E_Client *ec;
-   uint64_t win;
+   E_Client *ec = NULL;
    pid_t pid;
 
    DBG("Compositor Cb Surface Create: %d", id);
@@ -1384,27 +1370,33 @@ _e_comp_wl_compositor_cb_surface_create(struct wl_client *client, struct wl_reso
                                   _e_comp_wl_surface_destroy);
 
    wl_client_get_credentials(client, &pid, NULL, NULL);
-   win = e_comp_wl_id_get(id, pid);
-   /* try to create new pixmap */
-   if (!(ep = e_pixmap_new(E_PIXMAP_TYPE_WL, win)))
+   if (pid == getpid()) //internal!
+     ec = e_pixmap_find_client(E_PIXMAP_TYPE_WL, (uintptr_t)id);
+   if (!ec)
      {
-        ERR("Could not create new pixmap");
-        wl_resource_destroy(res);
-        wl_client_post_no_memory(client);
-        return;
-     }
-   DBG("\tUsing Pixmap: %p", ep);
+        E_Pixmap *ep;
 
-   if ((ec = e_client_new(ep, 0, 0)))
-     {
-        ec->new_client = 0;
-        e_comp->new_clients--;
-        ec->client.w = ec->client.h = 1;
-        ec->ignored = 1;
+        /* try to create new pixmap */
+        if (!(ep = e_pixmap_new(E_PIXMAP_TYPE_WL, resource)))
+          {
+             ERR("Could not create new pixmap");
+             wl_resource_destroy(res);
+             wl_client_post_no_memory(client);
+             return;
+          }
+        DBG("\tUsing Pixmap: %p", ep);
+
+        if ((ec = e_client_new(ep, 0, 0)))
+          {
+             ec->new_client = 0;
+             e_comp->new_clients--;
+             ec->client.w = ec->client.h = 1;
+             ec->ignored = 1;
+          }
      }
 
    /* set reference to pixmap so we can fetch it later */
-   wl_resource_set_user_data(res, ep);
+   wl_resource_set_user_data(res, ec);
 
    /* emit surface create signal */
    wl_signal_emit(&e_comp->wl_comp_data->signals.surface.create, res);
@@ -1920,14 +1912,13 @@ _e_comp_wl_subcompositor_cb_destroy(struct wl_client *client EINA_UNUSED, struct
 static void
 _e_comp_wl_subcompositor_cb_subsurface_get(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, uint32_t id, struct wl_resource *surface_resource, struct wl_resource *parent_resource)
 {
-   E_Pixmap *ep, *epp;
    E_Client *ec, *epc = NULL;
    static const char where[] = "get_subsurface: wl_subsurface@";
 
-   if (!(ep = wl_resource_get_user_data(surface_resource))) return;
-   if (!(epp = wl_resource_get_user_data(parent_resource))) return;
+   if (!(ec = wl_resource_get_user_data(surface_resource))) return;
+   if (!(epc = wl_resource_get_user_data(parent_resource))) return;
 
-   if (ep == epp)
+   if (ec == epc)
      {
         wl_resource_post_error(resource, WL_SUBCOMPOSITOR_ERROR_BAD_SURFACE,
                                "%s%d: wl_surface@%d cannot be its own parent",
@@ -1935,24 +1926,8 @@ _e_comp_wl_subcompositor_cb_subsurface_get(struct wl_client *client EINA_UNUSED,
         return;
      }
 
-   if (!(ec = e_pixmap_client_get(ep)))
-     {
-        if (!(ec = e_client_new(ep, 0, 0)))
-          {
-             wl_resource_post_no_memory(resource);
-             return;
-          }
-
-        if (ec->comp_data)
-          ec->comp_data->surface = surface_resource;
-     }
-
    if (e_object_is_del(E_OBJECT(ec))) return;
-
-   if ((epc = e_pixmap_client_get(epp)))
-     {
-        if (e_object_is_del(E_OBJECT(epc))) return;
-     }
+   if (e_object_is_del(E_OBJECT(epc))) return;
 
    /* check if this surface is already a sub-surface */
    if ((ec->comp_data) && (ec->comp_data->sub.data))
@@ -2085,7 +2060,8 @@ _e_comp_wl_client_cb_del(void *data EINA_UNUSED, E_Client *ec)
      wl_resource_set_user_data(ec->comp_data->surface, NULL);
 
    E_FREE(ec->comp_data);
-
+   if (ec->internal_elm_win)
+     _e_comp_wl_surface_render_stop(ec);
    _e_comp_wl_focus_check();
 }
 
index 686de07..2fc4714 100644 (file)
@@ -292,11 +292,5 @@ EAPI struct wl_signal e_comp_wl_surface_create_signal_get(void);
 EAPI double e_comp_wl_idle_time_get(void);
 EAPI Eina_Bool e_comp_wl_output_init(const char *id, const char *make, const char *model, int x, int y, int w, int h, int pw, int ph, unsigned int refresh, unsigned int subpixel, unsigned int transform);
 
-static inline uint64_t
-e_comp_wl_id_get(uint32_t id, pid_t pid)
-{
-   return ((uint64_t)id << 32) + pid;
-}
-
 # endif
 #endif
index 4005f55..d0729b7 100644 (file)
@@ -31,9 +31,7 @@ static void
 _e_comp_wl_input_pointer_cb_cursor_set(struct wl_client *client, struct wl_resource *resource EINA_UNUSED, uint32_t serial EINA_UNUSED, struct wl_resource *surface_resource, int32_t x, int32_t y)
 {
    E_Comp_Data *cdata;
-   pid_t pid;
    E_Client *ec;
-   uint64_t sid;
    Eina_Bool got_mouse = EINA_FALSE;
 
    /* get compositor data */
@@ -54,9 +52,7 @@ _e_comp_wl_input_pointer_cb_cursor_set(struct wl_client *client, struct wl_resou
         e_pointer_object_set(e_comp->pointer, NULL, x, y);
         return;
      }
-   wl_client_get_credentials(client, &pid, NULL, NULL);
-   sid = e_comp_wl_id_get(wl_resource_get_id(surface_resource), pid);
-   ec = e_pixmap_find_client(E_PIXMAP_TYPE_WL, sid);
+   ec = wl_resource_get_user_data(surface_resource);
    if (!ec->re_manage)
      {
         ec->re_manage = 1;
index 7be5534..3abd7fa 100644 (file)
@@ -150,7 +150,7 @@ _e_pixmap_find(E_Pixmap_Type type, va_list *l)
    Ecore_X_Window xwin;
 #endif
 #if defined(HAVE_WAYLAND_CLIENTS) || defined(HAVE_WAYLAND_ONLY)
-   uint64_t id;
+   uintptr_t id;
 #endif
    
    if (!pixmaps[type]) return NULL;
@@ -164,7 +164,7 @@ _e_pixmap_find(E_Pixmap_Type type, va_list *l)
         break;
       case E_PIXMAP_TYPE_WL:
 #if defined(HAVE_WAYLAND_CLIENTS) || defined(HAVE_WAYLAND_ONLY)
-        id = va_arg(*l, uint64_t);
+        id = va_arg(*l, uintptr_t);
         return eina_hash_find(pixmaps[type], &id);
 #endif
         break;
@@ -200,7 +200,7 @@ e_pixmap_new(E_Pixmap_Type type, ...)
    Ecore_X_Window xwin;
 #endif
 #if defined(HAVE_WAYLAND_CLIENTS) || defined(HAVE_WAYLAND_ONLY)
-   uint64_t id;
+   uintptr_t id;
 #endif
 
    EINA_SAFETY_ON_TRUE_RETURN_VAL((type != E_PIXMAP_TYPE_WL) && (type != E_PIXMAP_TYPE_X), NULL);
@@ -228,7 +228,7 @@ e_pixmap_new(E_Pixmap_Type type, ...)
         break;
       case E_PIXMAP_TYPE_WL:
 #if defined(HAVE_WAYLAND_CLIENTS) || defined(HAVE_WAYLAND_ONLY)
-        id = va_arg(l, uint64_t);
+        id = va_arg(l, uintptr_t);
         if (pixmaps[type])
           {
              cp = eina_hash_find(pixmaps[type], &id);
index c13c229..d2ccc32 100644 (file)
@@ -79,7 +79,7 @@ _e_elm_win_trap_show(void *data, Evas_Object *o)
              type = E_PIXMAP_TYPE_WL;
              ctx->pointer = e_comp->pointer;
              elm_win_borderless_set(o, 1);
-             wl_win_id = e_comp_wl_id_get(win, getpid());
+             wl_win_id = win;
           }
         else
 #endif
index 2efabae..b42fb62 100644 (file)
@@ -547,12 +547,11 @@ _e_shell_surface_unmap(struct wl_resource *resource)
 static void
 _e_shell_cb_shell_surface_get(struct wl_client *client, struct wl_resource *resource EINA_UNUSED, uint32_t id, struct wl_resource *surface_resource)
 {
-   E_Pixmap *ep;
    E_Client *ec;
    E_Comp_Client_Data *cdata;
 
    /* get the pixmap from this surface so we can find the client */
-   if (!(ep = wl_resource_get_user_data(surface_resource)))
+   if (!(ec = wl_resource_get_user_data(surface_resource)))
      {
         wl_resource_post_error(surface_resource,
                                WL_DISPLAY_ERROR_INVALID_OBJECT,
@@ -560,12 +559,6 @@ _e_shell_cb_shell_surface_get(struct wl_client *client, struct wl_resource *reso
         return;
      }
 
-   /* make sure it's a wayland pixmap */
-   if (e_pixmap_type_get(ep) != E_PIXMAP_TYPE_WL) return;
-
-   /* find the client for this pixmap */
-   ec = e_pixmap_client_get(ep);
-
    EC_CHANGED(ec);
    ec->new_client = ec->netwm.ping = EINA_TRUE;
    e_comp->new_clients++;
@@ -1109,14 +1102,13 @@ _e_xdg_shell_surface_unmap(struct wl_resource *resource)
 static void
 _e_xdg_shell_cb_surface_get(struct wl_client *client, struct wl_resource *resource EINA_UNUSED, uint32_t id, struct wl_resource *surface_resource)
 {
-   E_Pixmap *ep;
    E_Client *ec;
    E_Comp_Client_Data *cdata;
 
    /* DBG("XDG_SHELL: Surface Get %d", wl_resource_get_id(surface_resource)); */
 
    /* get the pixmap from this surface so we can find the client */
-   if (!(ep = wl_resource_get_user_data(surface_resource)))
+   if (!(ec = wl_resource_get_user_data(surface_resource)))
      {
         wl_resource_post_error(surface_resource,
                                WL_DISPLAY_ERROR_INVALID_OBJECT,
@@ -1124,12 +1116,6 @@ _e_xdg_shell_cb_surface_get(struct wl_client *client, struct wl_resource *resour
         return;
      }
 
-   /* make sure it's a wayland pixmap */
-   if (e_pixmap_type_get(ep) != E_PIXMAP_TYPE_WL) return;
-
-   /* find the client for this pixmap */
-   ec = e_pixmap_client_get(ep);
-
    EC_CHANGED(ec);
    ec->new_client = ec->netwm.ping = EINA_TRUE;
    e_comp->new_clients++;
@@ -1198,7 +1184,6 @@ static const struct xdg_popup_interface _e_xdg_popup_interface =
 static void
 _e_xdg_shell_cb_popup_get(struct wl_client *client, struct wl_resource *resource EINA_UNUSED, uint32_t id, struct wl_resource *surface_resource, struct wl_resource *parent_resource, struct wl_resource *seat_resource EINA_UNUSED, uint32_t serial EINA_UNUSED, int32_t x, int32_t y, uint32_t flags EINA_UNUSED)
 {
-   E_Pixmap *ep;
    E_Client *ec;
    E_Comp_Client_Data *cdata;
 
@@ -1208,7 +1193,7 @@ _e_xdg_shell_cb_popup_get(struct wl_client *client, struct wl_resource *resource
    /* DBG("\tLocation: %d %d", x, y); */
 
    /* get the pixmap from this surface so we can find the client */
-   if (!(ep = wl_resource_get_user_data(surface_resource)))
+   if (!(ec = wl_resource_get_user_data(surface_resource)))
      {
         wl_resource_post_error(surface_resource,
                                WL_DISPLAY_ERROR_INVALID_OBJECT,
@@ -1216,12 +1201,6 @@ _e_xdg_shell_cb_popup_get(struct wl_client *client, struct wl_resource *resource
         return;
      }
 
-   /* make sure it's a wayland pixmap */
-   if (e_pixmap_type_get(ep) != E_PIXMAP_TYPE_WL) return;
-
-   /* find the client for this pixmap */
-   ec = e_pixmap_client_get(ep);
-
    /* get the client data */
    if (!(cdata = ec->comp_data))
      {