summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-02-05 13:48:08 +0000
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-02-05 13:48:08 +0000
commit11a55d0dea41714e5e922e52170e7a97e23b747c (patch)
tree7f8609b67f7fb5b9d01119814cb39e0904e016e2
parentb493e5dfdd9d791c89323d3a7f0381860e46c0f3 (diff)
browser - limit number of browser file objects creates or destroyed
this limits how many per second we create or destroy spreading the cost over time to keep smoothness at the cost of perhaps some delay until you see updated content as you scroll.
-rw-r--r--src/bin/browser.c57
1 files changed, 52 insertions, 5 deletions
diff --git a/src/bin/browser.c b/src/bin/browser.c
index 65e1ec4..905be88 100644
--- a/src/bin/browser.c
+++ b/src/bin/browser.c
@@ -60,7 +60,13 @@ static Eina_List *entries = NULL;
60static Ecore_Timer *_browser_hide_focus_restore_timer = NULL; 60static Ecore_Timer *_browser_hide_focus_restore_timer = NULL;
61static Eina_Semaphore step_sema; 61static Eina_Semaphore step_sema;
62static Ecore_Timer *initial_update_timer = NULL; 62static Ecore_Timer *initial_update_timer = NULL;
63static Ecore_Timer *pop_eval_redo = NULL;
63 64
65static const int max_created = 8;
66static const int max_destroyed = 16;
67
68static void _pop_eval_delay(Evas_Object *win, int created, int destroyed);
69static void _entry_files_pop_eval(Evas_Object *win, Entry *entry);
64static void _sel_go(Evas_Object *win EINA_UNUSED, Entry *base_entry, int x, int y); 70static void _sel_go(Evas_Object *win EINA_UNUSED, Entry *base_entry, int x, int y);
65 71
66static void 72static void
@@ -298,21 +304,57 @@ _cb_file_selected(void *data, Evas_Object *obj, const char *sig EINA_UNUSED, con
298static void 304static void
299_entry_files_pop_clear(Entry *entry) 305_entry_files_pop_clear(Entry *entry)
300{ 306{
301 int i, k; 307 Evas_Object *win = evas_object_data_get(entry->table, "win");
308 int i, k, destroyed = 0;
302 309
303 // if we had any content at all before - nuke it all 310 // if we had any content at all before - nuke it all
304 if ((entry->sels) && (entry->file_obj)) 311 if ((entry->sels) && (entry->file_obj))
305 { 312 {
306 entry->sels = eina_list_free(entry->sels);
307 k = entry->cols * entry->rows; 313 k = entry->cols * entry->rows;
308 for (i = 0; i < k; i++) 314 for (i = 0; i < k; i++)
309 { 315 {
310 if (entry->file_obj[i]) 316 if (entry->file_obj[i])
311 { 317 {
318 entry->sels = eina_list_remove(entry->sels, entry->file_obj[i]);
312 evas_object_del(entry->file_obj[i]); 319 evas_object_del(entry->file_obj[i]);
313 entry->file_obj[i] = NULL; 320 entry->file_obj[i] = NULL;
321 destroyed++;
322 if (destroyed >= max_destroyed) break;
314 } 323 }
315 } 324 }
325 _pop_eval_delay(win, 0, destroyed);
326 }
327}
328
329static Eina_Bool
330_cb_pop_eval_redo(void *data)
331{
332 Evas_Object *win = data;
333 Inf *inf = evas_object_data_get(win, "inf");
334 Eina_List *l;
335 Entry *entry;
336 pop_eval_redo = NULL;
337 if (!inf) return EINA_FALSE;
338 if (!bx) return EINA_FALSE;
339 EINA_LIST_FOREACH(entries, l, entry)
340 {
341 if (pop_eval_redo) break;
342 _entry_files_pop_eval(win, entry);
343 }
344 return EINA_FALSE;
345}
346
347static void
348_pop_eval_delay(Evas_Object *win, int created, int destroyed)
349{
350 if ((created >= max_created) || (destroyed >= max_destroyed))
351 {
352 if (pop_eval_redo)
353 {
354 ecore_timer_del(pop_eval_redo);
355 pop_eval_redo = NULL;
356 }
357 pop_eval_redo = ecore_timer_add(0.01, _cb_pop_eval_redo, win);
316 } 358 }
317} 359}
318 360
@@ -323,9 +365,10 @@ _entry_files_pop_eval(Evas_Object *win, Entry *entry)
323 Eina_List *l; 365 Eina_List *l;
324 Evas_Object **obj; 366 Evas_Object **obj;
325 Evas_Coord win_w, win_h, ent_x, ent_y, ent_w, ent_h; 367 Evas_Coord win_w, win_h, ent_x, ent_y, ent_w, ent_h;
326 int i = 0, j = 0; 368 int i = 0, j = 0, created = 0, destroyed = 0;
327 Eina_Rectangle win_rect, file_rect; 369 Eina_Rectangle win_rect, file_rect;
328 370
371 if (pop_eval_redo) return;
329 evas_object_geometry_get(entry->table, &ent_x, &ent_y, &ent_w, &ent_h); 372 evas_object_geometry_get(entry->table, &ent_x, &ent_y, &ent_w, &ent_h);
330 evas_object_geometry_get(win, NULL, NULL, &win_w, &win_h); 373 evas_object_geometry_get(win, NULL, NULL, &win_w, &win_h);
331 win_rect.x = 0; 374 win_rect.x = 0;
@@ -350,6 +393,7 @@ _entry_files_pop_eval(Evas_Object *win, Entry *entry)
350 // walk files to find which intersect the window 393 // walk files to find which intersect the window
351 EINA_LIST_FOREACH(entry->files, l, file) 394 EINA_LIST_FOREACH(entry->files, l, file)
352 { 395 {
396 if ((created >= max_created) && (destroyed >= max_destroyed)) break;
353 file_rect.x = ent_x + ((i * ent_w) / entry->cols); 397 file_rect.x = ent_x + ((i * ent_w) / entry->cols);
354 file_rect.y = ent_y + ((j * ent_h) / entry->rows); 398 file_rect.y = ent_y + ((j * ent_h) / entry->rows);
355 file_rect.w = (ent_w / entry->cols); 399 file_rect.w = (ent_w / entry->cols);
@@ -361,7 +405,7 @@ _entry_files_pop_eval(Evas_Object *win, Entry *entry)
361 obj = &(entry->file_obj[(j * entry->cols) + i]); 405 obj = &(entry->file_obj[(j * entry->cols) + i]);
362 if (eina_rectangles_intersect(&win_rect, &file_rect)) 406 if (eina_rectangles_intersect(&win_rect, &file_rect))
363 { 407 {
364 if (!(*obj)) 408 if ((!(*obj)) && (created < max_created))
365 { 409 {
366 Evas_Object *o, *base; 410 Evas_Object *o, *base;
367 char buf[PATH_MAX], *p; 411 char buf[PATH_MAX], *p;
@@ -430,15 +474,17 @@ _entry_files_pop_eval(Evas_Object *win, Entry *entry)
430 "rage"); 474 "rage");
431 evas_object_raise(base); 475 evas_object_raise(base);
432 } 476 }
477 created++;
433 } 478 }
434 } 479 }
435 else 480 else
436 { 481 {
437 if (*obj) 482 if ((*obj) && (destroyed < max_destroyed))
438 { 483 {
439 entry->sels = eina_list_remove(entry->sels, *obj); 484 entry->sels = eina_list_remove(entry->sels, *obj);
440 evas_object_del(*obj); 485 evas_object_del(*obj);
441 *obj = NULL; 486 *obj = NULL;
487 destroyed++;
442 } 488 }
443 } 489 }
444 i++; 490 i++;
@@ -448,6 +494,7 @@ _entry_files_pop_eval(Evas_Object *win, Entry *entry)
448 j++; 494 j++;
449 } 495 }
450 } 496 }
497 _pop_eval_delay(win, created, destroyed);
451} 498}
452 499
453static void 500static void