On Wed, Nov 27, 2013 at 03:50:23PM -0200, Rafael Antognolli wrote:
> ---
> src/shell.c | 159
> ++--
> 1 file changed, 155 insertions(+), 4 deletions(-)
>
> diff --git a/src/shell.c b/src/shell.c
> index 98fb0fe..0daa136 100644
> --- a/src/shell.c
> +++ b/src/shell.c
> @@ -247,6 +247,12 @@ struct ping_timer {
> uint32_t serial;
> };
>
> +enum shell_surface_class_interface {
> + SHELL_CLASS_WL_SHELL_SURFACE,
> + SHELL_CLASS_XDG_SURFACE,
> + SHELL_CLASS_XDG_POPUP
> +};
> +
> struct shell_surface {
> struct wl_resource *resource;
> struct wl_signal destroy_signal;
> @@ -257,6 +263,7 @@ struct shell_surface {
> struct weston_surface *parent;
> struct desktop_shell *shell;
>
> + enum shell_surface_class_interface shell_class;
> enum shell_surface_type type, next_type;
> char *title, *class;
> int32_t saved_x, saved_y;
> @@ -1918,7 +1925,17 @@ ping_handler(struct weston_surface *surface, uint32_t
> serial)
> wl_event_loop_add_timer(loop, ping_timeout_handler,
> shsurf);
> wl_event_source_timer_update(shsurf->ping_timer->source,
> ping_timeout);
>
> - wl_shell_surface_send_ping(shsurf->resource, serial);
> + switch (shsurf->shell_class) {
We can just use wl_resource_instance_of() on shsurf->resource here.
> + case SHELL_CLASS_WL_SHELL_SURFACE:
> + wl_shell_surface_send_ping(shsurf->resource,
> serial);
> + break;
> + case SHELL_CLASS_XDG_SURFACE:
> + xdg_surface_send_ping(shsurf->resource, serial);
> + break;
> + case SHELL_CLASS_XDG_POPUP:
> + xdg_popup_send_ping(shsurf->resource, serial);
> + break;
> + }
> }
> }
>
> @@ -2664,7 +2681,17 @@ popup_grab_end(struct weston_pointer *pointer)
> assert(!wl_list_empty(&shseat->popup_grab.surfaces_list));
> /* Send the popup_done event to all the popups open */
> wl_list_for_each(shsurf, &shseat->popup_grab.surfaces_list,
> popup.grab_link) {
> - wl_shell_surface_send_popup_done(shsurf->resource);
> + switch (shsurf->shell_class) {
Use wl_resource_instance_of() as well, and let's add a helper we can
use in shell_map_popup() as well.
> + case SHELL_CLASS_WL_SHELL_SURFACE:
> +
> wl_shell_surface_send_popup_done(shsurf->resource);
> + break;
> + case SHELL_CLASS_XDG_POPUP:
> +
> xdg_popup_send_popup_done(shsurf->resource,
> +
> shsurf->popup.serial);
> + break;
> + default:
> + break;
> + }
> shsurf->popup.shseat = NULL;
> if (prev) {
> wl_list_init(&prev->popup.grab_link);
> @@ -2726,7 +2753,17 @@ shell_map_popup(struct shell_surface *shsurf)
> if (shseat->seat->pointer->grab_serial == shsurf->popup.serial) {
> add_popup_grab(shsurf, shseat);
> } else {
> - wl_shell_surface_send_popup_done(shsurf->resource);
> + switch (shsurf->shell_class) {
> + case SHELL_CLASS_WL_SHELL_SURFACE:
> +
> wl_shell_surface_send_popup_done(shsurf->resource);
> + break;
> + case SHELL_CLASS_XDG_POPUP:
> + xdg_popup_send_popup_done(shsurf->resource,
> + shsurf->popup.serial);
> + break;
> + default:
> + break;
> + }
> shseat->popup_grab.client = NULL;
> }
> }
> @@ -2932,6 +2969,8 @@ shell_get_shell_surface(struct wl_client *client,
> return;
> }
>
> + shsurf->shell_class = SHELL_CLASS_WL_SHELL_SURFACE;
> +
> shsurf->resource =
> wl_resource_create(client,
> &wl_shell_surface_interface, 1, id);
> @@ -3169,6 +3208,8 @@ xdg_get_xdg_surface(struct wl_client *client,
> return;
> }
>
> + shsurf->shell_class = SHELL_CLASS_XDG_SURFACE;
> +
> shsurf->resource =
> wl_resource_create(client,
> &xdg_surface_interface, 1, id);
> @@ -3177,12 +3218,122 @@ xdg_get_xdg_surface(struct wl_client *client,
> shsurf, shell_destroy_shell_surface);
> }
>
> +