From: Stefan Schmidt Date: Thu, 10 Apr 2014 15:01:58 +0000 (+0200) Subject: e_uuid_store: Use libuuid for UUID generation and handling X-Git-Tag: upstream/0.19.99~1191 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cc23186dbdbad31450f833ada77232079f0481eb;p=platform%2Fupstream%2Fenlightenment.git e_uuid_store: Use libuuid for UUID generation and handling Instead of rolling our own we go with a known working UUID implementation here. Dependency should be easy enough as more or less every Linux system is shipping it anyway. --- diff --git a/configure.ac b/configure.ac index 4d65f7b..1723c58 100644 --- a/configure.ac +++ b/configure.ac @@ -802,7 +802,7 @@ AC_MSG_CHECKING([whether wayland EGL support is enabled]) AC_MSG_RESULT([${e_cv_want_wayland_egl}]) if test "x${e_cv_want_wayland_only}" != "xno" || test "x${e_cv_want_wayland_clients}" != "xno";then - PKG_CHECK_MODULES([WAYLAND], [ecore-wayland wayland-server pixman-1 xkbcommon], + PKG_CHECK_MODULES([WAYLAND], [ecore-wayland wayland-server pixman-1 xkbcommon uuid], [ have_wayland=yes AC_DEFINE_UNQUOTED([HAVE_WAYLAND],[1],[enable wayland support]) diff --git a/src/bin/e.h b/src/bin/e.h index 46a675e..7fbc1cd 100644 --- a/src/bin/e.h +++ b/src/bin/e.h @@ -125,6 +125,7 @@ void *alloca (size_t); # ifdef HAVE_WAYLAND # include +# include # endif # ifdef EAPI diff --git a/src/bin/e_client.c b/src/bin/e_client.c index 368640f..f304f76 100644 --- a/src/bin/e_client.c +++ b/src/bin/e_client.c @@ -2260,6 +2260,10 @@ e_client_new(E_Comp *c, E_Pixmap *cp, int first_map, int internal) if (!ec) return NULL; e_object_del_func_set(E_OBJECT(ec), E_OBJECT_CLEANUP_FUNC(_e_client_del)); +#ifdef HAVE_WAYLAND_CLIENTS + uuid_generate(ec->uuid); +#endif + ec->focus_policy_override = E_FOCUS_LAST; ec->w = 1; ec->h = 1; diff --git a/src/bin/e_client.h b/src/bin/e_client.h index aacb593..c2fa816 100644 --- a/src/bin/e_client.h +++ b/src/bin/e_client.h @@ -683,6 +683,10 @@ struct E_Client Eina_Bool ignored : 1; // client is comp-ignored Eina_Bool no_shape_cut : 1; // client shape should not be cut Eina_Bool maximize_override : 1; // client is doing crazy stuff and should "just do it" when moving/resizing + +#ifdef HAVE_WAYLAND_CLIENTS + uuid_t uuid; +#endif }; #define e_client_focus_policy_click(ec) \ diff --git a/src/bin/e_uuid_store.c b/src/bin/e_uuid_store.c index 584d47b..3103dbf 100644 --- a/src/bin/e_uuid_store.c +++ b/src/bin/e_uuid_store.c @@ -26,6 +26,7 @@ e_uuid_dump(void) { struct uuid_table *table; int i; + char uuid_string[37]; if (store == NULL) return; @@ -35,8 +36,9 @@ e_uuid_dump(void) INF("Dump UUID table:"); for (i = 0; i < UUID_STORE_TABLE_SIZE -1; i++) { - if (table->entries[i].uuid == 0) continue; - INF("UUID %li, x=%i, y=%i, width=%i, heigth=%i", table->entries[i].uuid, table->entries[i].x, + if (uuid_is_null(table->entries[i].uuid)) continue; + uuid_unparse(table->entries[i].uuid, uuid_string); + INF("UUID %s, x=%i, y=%i, width=%i, heigth=%i", uuid_string, table->entries[i].x, table->entries[i].y, table->entries[i].width, table->entries[i].heigth); } @@ -117,10 +119,11 @@ e_uuid_store_reload(void) } Eina_Bool -e_uuid_store_entry_del(long uuid) +e_uuid_store_entry_del(uuid_t uuid) { struct uuid_table *table; int i; + char uuid_string[37]; if (store == NULL) return EINA_FALSE; @@ -130,29 +133,32 @@ e_uuid_store_entry_del(long uuid) /* Search through uuid list and delete if found */ for (i = 0; i < UUID_STORE_TABLE_SIZE -1; i++) { - if (table->entries[i].uuid == uuid) + if (!uuid_compare(table->entries[i].uuid, uuid)) { - table->entries[i].uuid = 0; + uuid_clear(table->entries[i].uuid); table->entries[i].x = 0; table->entries[i].x = 0; table->entries[i].width = 0; table->entries[i].heigth = 0; table->entry_count--; - DBG("Removed entry with UUID %li", uuid); + uuid_unparse(uuid, uuid_string); + DBG("Removed entry with UUID %s", uuid_string); return EINA_TRUE; } } - DBG("NOT removed entry with UUID %li. Entry not found.", uuid); + uuid_unparse(uuid, uuid_string); + DBG("NOT removed entry with UUID %s. Entry not found.", uuid_string); return EINA_FALSE; } /* FIXME: Think about having _add and _update functions instead only update */ Eina_Bool -e_uuid_store_entry_update(long uuid, E_Client *ec) +e_uuid_store_entry_update(uuid_t uuid, E_Client *ec) { struct uuid_table *table; int i, index = -1; + char uuid_string[37]; if (store == NULL) return EINA_FALSE; @@ -162,13 +168,14 @@ e_uuid_store_entry_update(long uuid, E_Client *ec) /* Search through uuid list if it already exist if yes update */ for (i = 0; i < UUID_STORE_TABLE_SIZE -1; i++) { - if (table->entries[i].uuid == uuid) + if (!uuid_compare(table->entries[i].uuid, uuid)) { table->entries[i].x = ec->x; table->entries[i].y = ec->y; table->entries[i].width = ec->client.w; table->entries[i].heigth = ec->client.h; - DBG("Updated entry with UUID %li", uuid); + uuid_unparse(uuid, uuid_string); + DBG("Updated entry with UUID %s", uuid_string); return EINA_TRUE; } } @@ -176,7 +183,7 @@ e_uuid_store_entry_update(long uuid, E_Client *ec) /* Find first empty entry */ for (i = 0; i < UUID_STORE_TABLE_SIZE -1; i++) { - if (table->entries[i].uuid == 0) + if (uuid_is_null(table->entries[i].uuid)) index = i; } @@ -187,13 +194,14 @@ e_uuid_store_entry_update(long uuid, E_Client *ec) } /* We do not have this UUID in the table yet. Create it */ - table->entries[index].uuid = uuid; + uuid_copy(table->entries[index].uuid, uuid); table->entries[index].x = ec->x; table->entries[index].y = ec->y; table->entries[index].width = ec->client.w; table->entries[index].heigth = ec->client.h; table->entry_count++; - DBG("Created entry with UUID %li", uuid); + uuid_unparse(table->entries[index].uuid, uuid_string); + DBG("Created entry with UUID %s", uuid_string); return EINA_TRUE; } diff --git a/src/bin/e_uuid_store.h b/src/bin/e_uuid_store.h index 63ce532..c9f6e1e 100644 --- a/src/bin/e_uuid_store.h +++ b/src/bin/e_uuid_store.h @@ -7,7 +7,7 @@ #define UUID_STORE_TABLE_SIZE 100 struct table_entry { - long uuid; + uuid_t uuid; /* data structure for per application properties */ Evas_Coord x, y; Evas_Coord width, heigth; @@ -31,6 +31,6 @@ EINTERN int e_uuid_store_init(void); EINTERN int e_uuid_store_shutdown(void); EAPI void e_uuid_dump(void); EAPI Eina_Bool e_uuid_store_reload(void); -EAPI Eina_Bool e_uuid_store_entry_del(long uuid); -EAPI Eina_Bool e_uuid_store_entry_update(long uuid, E_Client *ec); +EAPI Eina_Bool e_uuid_store_entry_del(uuid_t uuid); +EAPI Eina_Bool e_uuid_store_entry_update(uuid_t uuid, E_Client *ec); #endif