From b55ce098bf5e49284d84705337027d4b5fc705f8 Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Sat, 28 Jan 2017 16:08:46 +0900 Subject: [PATCH] e thumb - support signal emits and desk pan msgs for thumbs this in theory allows pan desk thumbs to work... but hey ... they are broken anyway... :) @fix --- src/bin/e_thumb.c | 114 +++++++++++++++++++++++++++++---- src/bin/e_thumb.h | 2 + src/bin/e_thumb_main.c | 120 +++++++++++++++++++++++++++-------- src/bin/e_widget_bgpreview.c | 21 +----- 4 files changed, 200 insertions(+), 57 deletions(-) diff --git a/src/bin/e_thumb.c b/src/bin/e_thumb.c index d73b1a824..9d8a87957 100644 --- a/src/bin/e_thumb.c +++ b/src/bin/e_thumb.c @@ -9,13 +9,17 @@ struct _E_Thumb const char *file; const char *key; char *sort_id; + struct { + int x, y, x_count, y_count; + } desk_pan; + Eina_List *sigsrc; unsigned char queued : 1; unsigned char busy : 1; unsigned char done : 1; }; /* local subsystem functions */ -static void _e_thumb_gen_begin(int objid, const char *file, const char *key, int w, int h); +static void _e_thumb_gen_begin(int objid, const char *file, const char *key, int w, int h, int desk_x, int desk_y, int desk_x_count, int desk_y_count, Eina_List *sigsrc); static void _e_thumb_gen_end(int objid); static void _e_thumb_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _e_thumb_hash_add(int objid, Evas_Object *obj); @@ -148,12 +152,20 @@ e_thumb_icon_begin(Evas_Object *obj) eth2->busy = 1; _pending++; if (_pending == 1) _e_thumb_thumbnailers_kill_cancel(); - _e_thumb_gen_begin(eth2->objid, eth2->file, eth2->key, eth2->w, eth2->h); + _e_thumb_gen_begin(eth2->objid, eth2->file, eth2->key, + eth2->w, eth2->h, + eth2->desk_pan.x, eth2->desk_pan.y, + eth2->desk_pan.x_count, eth2->desk_pan.y_count, + eth2->sigsrc); } eth->busy = 1; _pending++; if (_pending == 1) _e_thumb_thumbnailers_kill_cancel(); - _e_thumb_gen_begin(eth->objid, eth->file, eth->key, eth->w, eth->h); + _e_thumb_gen_begin(eth->objid, eth->file, eth->key, + eth->w, eth->h, + eth->desk_pan.x, eth->desk_pan.y, + eth->desk_pan.x_count, eth->desk_pan.y_count, + eth->sigsrc); } E_API void @@ -190,6 +202,28 @@ e_thumb_icon_rethumb(Evas_Object *obj) e_thumb_icon_begin(obj); } +E_API void +e_thumb_desk_pan_set(Evas_Object *obj, int x, int y, int x_count, int y_count) +{ + E_Thumb *eth; + eth = evas_object_data_get(obj, "e_thumbdata"); + if (!eth) return; + eth->desk_pan.x = x; + eth->desk_pan.y = y; + eth->desk_pan.x_count = x_count; + eth->desk_pan.y_count = y_count; +} + +E_API void +e_thumb_signal_add(Evas_Object *obj, const char *sig, const char *src) +{ + E_Thumb *eth; + eth = evas_object_data_get(obj, "e_thumbdata"); + if (!eth) return; + eth->sigsrc = eina_list_append(eth->sigsrc, eina_stringshare_add(sig)); + eth->sigsrc = eina_list_append(eth->sigsrc, eina_stringshare_add(src)); +} + #define A(v) (((v) >> 24) & 0xff) #define R(v) (((v) >> 16) & 0xff) #define G(v) (((v) >> 8) & 0xff) @@ -274,7 +308,11 @@ e_thumb_client_data(Ecore_Ipc_Event_Client_Data *e) eth->busy = 1; _pending++; if (_pending == 1) _e_thumb_thumbnailers_kill_cancel(); - _e_thumb_gen_begin(eth->objid, eth->file, eth->key, eth->w, eth->h); + _e_thumb_gen_begin(eth->objid, eth->file, eth->key, + eth->w, eth->h, + eth->desk_pan.x, eth->desk_pan.y, + eth->desk_pan.x_count, eth->desk_pan.y_count, + eth->sigsrc); } } } @@ -289,25 +327,75 @@ e_thumb_client_del(Ecore_Ipc_Event_Client_Del *e) /* local subsystem functions */ static void -_e_thumb_gen_begin(int objid, const char *file, const char *key, int w, int h) +_e_thumb_gen_begin(int objid, const char *file, const char *key, int w, int h, + int desk_x, int desk_y, int desk_x_count, int desk_y_count, + Eina_List *sigsrc) { - char *buf; - int l1, l2; + char *buf, *p; + int l1, l2, size, *desk; Ecore_Ipc_Client *cli; + Eina_List *l; + const char *s; /* send thumb req */ + // figure out buffer size needed l1 = strlen(file); l2 = 0; if (key) l2 = strlen(key); - buf = alloca(l1 + 1 + l2 + 1); - strcpy(buf, file); - if (key) strcpy(buf + l1 + 1, key); - else buf[l1 + 1] = 0; + size = (4 * sizeof(int)); // desk_x/y/count + size += l1 + 1; // file + size += l2 + 1; // key + EINA_LIST_FOREACH(sigsrc, l, s) + { + size += strlen(s) + 1; + } + buf = alloca(size); + p = buf; + + // fill in buffer data + // data is: + // [int]desk_x + // [int]desk_y + // [int]desk_x_count + // [int]desk_y_count + // [char[]]file + // [char[]]key + // optional: + // [char[]]sig1 + // [char[]]src1 + // [char[]]sig2 + // [char[]]src2 + // ... + desk = (int *)buf; + desk[0] = desk_x; + desk[1] = desk_y; + desk[2] = desk_x_count; + desk[3] = desk_y_count; + p += (4 * sizeof(int)); + strcpy(p, file); + p += l1 + 1; + if (key) + { + strcpy(p, key); + p += l2 + 1; + } + else + { + p[0] = 0; + p += 1; + } + EINA_LIST_FOREACH(sigsrc, l, s) + { + strcpy(p, s); + p += strlen(s) + 1; + } + + // actually send it off cli = eina_list_data_get(_thumbnailers); if (!cli) return; _thumbnailers = eina_list_remove_list(_thumbnailers, _thumbnailers); _thumbnailers = eina_list_append(_thumbnailers, cli); - ecore_ipc_client_send(cli, E_IPC_DOMAIN_THUMB, 1, objid, w, h, buf, l1 + 1 + l2 + 1); + ecore_ipc_client_send(cli, E_IPC_DOMAIN_THUMB, 1, objid, w, h, buf, size); } static void @@ -327,6 +415,7 @@ static void _e_thumb_del_hook(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) { E_Thumb *eth; + const char *s; eth = evas_object_data_get(obj, "e_thumbdata"); if (!eth) return; @@ -344,6 +433,7 @@ _e_thumb_del_hook(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, if (eth->file) eina_stringshare_del(eth->file); if (eth->key) eina_stringshare_del(eth->key); free(eth->sort_id); + EINA_LIST_FREE(eth->sigsrc, s) eina_stringshare_del(s); free(eth); } diff --git a/src/bin/e_thumb.h b/src/bin/e_thumb.h index 48c22bfd4..3578f0d76 100644 --- a/src/bin/e_thumb.h +++ b/src/bin/e_thumb.h @@ -14,6 +14,8 @@ E_API void e_thumb_icon_size_set(Evas_Object *obj, int w, int h E_API void e_thumb_icon_begin(Evas_Object *obj); E_API void e_thumb_icon_end(Evas_Object *obj); E_API void e_thumb_icon_rethumb(Evas_Object *obj); +E_API void e_thumb_desk_pan_set(Evas_Object *obj, int x, int y, int x_count, int y_count); +E_API void e_thumb_signal_add(Evas_Object *obj, const char *sig, const char *src); E_API const char *e_thumb_sort_id_get(Evas_Object *obj); E_API void e_thumb_client_data(Ecore_Ipc_Event_Client_Data *e); diff --git a/src/bin/e_thumb_main.c b/src/bin/e_thumb_main.c index c3a6752b7..6632c0ecb 100644 --- a/src/bin/e_thumb_main.c +++ b/src/bin/e_thumb_main.c @@ -35,10 +35,12 @@ typedef struct _E_Thumb E_Thumb; struct _E_Thumb { - int objid; - int w, h; - char *file; - char *key; + int objid; + int w, h; + int desk_x, desk_y, desk_x_count, desk_y_count; + Eina_List *sigsrc; + char *file; + char *key; }; /* local subsystem functions */ @@ -55,7 +57,12 @@ static Eina_Bool _e_ipc_cb_server_data(void *data, static Eina_Bool _e_cb_timer(void *data); static void _e_thumb_generate(E_Thumb *eth); static char *_e_thumb_file_id(char *file, - char *key); + char *key, + int desk_x, + int desk_y, + int desk_x_count, + int desk_y_count, + Eina_List *sigsrc); /* local subsystem globals */ static Ecore_Ipc_Server *_e_ipc_server = NULL; @@ -184,8 +191,8 @@ _e_ipc_cb_server_data(void *data EINA_UNUSED, Ecore_Ipc_Event_Server_Data *e; E_Thumb *eth; Eina_List *l; - char *file = NULL; - char *key = NULL; + const char *file = NULL; + const char *key = NULL; e = event; if (e->major != 5 /*E_IPC_DOMAIN_THUMB*/) return ECORE_CALLBACK_PASS_ON; @@ -194,14 +201,28 @@ _e_ipc_cb_server_data(void *data EINA_UNUSED, case 1: if (e->data) { + const char *s, *start; + const int *desk; + Eina_List *sigsrc = NULL; + /* begin thumb */ /* don't check stuff. since this connects TO E it is connecting */ /* TO a trusted process that WILL send this message properly */ /* formatted. if the thumbnailer dies anyway - it's not a big loss */ /* but it is a sign of a bug in e formatting messages maybe */ - file = e->data; - key = file + strlen(file) + 1; + s = start = e->data; + desk = (const int *)(s); + s += (4 * sizeof(int)); + file = s; + s += strlen(s) + 1; + key = s; + s += strlen(s) + 1; if (!key[0]) key = NULL; + while ((s - start) < e->size) + { + sigsrc = eina_list_append(sigsrc, eina_stringshare_add(s)); + s += strlen(s) + 1; + } eth = calloc(1, sizeof(E_Thumb)); if (eth) { @@ -209,6 +230,11 @@ _e_ipc_cb_server_data(void *data EINA_UNUSED, eth->w = e->ref_to; eth->h = e->response; eth->file = strdup(file); + eth->desk_x = desk[0]; + eth->desk_y = desk[1]; + eth->desk_x_count = desk[2]; + eth->desk_y_count = desk[3]; + eth->sigsrc = sigsrc; if (key) eth->key = strdup(key); _thumblist = eina_list_append(_thumblist, eth); if (!_timer) _timer = ecore_timer_add(0.001, _e_cb_timer, NULL); @@ -253,9 +279,12 @@ _e_cb_timer(void *data EINA_UNUSED) /* take thumb at head of list */ if (_thumblist) { + const char *s; + eth = eina_list_data_get(_thumblist); _thumblist = eina_list_remove_list(_thumblist, _thumblist); _e_thumb_generate(eth); + EINA_LIST_FREE(eth->sigsrc, s) eina_stringshare_del(s); free(eth->file); free(eth->key); free(eth); @@ -290,7 +319,7 @@ _e_thumb_generate(E_Thumb *eth) const unsigned int *data = NULL; time_t mtime_orig, mtime_thumb; - id = _e_thumb_file_id(eth->file, eth->key); + id = _e_thumb_file_id(eth->file, eth->key, eth->desk_x, eth->desk_y, eth->desk_x_count, eth->desk_y_count, eth->sigsrc); if (!id) return; td = strdup(id); @@ -338,6 +367,8 @@ _e_thumb_generate(E_Thumb *eth) ((!strcasecmp(ext, ".edj")) || (!strcasecmp(ext, ".eap")))) { + Eina_List *l; + ww = eth->w; hh = eth->h; im = ecore_evas_object_image_new(ee); @@ -358,6 +389,37 @@ _e_thumb_generate(E_Thumb *eth) evas_object_resize(edje, ww * 4, hh * 4); evas_object_show(edje); } + if ((eth->desk_x_count > 0) && + (eth->desk_y_count > 0)) + { + Edje_Message_Float_Set *msg; + + msg = alloca(sizeof(Edje_Message_Float_Set) + + (4 * sizeof(double))); + msg->count = 5; + msg->val[0] = 0.0; + msg->val[1] = eth->desk_x; + msg->val[2] = eth->desk_x_count; + msg->val[3] = eth->desk_y; + msg->val[4] = eth->desk_y_count; + edje_object_message_send(edje, EDJE_MESSAGE_FLOAT_SET, + 0, msg); + } + l = eth->sigsrc; + while (l) + { + const char *sig, *src; + + sig = l->data; + l = l->next; + if (l) + { + src = l->data; + l = l->next; + edje_object_signal_emit(edje, sig, src); + } + } + edje_object_message_signal_process(edje); evas_object_move(im, 0, 0); evas_object_resize(im, ww, hh); sortkey = EINA_TRUE; @@ -605,28 +667,32 @@ end: static char * _e_thumb_file_id(char *file, - char *key) + char *key, + int desk_x, + int desk_y, + int desk_x_count, + int desk_y_count, + Eina_List *sigsrc) { char s[64]; - const char *chmap = "0123456789abcdef"; - unsigned char *buf, id[20]; - int i, len, lenf; + const char *chmap = "0123456789abcdef", *str; + unsigned char id[20], *st; + Eina_Strbuf *sbuf; + int i; + Eina_List *l; - len = 0; - lenf = strlen(file); - len += lenf; - len++; - if (key) + sbuf = eina_strbuf_new(); + EINA_LIST_FOREACH(sigsrc, l, str) { - key += strlen(key); - len++; + eina_strbuf_append_printf(sbuf, "<<%s>>", str); } - buf = alloca(len); + eina_strbuf_append_printf(sbuf, "|%i.%i.%i.%i|", + desk_x, desk_y, desk_x_count, desk_y_count); + eina_strbuf_append_printf(sbuf, "///%s", file); + if (key) eina_strbuf_append_printf(sbuf, "/%s", key); - strcpy((char *)buf, file); - if (key) strcpy((char *)(buf + lenf + 1), key); - - e_sha1_sum(buf, len, id); + st = (unsigned char *)eina_strbuf_string_get(sbuf); + e_sha1_sum(st, eina_strbuf_length_get(sbuf), id); for (i = 0; i < 20; i++) { @@ -634,6 +700,8 @@ _e_thumb_file_id(char *file, s[(i * 2) + 1] = chmap[(id[i]) & 0xf]; } s[(i * 2)] = 0; + eina_strbuf_free(sbuf); + return strdup(s); } diff --git a/src/bin/e_widget_bgpreview.c b/src/bin/e_widget_bgpreview.c index 89be7427a..6dd32af58 100644 --- a/src/bin/e_widget_bgpreview.c +++ b/src/bin/e_widget_bgpreview.c @@ -27,23 +27,6 @@ static void _e_wid_desk_cb_config(void *data, Evas *evas, Evas_Object *obj, static void _e_wid_cb_resize(void *data, Evas *evas, Evas_Object *obj, void *event); static Eina_Bool _e_wid_cb_bg_update(void *data, int type, void *event); -/* -static void -_bgpreview_viewport_update(Evas_Object *o, const E_Zone *zone, int x, int y) -{ - Edje_Message_Float_Set *msg; - - msg = alloca(sizeof(Edje_Message_Float_Set) + (4 * sizeof(double))); - msg->count = 5; - msg->val[0] = 0.2 * (!!e_config->desk_flip_animate_mode);//e_config->desk_flip_animate_time; - msg->val[1] = x; - msg->val[2] = zone->desk_x_count; - msg->val[3] = y; - msg->val[4] = zone->desk_y_count; - edje_object_message_send(o, EDJE_MESSAGE_FLOAT_SET, 0, msg); -} -*/ - E_API Evas_Object * e_widget_bgpreview_add(Evas *evas, int nx, int ny) { @@ -105,9 +88,9 @@ e_widget_bgpreview_desk_add(Evas *e, E_Zone *zone, int x, int y) dd->live = o = e_thumb_icon_add(e); e_thumb_icon_size_set(o, zone->w / 8, zone->h / 8); e_thumb_icon_file_set(o, bgfile, "e/desktop/background"); + e_thumb_desk_pan_set(o, x, y, zone->desk_x_count, zone->desk_y_count); e_icon_fill_inside_set(o, EINA_FALSE); e_thumb_icon_begin(o); -// _bgpreview_viewport_update(o, zone, x, y); dd->thumb = EINA_TRUE; } else if ((eina_str_has_extension(bgfile, ".gif")) || @@ -379,9 +362,9 @@ _e_wid_cb_bg_update(void *data, int type, void *event) dd->live = o = e_thumb_icon_add(e); e_thumb_icon_size_set(o, zone->w / 8, zone->h / 8); e_thumb_icon_file_set(o, bgfile, "e/desktop/background"); + e_thumb_desk_pan_set(o, dd->x, dd->y, zone->desk_x_count, zone->desk_y_count); e_icon_fill_inside_set(o, EINA_FALSE); e_thumb_icon_begin(o); -// _bgpreview_viewport_update(o, zone, dd->x, dd->y); dd->thumb = EINA_TRUE; _e_wid_livethumb_resize_job(dd); }