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
This commit is contained in:
Carsten Haitzler 2017-01-28 16:08:46 +09:00
parent 1caf626322
commit b55ce098bf
4 changed files with 200 additions and 57 deletions

View File

@ -9,13 +9,17 @@ struct _E_Thumb
const char *file; const char *file;
const char *key; const char *key;
char *sort_id; char *sort_id;
struct {
int x, y, x_count, y_count;
} desk_pan;
Eina_List *sigsrc;
unsigned char queued : 1; unsigned char queued : 1;
unsigned char busy : 1; unsigned char busy : 1;
unsigned char done : 1; unsigned char done : 1;
}; };
/* local subsystem functions */ /* 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_gen_end(int objid);
static void _e_thumb_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info); 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); 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; eth2->busy = 1;
_pending++; _pending++;
if (_pending == 1) _e_thumb_thumbnailers_kill_cancel(); 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; eth->busy = 1;
_pending++; _pending++;
if (_pending == 1) _e_thumb_thumbnailers_kill_cancel(); 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 E_API void
@ -190,6 +202,28 @@ e_thumb_icon_rethumb(Evas_Object *obj)
e_thumb_icon_begin(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 A(v) (((v) >> 24) & 0xff)
#define R(v) (((v) >> 16) & 0xff) #define R(v) (((v) >> 16) & 0xff)
#define G(v) (((v) >> 8) & 0xff) #define G(v) (((v) >> 8) & 0xff)
@ -274,7 +308,11 @@ e_thumb_client_data(Ecore_Ipc_Event_Client_Data *e)
eth->busy = 1; eth->busy = 1;
_pending++; _pending++;
if (_pending == 1) _e_thumb_thumbnailers_kill_cancel(); 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 */ /* local subsystem functions */
static void 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; char *buf, *p;
int l1, l2; int l1, l2, size, *desk;
Ecore_Ipc_Client *cli; Ecore_Ipc_Client *cli;
Eina_List *l;
const char *s;
/* send thumb req */ /* send thumb req */
// figure out buffer size needed
l1 = strlen(file); l1 = strlen(file);
l2 = 0; l2 = 0;
if (key) l2 = strlen(key); if (key) l2 = strlen(key);
buf = alloca(l1 + 1 + l2 + 1); size = (4 * sizeof(int)); // desk_x/y/count
strcpy(buf, file); size += l1 + 1; // file
if (key) strcpy(buf + l1 + 1, key); size += l2 + 1; // key
else buf[l1 + 1] = 0; 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); cli = eina_list_data_get(_thumbnailers);
if (!cli) return; if (!cli) return;
_thumbnailers = eina_list_remove_list(_thumbnailers, _thumbnailers); _thumbnailers = eina_list_remove_list(_thumbnailers, _thumbnailers);
_thumbnailers = eina_list_append(_thumbnailers, cli); _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 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_del_hook(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{ {
E_Thumb *eth; E_Thumb *eth;
const char *s;
eth = evas_object_data_get(obj, "e_thumbdata"); eth = evas_object_data_get(obj, "e_thumbdata");
if (!eth) return; 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->file) eina_stringshare_del(eth->file);
if (eth->key) eina_stringshare_del(eth->key); if (eth->key) eina_stringshare_del(eth->key);
free(eth->sort_id); free(eth->sort_id);
EINA_LIST_FREE(eth->sigsrc, s) eina_stringshare_del(s);
free(eth); free(eth);
} }

View File

@ -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_begin(Evas_Object *obj);
E_API void e_thumb_icon_end(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_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 const char *e_thumb_sort_id_get(Evas_Object *obj);
E_API void e_thumb_client_data(Ecore_Ipc_Event_Client_Data *e); E_API void e_thumb_client_data(Ecore_Ipc_Event_Client_Data *e);

View File

@ -35,10 +35,12 @@ typedef struct _E_Thumb E_Thumb;
struct _E_Thumb struct _E_Thumb
{ {
int objid; int objid;
int w, h; int w, h;
char *file; int desk_x, desk_y, desk_x_count, desk_y_count;
char *key; Eina_List *sigsrc;
char *file;
char *key;
}; };
/* local subsystem functions */ /* 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 Eina_Bool _e_cb_timer(void *data);
static void _e_thumb_generate(E_Thumb *eth); static void _e_thumb_generate(E_Thumb *eth);
static char *_e_thumb_file_id(char *file, 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 */ /* local subsystem globals */
static Ecore_Ipc_Server *_e_ipc_server = NULL; 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; Ecore_Ipc_Event_Server_Data *e;
E_Thumb *eth; E_Thumb *eth;
Eina_List *l; Eina_List *l;
char *file = NULL; const char *file = NULL;
char *key = NULL; const char *key = NULL;
e = event; e = event;
if (e->major != 5 /*E_IPC_DOMAIN_THUMB*/) return ECORE_CALLBACK_PASS_ON; 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: case 1:
if (e->data) if (e->data)
{ {
const char *s, *start;
const int *desk;
Eina_List *sigsrc = NULL;
/* begin thumb */ /* begin thumb */
/* don't check stuff. since this connects TO E it is connecting */ /* don't check stuff. since this connects TO E it is connecting */
/* TO a trusted process that WILL send this message properly */ /* TO a trusted process that WILL send this message properly */
/* formatted. if the thumbnailer dies anyway - it's not a big loss */ /* 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 */ /* but it is a sign of a bug in e formatting messages maybe */
file = e->data; s = start = e->data;
key = file + strlen(file) + 1; 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; 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)); eth = calloc(1, sizeof(E_Thumb));
if (eth) if (eth)
{ {
@ -209,6 +230,11 @@ _e_ipc_cb_server_data(void *data EINA_UNUSED,
eth->w = e->ref_to; eth->w = e->ref_to;
eth->h = e->response; eth->h = e->response;
eth->file = strdup(file); 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); if (key) eth->key = strdup(key);
_thumblist = eina_list_append(_thumblist, eth); _thumblist = eina_list_append(_thumblist, eth);
if (!_timer) _timer = ecore_timer_add(0.001, _e_cb_timer, NULL); 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 */ /* take thumb at head of list */
if (_thumblist) if (_thumblist)
{ {
const char *s;
eth = eina_list_data_get(_thumblist); eth = eina_list_data_get(_thumblist);
_thumblist = eina_list_remove_list(_thumblist, _thumblist); _thumblist = eina_list_remove_list(_thumblist, _thumblist);
_e_thumb_generate(eth); _e_thumb_generate(eth);
EINA_LIST_FREE(eth->sigsrc, s) eina_stringshare_del(s);
free(eth->file); free(eth->file);
free(eth->key); free(eth->key);
free(eth); free(eth);
@ -290,7 +319,7 @@ _e_thumb_generate(E_Thumb *eth)
const unsigned int *data = NULL; const unsigned int *data = NULL;
time_t mtime_orig, mtime_thumb; 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; if (!id) return;
td = strdup(id); td = strdup(id);
@ -338,6 +367,8 @@ _e_thumb_generate(E_Thumb *eth)
((!strcasecmp(ext, ".edj")) || ((!strcasecmp(ext, ".edj")) ||
(!strcasecmp(ext, ".eap")))) (!strcasecmp(ext, ".eap"))))
{ {
Eina_List *l;
ww = eth->w; ww = eth->w;
hh = eth->h; hh = eth->h;
im = ecore_evas_object_image_new(ee); 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_resize(edje, ww * 4, hh * 4);
evas_object_show(edje); 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_move(im, 0, 0);
evas_object_resize(im, ww, hh); evas_object_resize(im, ww, hh);
sortkey = EINA_TRUE; sortkey = EINA_TRUE;
@ -605,28 +667,32 @@ end:
static char * static char *
_e_thumb_file_id(char *file, _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]; char s[64];
const char *chmap = "0123456789abcdef"; const char *chmap = "0123456789abcdef", *str;
unsigned char *buf, id[20]; unsigned char id[20], *st;
int i, len, lenf; Eina_Strbuf *sbuf;
int i;
Eina_List *l;
len = 0; sbuf = eina_strbuf_new();
lenf = strlen(file); EINA_LIST_FOREACH(sigsrc, l, str)
len += lenf;
len++;
if (key)
{ {
key += strlen(key); eina_strbuf_append_printf(sbuf, "<<%s>>", str);
len++;
} }
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); st = (unsigned char *)eina_strbuf_string_get(sbuf);
if (key) strcpy((char *)(buf + lenf + 1), key); e_sha1_sum(st, eina_strbuf_length_get(sbuf), id);
e_sha1_sum(buf, len, id);
for (i = 0; i < 20; i++) 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) + 1] = chmap[(id[i]) & 0xf];
} }
s[(i * 2)] = 0; s[(i * 2)] = 0;
eina_strbuf_free(sbuf);
return strdup(s); return strdup(s);
} }

View File

@ -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 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 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_API Evas_Object *
e_widget_bgpreview_add(Evas *evas, int nx, int ny) 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); dd->live = o = e_thumb_icon_add(e);
e_thumb_icon_size_set(o, zone->w / 8, zone->h / 8); e_thumb_icon_size_set(o, zone->w / 8, zone->h / 8);
e_thumb_icon_file_set(o, bgfile, "e/desktop/background"); 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_icon_fill_inside_set(o, EINA_FALSE);
e_thumb_icon_begin(o); e_thumb_icon_begin(o);
// _bgpreview_viewport_update(o, zone, x, y);
dd->thumb = EINA_TRUE; dd->thumb = EINA_TRUE;
} }
else if ((eina_str_has_extension(bgfile, ".gif")) || 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); dd->live = o = e_thumb_icon_add(e);
e_thumb_icon_size_set(o, zone->w / 8, zone->h / 8); e_thumb_icon_size_set(o, zone->w / 8, zone->h / 8);
e_thumb_icon_file_set(o, bgfile, "e/desktop/background"); 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_icon_fill_inside_set(o, EINA_FALSE);
e_thumb_icon_begin(o); e_thumb_icon_begin(o);
// _bgpreview_viewport_update(o, zone, dd->x, dd->y);
dd->thumb = EINA_TRUE; dd->thumb = EINA_TRUE;
_e_wid_livethumb_resize_job(dd); _e_wid_livethumb_resize_job(dd);
} }