[PATCH] wayland-server: Add APIs to get some structure's value

Pekka Paalanen ppaalanen at gmail.com
Tue Jun 21 08:02:20 UTC 2016


On Tue, 21 Jun 2016 13:45:16 +0900
JengHyun Kang <jhyuni.kang at samsung.com> wrote:

> This patch's purpose is getting global interface information
> registerred in the server.
> If global is created (used wl_global_create()),
> information are saved in global_list.
> But almost structures used in wayland is defined statically.
> So it is hard to get structure's values in server side.
> 
> Added following APIs.
>   - wl_display_get_global_list()
>   - wl_global_get_interface()
>   - wl_interface_get_name()
>   - wl_interface_get_method_count()
>   - wl_interface_get_methods()
>   - wl_interface_get_event_count()
>   - wl_interface_get_events()
>   - wl_message_get_name()
>   - wl_global_list_get_global()
> 
> You can get interface information to combine added APIs.
> (Such as interface's name and events/requests name)
> 
> 1st, you can get wl_list:global_list to use wl_display_get_global_list().
> 2nd, you can get length of wl_list to use wl_list_length() and
>      wl_global to use wl_global_list_get_global().
>      wl_global is saved in list, so you need index to get wl_global.
> 3rd, you can get wl_interface to use wl_global_get_interface().
> 4th, in wl_interface structure, there are so many information about
>      interface name and events/requests information.
>      so you can get information to use wl_interface_get_name(),
>      wl_interface_get_method_count(), wl_interface_get_method(),
>      wl_interface_get_event_count(), wl_interface_get_event().

Hi,

your commit message forgot to explain the one most important thing:

Why?

Also, please see https://patchwork.freedesktop.org/series/4181/ which
is already reviewed and seems to overlap with yours. Giulio has
demonstrated the use case for all the API he is adding with a single
screenshot:
https://i.imgur.com/ihW3d88.jpg

and also roughly explaining how "GammaRay" hooks up to a compositor.

It would be nice if you reviewed Giulio's series, checked how it
matches your needs, and then explain what you are still missing and why.
Personally I am in favour of Giulio's series and no-one has yet
disagreed with it, so I think it has good chances of getting merged
once polished.


Thanks,
pq

> ---
>  src/wayland-server.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  src/wayland-server.h | 27 ++++++++++++++++++++++
>  2 files changed, 90 insertions(+)
> 
> diff --git a/src/wayland-server.c b/src/wayland-server.c
> index 19aa2e8..ac5c2e5 100644
> --- a/src/wayland-server.c
> +++ b/src/wayland-server.c
> @@ -997,6 +997,63 @@ wl_global_destroy(struct wl_global *global)
>  	free(global);
>  }
>  
> +WL_EXPORT const struct wl_interface *
> +wl_global_get_interface(struct wl_global *global)
> +{
> +	return global->interface;
> +}
> +
> +WL_EXPORT struct wl_global *
> +wl_global_list_get_global(struct wl_list *list, int idx)
> +{
> +	int i = 0;
> +	struct wl_global *global;
> +
> +	wl_list_for_each(global, list, link)
> +	{
> +		if (idx == i) break;
> +		i++;
> +	}
> +
> +	return global;
> +}
> +
> +WL_EXPORT const char *
> +wl_interface_get_name(const struct wl_interface *interface)
> +{
> +	return interface->name;
> +}
> +
> +WL_EXPORT int
> +wl_interface_get_method_count(const struct wl_interface *interface)
> +{
> +	return interface->method_count;
> +}
> +
> +WL_EXPORT const struct wl_message *
> +wl_interface_get_methods(const struct wl_interface *interface)
> +{
> +	return interface->methods;
> +}
> +
> +WL_EXPORT int
> +wl_interface_get_event_count(const struct wl_interface *interface)
> +{
> +	return interface->event_count;
> +}
> +
> +WL_EXPORT const struct wl_message *
> +wl_interface_get_events(const struct wl_interface *interface)
> +{
> +	return interface->events;
> +}
> +
> +WL_EXPORT const char *
> +wl_message_get_name(const struct wl_message *message)
> +{
> +	return message->name;
> +}
> +
>  /** Get the current serial number
>   *
>   * \param display The display object
> @@ -1035,6 +1092,12 @@ wl_display_get_event_loop(struct wl_display *display)
>  	return display->loop;
>  }
>  
> +WL_EXPORT struct wl_list *
> +wl_display_get_global_list(struct wl_display *display)
> +{
> +	return &display->global_list;
> +}
> +
>  WL_EXPORT void
>  wl_display_terminate(struct wl_display *display)
>  {
> diff --git a/src/wayland-server.h b/src/wayland-server.h
> index a6e7951..3494641 100644
> --- a/src/wayland-server.h
> +++ b/src/wayland-server.h
> @@ -92,6 +92,33 @@ wl_display_remove_global(struct wl_display *display,
>  
>  #endif
>  
> +struct wl_list *
> +wl_display_get_global_list(struct wl_display *display);
> +
> +const struct wl_interface *
> +wl_global_get_interface(struct wl_global *global);
> +
> +const char *
> +wl_interface_get_name(const struct wl_interface *interface);
> +
> +int
> +wl_interface_get_method_count(const struct wl_interface *interface);
> +
> +const struct wl_message *
> +wl_interface_get_methods(const struct wl_interface *interface);
> +
> +int
> +wl_interface_get_event_count(const struct wl_interface *interface);
> +
> +const struct wl_message *
> +wl_interface_get_events(const struct wl_interface *interface);
> +
> +const char *
> +wl_message_get_name(const struct wl_message *message);
> +
> +struct wl_global *
> +wl_global_list_get_global(struct wl_list *list, int idx);
> +
>  #ifdef  __cplusplus
>  }
>  #endif

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 811 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20160621/7f9cd260/attachment-0001.sig>


More information about the wayland-devel mailing list