From 1e4ddea0147e866496143aa17bf6310c6ca38643 Mon Sep 17 00:00:00 2001 From: Gwanglim Lee Date: Wed, 13 May 2015 23:24:22 +0900 Subject: [PATCH] change name of wayland interface for tizen_extension protocol Change-Id: I3e4fb5664f6f0e1a21578c01454c70e445c27e72 --- src/bin/e_pixmap.c | 26 +++---- src/bin/e_pixmap.h | 4 +- src/modules/Makefile_wl_desktop_shell.mk | 4 +- src/modules/wl_desktop_shell/e_mod_main.c | 91 +++++++++++----------- .../wl_desktop_shell/e_transient_for_protocol.c | 39 ---------- .../wl_desktop_shell/e_transient_for_protocol.h | 62 --------------- src/modules/wl_desktop_shell/tizen_extension.xml | 18 +++++ .../wl_desktop_shell/tizen_extension_protocol.c | 39 ++++++++++ .../tizen_extension_server_protocol.h | 65 ++++++++++++++++ 9 files changed, 185 insertions(+), 163 deletions(-) delete mode 100755 src/modules/wl_desktop_shell/e_transient_for_protocol.c delete mode 100755 src/modules/wl_desktop_shell/e_transient_for_protocol.h create mode 100644 src/modules/wl_desktop_shell/tizen_extension.xml create mode 100644 src/modules/wl_desktop_shell/tizen_extension_protocol.c create mode 100644 src/modules/wl_desktop_shell/tizen_extension_server_protocol.h diff --git a/src/bin/e_pixmap.c b/src/bin/e_pixmap.c index 349c158..62d5d26 100644 --- a/src/bin/e_pixmap.c +++ b/src/bin/e_pixmap.c @@ -8,8 +8,8 @@ #endif static Eina_Hash *pixmaps[2] = {NULL}; -static Eina_Hash *gids = NULL; -static uint32_t gid = 0; +static Eina_Hash *res_ids = NULL; +static uint32_t res_id = 0; struct _E_Pixmap { @@ -20,7 +20,7 @@ struct _E_Pixmap E_Pixmap_Type type; uint64_t win; - uint32_t gid; + uint32_t res_id; Ecore_Window parent; int w, h; @@ -265,11 +265,11 @@ e_pixmap_new(E_Pixmap_Type type, ...) cp = _e_pixmap_new(type); cp->win = id; eina_hash_add(pixmaps[type], &id, cp); - if (!gids) - gids = eina_hash_int32_new((Eina_Free_Cb)_e_pixmap_free); - gid++; - cp->gid = gid; - eina_hash_add(gids, &gid, cp); + if (!res_ids) + res_ids = eina_hash_int32_new((Eina_Free_Cb)_e_pixmap_free); + cp->res_id = res_id; + eina_hash_add(res_ids, &res_id, cp); + res_id++; #endif break; } @@ -513,21 +513,21 @@ e_pixmap_find_client(E_Pixmap_Type type, ...) } EAPI E_Client * -e_pixmap_find_client_by_tizen_gid(uint32_t gid) +e_pixmap_find_client_by_res_id(uint32_t res_id) { E_Pixmap *cp; - if (!gids) return NULL; - cp = eina_hash_find(gids, &gid); + if (!res_ids) return NULL; + cp = eina_hash_find(res_ids, &res_id); return (!cp) ? NULL : cp->client; } EAPI uint32_t -e_pixmap_tizen_gid_get(E_Pixmap *cp) +e_pixmap_res_id_get(E_Pixmap *cp) { EINA_SAFETY_ON_NULL_RETURN_VAL(cp, 0); - return cp->gid; + return cp->res_id; } EAPI uint64_t diff --git a/src/bin/e_pixmap.h b/src/bin/e_pixmap.h index e47e5ce..2d734c8 100644 --- a/src/bin/e_pixmap.h +++ b/src/bin/e_pixmap.h @@ -36,8 +36,8 @@ EAPI void e_pixmap_client_set(E_Pixmap *cp, E_Client *ec); EAPI E_Client *e_pixmap_client_get(E_Pixmap *cp); EAPI E_Pixmap *e_pixmap_find(E_Pixmap_Type type, ...); EAPI E_Client *e_pixmap_find_client(E_Pixmap_Type type, ...); -EAPI E_Client *e_pixmap_find_client_by_tizen_gid(uint32_t gid); -EAPI uint32_t e_pixmap_tizen_gid_get(E_Pixmap *cp); +EAPI E_Client *e_pixmap_find_client_by_res_id(uint32_t res_id); +EAPI uint32_t e_pixmap_res_id_get(E_Pixmap *cp); EAPI uint64_t e_pixmap_window_get(E_Pixmap *cp); EAPI Ecore_Window e_pixmap_parent_window_get(E_Pixmap *cp); EAPI Eina_Bool e_pixmap_native_surface_init(E_Pixmap *cp, Evas_Native_Surface *ns); diff --git a/src/modules/Makefile_wl_desktop_shell.mk b/src/modules/Makefile_wl_desktop_shell.mk index 15f3025..efbad10 100644 --- a/src/modules/Makefile_wl_desktop_shell.mk +++ b/src/modules/Makefile_wl_desktop_shell.mk @@ -24,8 +24,8 @@ src_modules_wl_desktop_shell_module_la_SOURCES = \ src/modules/wl_desktop_shell/e_scaler.h \ src/modules/wl_desktop_shell/e_scaler_protocol.c \ src/modules/wl_desktop_shell/e_scaler_protocol.h \ - src/modules/wl_desktop_shell/e_transient_for_protocol.h \ - src/modules/wl_desktop_shell/e_transient_for_protocol.c + src/modules/wl_desktop_shell/tizen_extension_server_protocol.h \ + src/modules/wl_desktop_shell/tizen_extension_protocol.c PHONIES += wl_desktop_shell install-wl_desktop_shell wl_desktop_shell: $(wl_desktop_shellpkg_LTLIBRARIES) $(wl_desktop_shell_DATA) diff --git a/src/modules/wl_desktop_shell/e_mod_main.c b/src/modules/wl_desktop_shell/e_mod_main.c index bd3b670..30f513d 100644 --- a/src/modules/wl_desktop_shell/e_mod_main.c +++ b/src/modules/wl_desktop_shell/e_mod_main.c @@ -3,7 +3,7 @@ #include "e.h" #include "e_desktop_shell_protocol.h" #include "e_scaler.h" -#include "e_transient_for_protocol.h" +#include "tizen_extension_server_protocol.h" #define XDG_SERVER_VERSION 4 @@ -1349,22 +1349,22 @@ _e_xdg_shell_cb_pong(struct wl_client *client EINA_UNUSED, struct wl_resource *r } static void -_e_tizen_gid_cb_destroy(struct wl_client *client, struct wl_resource *resource) +_e_tz_res_cb_destroy(struct wl_client *client, struct wl_resource *resource) { wl_resource_destroy(resource); } -static const struct tizen_gid_interface _e_tizen_gid_interface = +static const struct tizen_resource_interface _e_tz_res_interface = { - _e_tizen_gid_cb_destroy, + _e_tz_res_cb_destroy }; static void -_e_tizen_ext_cb_tizen_gid_get(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *surface) +_e_tz_surf_ext_cb_tz_res_get(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *surface) { struct wl_resource *res; E_Pixmap *ep; - uint32_t gid; + uint32_t res_id; /* get the pixmap from this surface so we can find the client */ if (!(ep = wl_resource_get_user_data(surface))) @@ -1379,56 +1379,51 @@ _e_tizen_ext_cb_tizen_gid_get(struct wl_client *client, struct wl_resource *reso if (e_pixmap_type_get(ep) != E_PIXMAP_TYPE_WL) return; /* find the window id for this pixmap */ - gid = e_pixmap_tizen_gid_get(ep); + res_id = e_pixmap_res_id_get(ep); - DBG("TIZEN_EXT: tizen_gid_get %" PRIu32, gid); + DBG("tizen resource id %" PRIu32, res_id); /* try to create a tizen_gid */ - if (!(res = wl_resource_create(client, &tizen_gid_interface, wl_resource_get_version(resource), id))) + if (!(res = wl_resource_create(client, + &tizen_resource_interface, + wl_resource_get_version(resource), + id))) { wl_resource_post_no_memory(resource); return; } - wl_resource_set_implementation(res, &_e_tizen_gid_interface, - ep, NULL); - tizen_gid_send_notify(res, gid); + wl_resource_set_implementation(res, + &_e_tz_res_interface, + ep, + NULL); + + tizen_resource_send_resource_id(res, res_id); } static void -_e_tizen_ext_cb_transient_for_set(struct wl_client *client, struct wl_resource *resource, uint32_t surface_gid, uint32_t parent_gid) +_e_tz_surf_ext_cb_transient_for_set(struct wl_client *client, struct wl_resource *resource, uint32_t child_id, uint32_t parent_id) { - E_Client *ec; - E_Client *pc; - struct wl_resource *parent_resource; + E_Client *ec, *pc; + struct wl_resource *parent_res; - DBG("TIZEN_EXT: surface_gid: %" PRIu32 ", parent_gid : %" PRIu32, surface_gid, parent_gid); + DBG("chid_id: %" PRIu32 ", parent_id: %" PRIu32, child_id, parent_id); - ec = e_pixmap_find_client_by_tizen_gid(surface_gid); - if (!ec) - { - ERR("No Client for this surface gid"); - return; - } + ec = e_pixmap_find_client_by_res_id(child_id); + EINA_SAFETY_ON_NULL_RETURN(ec); - /* find the parent client */ - pc = e_pixmap_find_client_by_tizen_gid(parent_gid); - if (!pc) - { - ERR("No Client for this parent gid"); - return; - } - if (pc->comp_data->surface) - { - parent_resource = pc->comp_data->surface; - _e_shell_surface_parent_set(ec, parent_resource); - } + pc = e_pixmap_find_client_by_res_id(parent_id); + EINA_SAFETY_ON_NULL_RETURN(pc); + EINA_SAFETY_ON_NULL_RETURN(pc->comp_data); + + parent_res = pc->comp_data->surface; + _e_shell_surface_parent_set(ec, parent_res); } -static const struct tizen_ext_interface _e_tizen_ext_interface = +static const struct tizen_surface_extension_interface _e_tz_surf_ext_interface = { - _e_tizen_ext_cb_tizen_gid_get, - _e_tizen_ext_cb_transient_for_set, + _e_tz_surf_ext_cb_tz_res_get, + _e_tz_surf_ext_cb_transient_for_set }; static const struct wl_shell_interface _e_shell_interface = @@ -1541,7 +1536,7 @@ _e_xdg_shell_cb_bind(struct wl_client *client, void *data, uint32_t version, uin } static void -_e_tizen_ext_cb_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id) +_e_tz_surf_ext_cb_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id) { E_Comp_Data *cdata; struct wl_resource *res; @@ -1552,14 +1547,17 @@ _e_tizen_ext_cb_bind(struct wl_client *client, void *data, uint32_t version, uin return; } - if (!(res = wl_resource_create(client, &tizen_ext_interface, MIN(version, 1), id))) + if (!(res = wl_resource_create(client, + &tizen_surface_extension_interface, + MIN(version, 1), + id))) { ERR("Could not create tizen_ext resource: %m"); wl_client_post_no_memory(client); return; } - wl_resource_set_implementation(res, &_e_tizen_ext_interface, cdata, NULL); + wl_resource_set_implementation(res, &_e_tz_surf_ext_interface, cdata, NULL); } EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Wl_Desktop_Shell" }; @@ -1597,11 +1595,14 @@ e_modapi_init(E_Module *m) e_scaler_init(); - /* try to add tizen_ext to wayland globals */ - if (!wl_global_create(cdata->wl.disp, &tizen_ext_interface, 1, - cdata, _e_tizen_ext_cb_bind)) + /* try to create global tizen surface extention interface */ + if (!wl_global_create(cdata->wl.disp, + &tizen_surface_extension_interface, + 1, + cdata, + _e_tz_surf_ext_cb_bind)) { - ERR("Could not add tizen_ext to wayland globals: %m"); + ERR("Could not create tizen_surface_extension to wayland globals: %m"); return NULL; } diff --git a/src/modules/wl_desktop_shell/e_transient_for_protocol.c b/src/modules/wl_desktop_shell/e_transient_for_protocol.c deleted file mode 100755 index a8d9e07..0000000 --- a/src/modules/wl_desktop_shell/e_transient_for_protocol.c +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include "wayland-util.h" - -extern const struct wl_interface tizen_gid_interface; -extern const struct wl_interface wl_surface_interface; - -static const struct wl_interface *types[] = { - NULL, - NULL, - &tizen_gid_interface, - &wl_surface_interface, -}; - -static const struct wl_message tizen_ext_requests[] = { - { "get_tizen_gid", "no", types + 2 }, - { "set_transient_for", "uu", types + 0 }, -}; - -WL_EXPORT const struct wl_interface tizen_ext_interface = { - "tizen_ext", 1, - 2, tizen_ext_requests, - 0, NULL, -}; - -static const struct wl_message tizen_gid_requests[] = { - { "destroy", "", types + 0 }, -}; - -static const struct wl_message tizen_gid_events[] = { - { "notify", "u", types + 0 }, -}; - -WL_EXPORT const struct wl_interface tizen_gid_interface = { - "tizen_gid", 1, - 1, tizen_gid_requests, - 1, tizen_gid_events, -}; - diff --git a/src/modules/wl_desktop_shell/e_transient_for_protocol.h b/src/modules/wl_desktop_shell/e_transient_for_protocol.h deleted file mode 100755 index 15c6c4e..0000000 --- a/src/modules/wl_desktop_shell/e_transient_for_protocol.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef TIZEN_EXT_SERVER_PROTOCOL_H -#define TIZEN_EXT_SERVER_PROTOCOL_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include "wayland-util.h" - -struct wl_client; -struct wl_resource; - -struct tizen_ext; -struct tizen_gid; - -extern const struct wl_interface tizen_ext_interface; -extern const struct wl_interface tizen_gid_interface; - -struct tizen_ext_interface { - /** - * get_tizen_gid - (none) - * @id: (none) - * @surface: (none) - */ - void (*get_tizen_gid)(struct wl_client *client, - struct wl_resource *resource, - uint32_t id, - struct wl_resource *surface); - /** - * set_transient_for - (none) - * @surface_gid: (none) - * @parent_gid: (none) - */ - void (*set_transient_for)(struct wl_client *client, - struct wl_resource *resource, - uint32_t surface_gid, - uint32_t parent_gid); -}; - -struct tizen_gid_interface { - /** - * destroy - (none) - */ - void (*destroy)(struct wl_client *client, - struct wl_resource *resource); -}; - -#define TIZEN_GID_NOTIFY 0 - -static inline void -tizen_gid_send_notify(struct wl_resource *resource_, uint32_t gid) -{ - wl_resource_post_event(resource_, TIZEN_GID_NOTIFY, gid); -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/modules/wl_desktop_shell/tizen_extension.xml b/src/modules/wl_desktop_shell/tizen_extension.xml new file mode 100644 index 0000000..81e70b0 --- /dev/null +++ b/src/modules/wl_desktop_shell/tizen_extension.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/modules/wl_desktop_shell/tizen_extension_protocol.c b/src/modules/wl_desktop_shell/tizen_extension_protocol.c new file mode 100644 index 0000000..23af7ac --- /dev/null +++ b/src/modules/wl_desktop_shell/tizen_extension_protocol.c @@ -0,0 +1,39 @@ +#include +#include +#include "wayland-util.h" + +extern const struct wl_interface tizen_resource_interface; +extern const struct wl_interface wl_surface_interface; + +static const struct wl_interface *types[] = { + NULL, + NULL, + &tizen_resource_interface, + &wl_surface_interface, +}; + +static const struct wl_message tizen_resource_requests[] = { + { "destroy", "", types + 0 }, +}; + +static const struct wl_message tizen_resource_events[] = { + { "resource_id", "u", types + 0 }, +}; + +WL_EXPORT const struct wl_interface tizen_resource_interface = { + "tizen_resource", 1, + 1, tizen_resource_requests, + 1, tizen_resource_events, +}; + +static const struct wl_message tizen_surface_extension_requests[] = { + { "get_tizen_resource", "no", types + 2 }, + { "set_transient_for", "uu", types + 0 }, +}; + +WL_EXPORT const struct wl_interface tizen_surface_extension_interface = { + "tizen_surface_extension", 1, + 2, tizen_surface_extension_requests, + 0, NULL, +}; + diff --git a/src/modules/wl_desktop_shell/tizen_extension_server_protocol.h b/src/modules/wl_desktop_shell/tizen_extension_server_protocol.h new file mode 100644 index 0000000..a3ad9fb --- /dev/null +++ b/src/modules/wl_desktop_shell/tizen_extension_server_protocol.h @@ -0,0 +1,65 @@ +#ifndef TIZEN_EXTENSION_SERVER_PROTOCOL_H +#define TIZEN_EXTENSION_SERVER_PROTOCOL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "wayland-server.h" + +struct wl_client; +struct wl_resource; + +struct tizen_resource; +struct tizen_surface_extension; + +extern const struct wl_interface tizen_resource_interface; +extern const struct wl_interface tizen_surface_extension_interface; + +struct tizen_resource_interface { + /** + * destroy - (none) + */ + void (*destroy)(struct wl_client *client, + struct wl_resource *resource); +}; + +#define TIZEN_RESOURCE_RESOURCE_ID 0 + +#define TIZEN_RESOURCE_RESOURCE_ID_SINCE_VERSION 1 + +static inline void +tizen_resource_send_resource_id(struct wl_resource *resource_, uint32_t id) +{ + wl_resource_post_event(resource_, TIZEN_RESOURCE_RESOURCE_ID, id); +} + +struct tizen_surface_extension_interface { + /** + * get_tizen_resource - (none) + * @id: (none) + * @surface: (none) + */ + void (*get_tizen_resource)(struct wl_client *client, + struct wl_resource *resource, + uint32_t id, + struct wl_resource *surface); + /** + * set_transient_for - (none) + * @child_id: (none) + * @parent_id: (none) + */ + void (*set_transient_for)(struct wl_client *client, + struct wl_resource *resource, + uint32_t child_id, + uint32_t parent_id); +}; + + +#ifdef __cplusplus +} +#endif + +#endif -- 2.7.4