Update e_wayland for recent wl_resource and wl_client changes
authorChris Michael <cp.michael@samsung.com>
Tue, 25 Jun 2013 08:00:15 +0000 (09:00 +0100)
committerChris Michael <cp.michael@samsung.com>
Tue, 25 Jun 2013 08:00:15 +0000 (09:00 +0100)
Signed-off-by: Chris Michael <cp.michael@samsung.com>
src/bin/e_wayland/e_comp.c
src/bin/e_wayland/e_input.c
src/bin/e_wayland/e_output.c
src/bin/e_wayland/e_region.c
src/bin/e_wayland/e_renderer.c
src/bin/e_wayland/e_shell_surface.c
src/bin/e_wayland/e_shell_surface.h
src/bin/e_wayland/e_surface.c
src/bin/e_wayland/e_surface.h

index d85272c09cf463b93a197146f87abd9bbe1a3d2b..4b3ce411a0ac4212943e96454916142037218e08 100644 (file)
@@ -407,6 +407,8 @@ _e_comp_cb_surface_create(struct wl_client *client, struct wl_resource *resource
    E_Compositor *comp;
    E_Surface *es;
 
+   printf("Comp Surface Create: %d\n", id);
+
    /* try to cast to our compositor */
    if (!(comp = resource->data)) return;
 
@@ -431,6 +433,8 @@ _e_comp_cb_surface_create(struct wl_client *client, struct wl_resource *resource
    /* set surface plane to compositor primary plane */
    es->plane = &comp->plane;
 
+   printf("\tAdding Surface: %p\n", es);
+
    /* add this surface to the compositors list */
    comp->surfaces = eina_list_append(comp->surfaces, es);
 }
@@ -521,20 +525,19 @@ _e_comp_data_device_cb_get(struct wl_client *client, struct wl_resource *resourc
    E_Input *seat;
    struct wl_resource *res;
 
-   if (!(seat = seat_resource->data)) return;
+   if (!(seat = wl_resource_get_user_data(seat_resource))) return;
 
    res = wl_client_add_object(client, &wl_data_device_interface, 
                               &_e_data_device_interface, id, seat);
 
-   wl_list_insert(&seat->drag_resources, &res->link);
-
-   res->destroy = _e_comp_data_device_cb_unbind;
+   wl_list_insert(&seat->drag_resources, wl_resource_get_link(res));
+   wl_resource_set_destructor(res, _e_comp_data_device_cb_unbind);
 }
 
 static void 
 _e_comp_data_device_cb_unbind(struct wl_resource *resource)
 {
-   wl_list_remove(&resource->link);
+   wl_list_remove(wl_resource_get_link(resource));
    free(resource);
 }
 
index 2cfb8496524dd7ac69a93cdb890b45014af34dd7..c722bb25a7520f45989e18d240f0dae97bb3c263 100644 (file)
@@ -169,7 +169,7 @@ e_input_pointer_focus_set(E_Input_Pointer *pointer, E_Surface *surface, Evas_Coo
    resource = pointer->focus_resource;
    if ((resource) && (pointer->focus != surface))
      {
-        disp = wl_client_get_display(resource->client);
+        disp = wl_client_get_display(wl_resource_get_client(resource));
         serial = wl_display_next_serial(disp);
         wl_pointer_send_leave(resource, serial, pointer->focus->wl.resource);
 //        wl_list_remove(&pointer->focus_listener.link);
@@ -182,7 +182,7 @@ e_input_pointer_focus_set(E_Input_Pointer *pointer, E_Surface *surface, Evas_Coo
        ((pointer->focus != surface) || 
            (pointer->focus_resource != resource)))
      {
-        disp = wl_client_get_display(resource->client);
+        disp = wl_client_get_display(wl_resource_get_client(resource));
         serial = wl_display_next_serial(disp);
 
         if (kbd)
@@ -202,7 +202,7 @@ e_input_pointer_focus_set(E_Input_Pointer *pointer, E_Surface *surface, Evas_Coo
 
         wl_pointer_send_enter(resource, serial, surface->wl.resource, 
                               wl_fixed_from_int(x), wl_fixed_from_int(y));
-        wl_signal_add(&resource->destroy_signal, &pointer->focus_listener);
+        wl_resource_add_destroy_listener(resource, &pointer->focus_listener);
         pointer->focus_serial = serial;
      }
 
@@ -294,7 +294,7 @@ e_input_keyboard_focus_set(E_Input_Keyboard *keyboard, E_Surface *surface)
    if ((keyboard->focus_resource) && (keyboard->focus != surface))
      {
         res = keyboard->focus_resource;
-        disp = wl_client_get_display(res->client);
+        disp = wl_client_get_display(wl_resource_get_client(res));
         serial = wl_display_next_serial(disp);
         printf("Send Keyboard Leave: %p\n", keyboard->focus);
         if (surface) printf("\tSurface: %p\n", surface);
@@ -307,7 +307,7 @@ e_input_keyboard_focus_set(E_Input_Keyboard *keyboard, E_Surface *surface)
    if ((res) && 
        ((keyboard->focus != surface) || (keyboard->focus_resource != res)))
      {
-        disp = wl_client_get_display(res->client);
+        disp = wl_client_get_display(wl_resource_get_client(res));
         serial = wl_display_next_serial(disp);
         wl_keyboard_send_modifiers(res, serial, 
                                    keyboard->modifiers.pressed,
@@ -317,7 +317,7 @@ e_input_keyboard_focus_set(E_Input_Keyboard *keyboard, E_Surface *surface)
         printf("Send Keyboard Enter: %p\n", surface);
         wl_keyboard_send_enter(res, serial, 
                                surface->wl.resource, &keyboard->keys);
-        wl_signal_add(&res->destroy_signal, &keyboard->focus_listener);
+        wl_resource_add_destroy_listener(res, &keyboard->focus_listener);
         keyboard->focus_serial = serial;
      }
 
@@ -378,7 +378,7 @@ e_input_keyboard_focus_destroy(struct wl_listener *listener, void *data)
 static void 
 _e_input_capabilities_update(E_Input *seat)
 {
-   struct wl_resource *res;
+   struct wl_list *link;
    enum wl_seat_capability caps = 0;
 
    if (seat->pointer)
@@ -388,8 +388,11 @@ _e_input_capabilities_update(E_Input *seat)
    /* if (seat->touch) */
    /*   caps |= WL_SEAT_CAPABILITY_TOUCH; */
 
-   wl_list_for_each(res, &seat->resources, link)
-     wl_seat_send_capabilities(res, caps);
+   for (link = seat->resources.next; 
+        link != &seat->resources; link = link->next)
+     {
+        wl_seat_send_capabilities(wl_resource_from_link(link), caps);
+     }
 }
 
 static void 
@@ -404,9 +407,8 @@ _e_input_cb_bind(struct wl_client *client, void *data, unsigned int version, uns
    res = wl_client_add_object(client, &wl_seat_interface, 
                               &_e_input_interface, id, data);
 
-   wl_list_insert(&seat->resources, &res->link);
-
-   res->destroy = _e_input_cb_unbind;
+   wl_list_insert(&seat->resources, wl_resource_get_link(res));
+   wl_resource_set_destructor(res, _e_input_cb_unbind);
 
    if (seat->pointer)
      caps |= WL_SEAT_CAPABILITY_POINTER;
@@ -433,15 +435,14 @@ _e_input_cb_pointer_get(struct wl_client *client, struct wl_resource *resource,
    E_Input *seat;
    struct wl_resource *res;
 
-   if (!(seat = resource->data)) return;
+   if (!(seat = wl_resource_get_user_data(resource))) return;
    if (!seat->pointer) return;
 
    res = wl_client_add_object(client, &wl_pointer_interface, 
                               &_e_pointer_interface, id, seat->pointer);
 
-   wl_list_insert(&seat->pointer->resources, &res->link);
-
-   res->destroy = _e_input_cb_unbind;
+   wl_list_insert(&seat->pointer->resources, wl_resource_get_link(res));
+   wl_resource_set_destructor(res, _e_input_cb_unbind);
 
    if ((seat->pointer->focus) && 
        (wl_resource_get_client(seat->pointer->focus->wl.resource) == client))
@@ -461,14 +462,13 @@ _e_input_cb_keyboard_get(struct wl_client *client, struct wl_resource *resource,
    E_Input *seat;
    struct wl_resource *res;
 
-   if (!(seat = resource->data)) return;
+   if (!(seat = wl_resource_get_user_data(resource))) return;
    if (!seat->keyboard) return;
 
    res = wl_client_add_object(client, &wl_keyboard_interface, NULL, id, seat);
 
-   wl_list_insert(&seat->keyboard->resources, &res->link);
-
-   res->destroy = _e_input_cb_unbind;
+   wl_list_insert(&seat->keyboard->resources, wl_resource_get_link(res));
+   wl_resource_set_destructor(res, _e_input_cb_unbind);
 
    wl_keyboard_send_keymap(res, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, 
                            seat->kbd_info.fd, seat->kbd_info.size);
@@ -496,9 +496,10 @@ _e_input_pointer_cb_cursor_set(struct wl_client *client, struct wl_resource *res
    E_Input_Pointer *ptr;
    E_Surface *es;
 
-   if (!(ptr = resource->data)) return;
-   if (surface_resource) es = surface_resource->data;
+   if (!(ptr = wl_resource_get_user_data(resource))) return;
+   if (surface_resource) es = wl_resource_get_user_data(surface_resource);
    if (!ptr->focus) return;
+   if (!ptr->focus->wl.resource) return;
    if (wl_resource_get_client(ptr->focus->wl.resource) != client) return;
    if (ptr->focus_serial - serial > UINT32_MAX / 2) return;
 
@@ -660,13 +661,7 @@ _e_input_keyboard_grab_cb_modifiers(E_Input_Keyboard_Grab *grab, unsigned int se
 static struct wl_resource *
 _e_input_surface_resource_get(struct wl_list *list, E_Surface *surface)
 {
-   struct wl_resource *ret;
-
    if (!surface) return NULL;
 
-   wl_list_for_each(ret, list, link)
-     if (ret->client == wl_resource_get_client(surface->wl.resource))
-       return ret;
-
-   return NULL;
+   return wl_resource_find_for_client(list, wl_resource_get_client(surface->wl.resource));
 }
index a75888b45069deca1093e7e5d2bad1a2093459f5..6cde034dfcba72e6b34c3962de2ef05b568251dc 100644 (file)
@@ -155,10 +155,8 @@ _e_output_cb_bind(struct wl_client *client, void *data, unsigned int version EIN
    /* add this output to the client */
    resource = 
      wl_client_add_object(client, &wl_output_interface, NULL, id, output);
-   wl_list_insert(&output->wl.resources, &resource->link);
-
-   /* setup destroy callback */
-   resource->destroy = _e_output_cb_unbind;
+   wl_list_insert(&output->wl.resources, wl_resource_get_link(resource));
+   wl_resource_set_destructor(resource, _e_output_cb_unbind);
 
    /* send out this output's geometry */
    wl_output_send_geometry(resource, output->x, output->y, 
@@ -169,12 +167,14 @@ _e_output_cb_bind(struct wl_client *client, void *data, unsigned int version EIN
    EINA_LIST_FOREACH(output->modes, l, mode)
      wl_output_send_mode(resource, mode->flags, mode->w, mode->h, 
                          mode->refresh);
+
+   if (version >= 2) wl_output_send_done(resource);
 }
 
 static void 
 _e_output_cb_unbind(struct wl_resource *resource)
 {
-   wl_list_remove(&resource->link);
+   wl_list_remove(wl_resource_get_link(resource));
    free(resource);
 }
 
index b3d2ae21a92ca26f9a77f5b96c6a374fa2703835..f938873999458eb19ecb0b751688b0301972ad1b 100644 (file)
@@ -42,8 +42,7 @@ _e_region_cb_add(struct wl_client *client EINA_UNUSED, struct wl_resource *resou
 {
    E_Region *reg;
 
-   /* try to cast resource to our region */
-   if (!(reg = resource->data)) return;
+   if (!(reg = wl_resource_get_user_data(resource))) return;
 
    pixman_region32_union_rect(&reg->region, &reg->region, x, y, w, h);
 }
@@ -55,7 +54,7 @@ _e_region_cb_subtract(struct wl_client *client EINA_UNUSED, struct wl_resource *
    pixman_region32_t rect;
 
    /* try to cast resource to our region */
-   if (!(reg = resource->data)) return;
+   if (!(reg = wl_resource_get_user_data(resource))) return;
 
    pixman_region32_init_rect(&rect, x, y, w, h);
    pixman_region32_subtract(&reg->region, &reg->region, &rect);
index 70e0f432c449aa6f1e42c6890d3187dad77d048f..092d4e29ca1893abcd3a6563cbf6ad22399619d7 100644 (file)
@@ -292,6 +292,10 @@ _e_renderer_cb_attach(E_Surface *surface, E_Buffer *buffer)
       case WL_SHM_FORMAT_ARGB8888:
         format = PIXMAN_a8r8g8b8;
         break;
+      default:
+        e_buffer_reference(&state->buffer_reference, NULL);
+        return;
+        break;
      }
 
    buffer->shm_buffer = shm_buffer;
index fe3699170ed6b9c73af2d1cac19f7e5a1e4d43d9..4b81f577131406eb02d4c6db65abf248d08c36e1 100644 (file)
@@ -19,12 +19,35 @@ e_shell_surface_new(E_Surface *surface, unsigned int id)
    ess->type = E_SHELL_SURFACE_TYPE_NONE;
    ess->ntype = E_SHELL_SURFACE_TYPE_NONE;
 
-   wl_signal_init(&ess->wl.resource.destroy_signal);
    wl_list_init(&ess->wl.link);
 
-   ess->wl.resource.object.id = id;
-   ess->wl.resource.object.interface = &wl_shell_surface_interface;
-   ess->wl.resource.data = ess;
-
    return ess;
 }
+
+EAPI void 
+e_shell_surface_destroy(E_Shell_Surface *ess)
+{
+   if (!ess) return;
+
+   wl_signal_emit(&ess->signals.destroy, ess);
+
+   /* TODO: handle popup */
+
+   wl_list_remove(&ess->wl.surface_destroy.link);
+   ess->surface->configure = NULL;
+
+   if (ess->ping_timer) 
+     {
+        if (ess->ping_timer->source)
+          wl_event_source_remove(ess->ping_timer->source);
+
+        E_FREE(ess->ping_timer);
+     }
+
+   free(ess->title);
+   free(ess->clas);
+
+   wl_list_remove(&ess->wl.link);
+
+   E_FREE(ess);
+}
index fb6ac2b27f2cec3ab395b920be62213db2882f2e..991380dea1a076c1ee83fbe66220250145ce3cfc 100644 (file)
@@ -22,11 +22,16 @@ struct _E_Shell_Surface
 {
    struct 
      {
-        struct wl_resource resource;
+        struct wl_resource *resource;
         struct wl_listener surface_destroy;
         struct wl_list link;
      } wl;
 
+   struct 
+     {
+        struct wl_signal destroy;
+     } signals;
+
    struct 
      {
         Evas_Coord x, y, w, h;
@@ -67,6 +72,7 @@ struct _E_Shell_Surface_Ping_Timer
 };
 
 EAPI E_Shell_Surface *e_shell_surface_new(E_Surface *surface, unsigned int id);
+EAPI void e_shell_surface_destroy(E_Shell_Surface *ess);
 
 # endif
 #endif
index bdaf17d9fc93a1c587f6f746ed6ac83df5bf8549..db93665cbba2f6d88cc67b92bf2321c2e3e0af39 100644 (file)
@@ -8,8 +8,8 @@ static void _e_surface_cb_commit(struct wl_client *client EINA_UNUSED, struct wl
 static void _e_surface_cb_frame(struct wl_client *client, struct wl_resource *resource, unsigned int callback);
 static void _e_surface_cb_opaque_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *region_resource);
 static void _e_surface_cb_input_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *region_resource);
+static void _e_surface_cb_buffer_scale_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, int scale);
 static void _e_surface_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED);
-
 static void _e_surface_frame_cb_destroy(struct wl_resource *resource);
 
 /* local wayland interfaces */
@@ -22,7 +22,8 @@ static const struct wl_surface_interface _e_surface_interface =
    _e_surface_cb_opaque_set,
    _e_surface_cb_input_set,
    _e_surface_cb_commit,
-   NULL // cb_buffer_transform_set
+   NULL, // cb_buffer_transform_set
+   NULL // cb_buffer_scale_set
 };
 
 EAPI E_Surface *
@@ -35,6 +36,9 @@ e_surface_new(struct wl_client *client, unsigned int id)
 
    es->wl.id = id;
 
+   es->scale = 1;
+   es->pending.scale = es->scale;
+
    /* initialize the destroy signal */
    wl_signal_init(&es->signals.destroy);
 
@@ -289,6 +293,18 @@ e_surface_activate(E_Surface *es, E_Input *seat)
    wl_signal_emit(&comp->signals.activate, es);
 }
 
+EAPI int 
+e_surface_buffer_width(E_Surface *es)
+{
+   return es->buffer.reference.buffer->w / es->scale;
+}
+
+EAPI int 
+e_surface_buffer_height(E_Surface *es)
+{
+   return es->buffer.reference.buffer->h / es->scale;
+}
+
 /* local functions */
 static void 
 _e_surface_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
@@ -302,12 +318,28 @@ _e_surface_cb_attach(struct wl_client *client EINA_UNUSED, struct wl_resource *r
    E_Surface *es;
    E_Buffer *buffer = NULL;
 
+   printf("E_Surface Attach\n");
+
    /* try to cast the resource to our surface */
-   if (!(es = wl_resource_get_user_data(resource))) return;
+   if (!(es = wl_resource_get_user_data(resource)))
+     {
+        printf("\tCOULD NOT GET SURFACE FROM RESOURCE !!\n");
+        return;
+     }
+
+   printf("\tHave Surface: %p\n", es);
 
    /* if we have a buffer resource, get a wl_buffer from it */
    if (buffer_resource) buffer = e_buffer_resource_get(buffer_resource);
 
+   if (buffer) printf("\tHave Buffer\n");
+   else printf("\tNO BUFFER !!!\n");
+
+   if (buffer)
+     {
+        printf("\tBuffer Size: %d %d\n", buffer->w, buffer->h);
+     }
+
    /* if we have a previous pending buffer, remove it
     * 
     * NB: This means that attach was called more than once without calling 
@@ -332,7 +364,7 @@ _e_surface_cb_damage(struct wl_client *client EINA_UNUSED, struct wl_resource *r
    E_Surface *es;
 
    /* try to cast the resource to our surface */
-   if (!(es = resource->data)) return;
+   if (!(es = wl_resource_get_user_data(resource))) return;
 
    /* add this damage rectangle */
    pixman_region32_union_rect(&es->pending.damage, &es->pending.damage, 
@@ -346,8 +378,14 @@ _e_surface_cb_commit(struct wl_client *client EINA_UNUSED, struct wl_resource *r
    Evas_Coord bw = 0, bh = 0;
    pixman_region32_t opaque;
 
+   printf("Surface Commit\n");
+
    /* try to cast the resource to our surface */
-   if (!(es = resource->data)) return;
+   if (!(es = wl_resource_get_user_data(resource))) return;
+
+   printf("\tHave Surface: %p\n", es);
+
+   es->scale = es->pending.scale;
 
    /* if we have a pending buffer, attach it */
    if ((es->pending.buffer) || (es->pending.new_attach))
@@ -356,8 +394,8 @@ _e_surface_cb_commit(struct wl_client *client EINA_UNUSED, struct wl_resource *r
    /* if we have a referenced buffer, get it's size */
    if (es->buffer.reference.buffer)
      {
-        bw = es->buffer.reference.buffer->w;
-        bh = es->buffer.reference.buffer->h;
+        bw = e_surface_buffer_width(es);
+        bh = e_surface_buffer_height(es);
      }
 
    /* if we attached a new buffer, call the surface configure function */
@@ -377,7 +415,6 @@ _e_surface_cb_commit(struct wl_client *client EINA_UNUSED, struct wl_resource *r
    pixman_region32_union(&es->damage, &es->damage, &es->pending.damage);
    pixman_region32_intersect_rect(&es->damage, &es->damage, 
                                   0, 0, es->geometry.w, es->geometry.h);
-   /* TODO: empty region */
 
    /* free any pending damage */
    pixman_region32_fini(&es->pending.damage);
@@ -391,6 +428,7 @@ _e_surface_cb_commit(struct wl_client *client EINA_UNUSED, struct wl_resource *r
         pixman_region32_copy(&es->opaque, &opaque);
         es->geometry.changed = EINA_TRUE;
      }
+   pixman_region32_fini(&opaque);
 
    /* combine any pending input */
    pixman_region32_fini(&es->input);
@@ -436,14 +474,15 @@ _e_surface_cb_opaque_set(struct wl_client *client EINA_UNUSED, struct wl_resourc
    E_Surface *es;
 
    /* try to cast the resource to our surface */
-   if (!(es = resource->data)) return;
+   if (!(es = wl_resource_get_user_data(resource))) return;
 
    if (region_resource)
      {
         E_Region *reg;
 
         /* try to cast this resource to our region */
-        reg = region_resource->data;
+        if (!(reg = wl_resource_get_user_data(region_resource)))
+          return;
         pixman_region32_copy(&es->pending.opaque, &reg->region);
      }
    else
@@ -459,14 +498,15 @@ _e_surface_cb_input_set(struct wl_client *client EINA_UNUSED, struct wl_resource
    E_Surface *es;
 
    /* try to cast the resource to our surface */
-   if (!(es = resource->data)) return;
+   if (!(es = wl_resource_get_user_data(resource))) return;
 
    if (region_resource)
      {
         E_Region *reg;
 
         /* try to cast this resource to our region */
-        reg = region_resource->data;
+        if (!(reg = wl_resource_get_user_data(region_resource)))
+          return;
         pixman_region32_copy(&es->pending.input, &reg->region);
      }
    else
@@ -477,6 +517,15 @@ _e_surface_cb_input_set(struct wl_client *client EINA_UNUSED, struct wl_resource
      }
 }
 
+static void 
+_e_surface_cb_buffer_scale_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, int scale)
+{
+   E_Surface *es;
+
+   if (!(es = wl_resource_get_user_data(resource))) return;
+   es->pending.scale = scale;
+}
+
 static void 
 _e_surface_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
 {
index 5b10b57d53cdbe465abff856822b1e034ef5fb50..260c2d5987ba7ec098409d66f9bf41d801424529 100644 (file)
@@ -37,6 +37,7 @@ struct _E_Surface
 
         Evas_Coord x, y;
         Eina_Bool new_attach : 1;
+        int scale;
      } pending;
 
    pixman_region32_t bounding;
@@ -50,6 +51,7 @@ struct _E_Surface
    E_Plane *plane;
    E_Output *output;
    unsigned int output_mask;
+   int scale;
 
    struct 
      {
@@ -86,6 +88,8 @@ EAPI void e_surface_show(E_Surface *es);
 EAPI void e_surface_repaint_schedule(E_Surface *es);
 EAPI void e_surface_output_assign(E_Surface *es);
 EAPI void e_surface_activate(E_Surface *es, E_Input *seat);
+EAPI int e_surface_buffer_width(E_Surface *es);
+EAPI int e_surface_buffer_height(E_Surface *es);
 
 # endif
 #endif