From b8081e7c0591cd251f2b76f8aad8eaca4d90e06e Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Tue, 25 Jun 2013 09:00:15 +0100 Subject: [PATCH] Update e_wayland for recent wl_resource and wl_client changes Signed-off-by: Chris Michael --- src/bin/e_wayland/e_comp.c | 13 +++-- src/bin/e_wayland/e_input.c | 53 ++++++++++----------- src/bin/e_wayland/e_output.c | 10 ++-- src/bin/e_wayland/e_region.c | 5 +- src/bin/e_wayland/e_renderer.c | 4 ++ src/bin/e_wayland/e_shell_surface.c | 33 +++++++++++-- src/bin/e_wayland/e_shell_surface.h | 8 +++- src/bin/e_wayland/e_surface.c | 73 ++++++++++++++++++++++++----- src/bin/e_wayland/e_surface.h | 4 ++ 9 files changed, 143 insertions(+), 60 deletions(-) diff --git a/src/bin/e_wayland/e_comp.c b/src/bin/e_wayland/e_comp.c index d85272c09..4b3ce411a 100644 --- a/src/bin/e_wayland/e_comp.c +++ b/src/bin/e_wayland/e_comp.c @@ -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); } diff --git a/src/bin/e_wayland/e_input.c b/src/bin/e_wayland/e_input.c index 2cfb84965..c722bb25a 100644 --- a/src/bin/e_wayland/e_input.c +++ b/src/bin/e_wayland/e_input.c @@ -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)); } diff --git a/src/bin/e_wayland/e_output.c b/src/bin/e_wayland/e_output.c index a75888b45..6cde034df 100644 --- a/src/bin/e_wayland/e_output.c +++ b/src/bin/e_wayland/e_output.c @@ -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); } diff --git a/src/bin/e_wayland/e_region.c b/src/bin/e_wayland/e_region.c index b3d2ae21a..f93887399 100644 --- a/src/bin/e_wayland/e_region.c +++ b/src/bin/e_wayland/e_region.c @@ -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(®->region, ®->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(®->region, ®->region, &rect); diff --git a/src/bin/e_wayland/e_renderer.c b/src/bin/e_wayland/e_renderer.c index 70e0f432c..092d4e29c 100644 --- a/src/bin/e_wayland/e_renderer.c +++ b/src/bin/e_wayland/e_renderer.c @@ -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; diff --git a/src/bin/e_wayland/e_shell_surface.c b/src/bin/e_wayland/e_shell_surface.c index fe3699170..4b81f5771 100644 --- a/src/bin/e_wayland/e_shell_surface.c +++ b/src/bin/e_wayland/e_shell_surface.c @@ -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); +} diff --git a/src/bin/e_wayland/e_shell_surface.h b/src/bin/e_wayland/e_shell_surface.h index fb6ac2b27..991380dea 100644 --- a/src/bin/e_wayland/e_shell_surface.h +++ b/src/bin/e_wayland/e_shell_surface.h @@ -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 diff --git a/src/bin/e_wayland/e_surface.c b/src/bin/e_wayland/e_surface.c index bdaf17d9f..db93665cb 100644 --- a/src/bin/e_wayland/e_surface.c +++ b/src/bin/e_wayland/e_surface.c @@ -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, ®->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, ®->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) { diff --git a/src/bin/e_wayland/e_surface.h b/src/bin/e_wayland/e_surface.h index 5b10b57d5..260c2d598 100644 --- a/src/bin/e_wayland/e_surface.h +++ b/src/bin/e_wayland/e_surface.h @@ -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