bu5hm4n pushed a commit to branch master.

http://git.enlightenment.org/tools/clouseau.git/commit/?id=9083738d1087486cb98e24ddf76dcd6c2a520e68

commit 9083738d1087486cb98e24ddf76dcd6c2a520e68
Author: Marcel Hollerbach <marcel-hollerb...@t-online.de>
Date:   Sun Nov 13 19:59:40 2016 +0100

    clouseau: lets bring back highlight in offline mode
    
    if the screenshot of a offline app is open it will be highlighted again.
    The problem was that the highlight in the offline mode still worked with
    legacy data which was not generated. Now this informations are just
    searched from the Efl_Dbg_Info structs.
    
    To test this you can just take a screenshot of a app, save the app with
    the button in the upper right. Then start clouseau again in offline
    mode, after that you can select a file. Select the file where you have
    saved your app before. If you now display the screenshot and click on a
    element, this object is displayed.
---
 src/bin/clouseau_client.c  | 90 +++++++++++++++++++++++++++----------------
 src/lib/clouseau_app.c     | 95 ++++++++++++----------------------------------
 src/lib/clouseau_data.c    | 22 +++++++++++
 src/lib/clouseau_private.h |  4 +-
 4 files changed, 107 insertions(+), 104 deletions(-)

diff --git a/src/bin/clouseau_client.c b/src/bin/clouseau_client.c
index 8ea7990..8eb5f10 100644
--- a/src/bin/clouseau_client.c
+++ b/src/bin/clouseau_client.c
@@ -1313,6 +1313,63 @@ _connect_to_daemon(Gui_Elements *g)
 }
 
 static void
+_send_highlight(App_Data_St *app, Clouseau_Tree_Item *tree)
+{
+   if (!do_highlight)
+     return;
+
+   if (!eet_svr)
+     {
+        //do offline highlight
+        Efl_Dbg_Info *evas_object, *pos, *size, *x, *y, *w, *h;
+        Eina_Rectangle r;
+        Evas_Object *rectangle;
+        bmp_info_st *bmp;
+        Evas *e;
+
+        evas_object = clouseau_eo_info_find(tree->new_eo_info , "Evas_Object");
+        size = clouseau_eo_info_find(evas_object, "Size");
+        pos = clouseau_eo_info_find(evas_object, "Position");
+
+#define FIND_AND_GET(c, name) \
+        name = clouseau_eo_info_find(c, ""#name""); \
+        eina_value_get(&name->value, &r.name);
+
+        FIND_AND_GET(pos, x)
+        FIND_AND_GET(pos, y)
+        FIND_AND_GET(size, w)
+        FIND_AND_GET(size, h)
+
+#undef FIND_AND_GET
+
+        bmp = eina_list_search_unsorted(app->app->view,
+                                        _bmp_app_ptr_cmp,
+                                        (void*) (uintptr_t) app->td->app);
+
+        if (!bmp)
+          {
+             printf("Error, failed to find window of open screenshot!\n");
+             return;
+          }
+
+        //win is null as long as the screenshot is not displayed
+        if (!bmp->win) return;
+        e = efl_parent_get(bmp->win);
+        rectangle = evas_object_rectangle_add(e);
+        evas_object_geometry_set(rectangle, r.x, r.y, r.w, r.h);
+        clouseau_data_object_highlight(rectangle);
+     }
+   else
+     {
+        //sent highlight to the listening client
+        highlight_st st = { (unsigned long long) (uintptr_t) app->app->ptr,
+                            tree->ptr };
+
+        ecore_con_eet_send(eet_svr, CLOUSEAU_HIGHLIGHT_STR, &st);
+     }
+}
+
+static void
 _gl_selected(void *data, Evas_Object *pobj EINA_UNUSED, void *event_info)
 {
    Gui_Elements *g = data;
@@ -1367,38 +1424,7 @@ _gl_selected(void *data, Evas_Object *pobj EINA_UNUSED, 
void *event_info)
           }
      }
 
-   if (!do_highlight)
-     return;
-
-   /* START - replacing libclouseau_highlight(obj); */
-   app_info_st *app = g->sel_app->app;
-   highlight_st st = { (unsigned long long) (uintptr_t) app->ptr,
-                       treeit->ptr };
-
-   if (eet_svr)
-     {
-        ecore_con_eet_send(eet_svr, CLOUSEAU_HIGHLIGHT_STR, &st);
-     }
-
-   /* We also like to HIGHLIGHT on any app views that open (for offline) */
-   do
-     {
-        parent = prt;
-        prt = elm_genlist_item_parent_get(prt);
-     }
-   while (prt);
-
-   Clouseau_Tree_Item *t = elm_object_item_data_get(parent);
-   bmp_info_st *bmp = eina_list_search_unsorted(app->view,
-                                             _bmp_object_ptr_cmp,
-                                             (void*) (uintptr_t) t->ptr);
-
-   if (bmp && bmp->win)
-     {  /* Third param gives evas surface when running offline */
-        clouseau_data_object_highlight((void*) (uintptr_t) treeit->ptr,
-                                  &treeit->info->evas_props, bmp);
-     }
-   /* END   - replacing clouseau_object_highlight(obj); */
+   _send_highlight(g->sel_app , treeit);
 }
 
 static void
diff --git a/src/lib/clouseau_app.c b/src/lib/clouseau_app.c
index c4e96fa..222d4a6 100644
--- a/src/lib/clouseau_app.c
+++ b/src/lib/clouseau_app.c
@@ -245,89 +245,38 @@ _clouseau_highlight_del(void *data,
    ecore_animator_del(data);
 }
 
+
 EAPI void
-clouseau_data_object_highlight(Evas_Object *obj, Clouseau_Evas_Props *props, 
bmp_info_st *view)
+clouseau_data_object_highlight(Evas_Object *obj)
 {
+   const Evas_Map *map;
    Ecore_Animator *t;
+   Evas *e = NULL;
    Evas_Object *r;
    int x, y, wd, ht;
-   Evas *e = NULL;
-
-   if (props)
-     {
-        e = evas_object_evas_get(view->win);
-     }
-   else
-     {
-        /* Check validity of object when working online */
-        if (!_clouseau_verify_e_obj(obj))
-          {
-             printf("<%s> Evas Object not found <%p> (probably deleted)\n",
-                   __func__, obj);
-             return;
-          }
-
-        /* Take evas from object if working online */
-        e = evas_object_evas_get(obj);
-        if (!e) return;
-     }
 
-   /* Continue and do the Highlight */
+   e = evas_object_evas_get(obj);
    r = evas_object_polygon_add(e);
-   evas_object_move(r, 0, 0);
 
-   if (props)
+   if ((map = evas_object_map_get(obj)))
      {
-        /* When working offline grab info from struct */
-        Evas_Coord x_bmp, y_bmp;
-
-        /* If there's a map, highlight the map coords, not the object's */
-        if (props->points_count > 0)
-          {
-             int i = props->points_count;
-             for ( ; i > 0 ; i--)
-               {
-                  evas_object_polygon_point_add(r,
-                        props->points[i].x, props->points[i].y);
-               }
-          }
-        else
+        int i = evas_map_count_get(map);
+        for ( ; i > 0 ; i--)
           {
-             evas_object_geometry_get(view->o, &x_bmp, &y_bmp, NULL, NULL);
-             x =  (view->zoom_val * props->x) + x_bmp;
-             y =  (view->zoom_val * props->y) + y_bmp;
-             wd = (view->zoom_val * props->w);
-             ht = (view->zoom_val * props->h);
-             evas_object_polygon_point_add(r, x, y);
-             evas_object_polygon_point_add(r, x + wd, y);
-             evas_object_polygon_point_add(r, x + wd, y + ht);
-             evas_object_polygon_point_add(r, x, y + ht);
+             Evas_Coord mx, my;
+             evas_map_point_coord_get(map, i - 1, &mx, &my, NULL);
+             evas_object_polygon_point_add(r, mx, my);
           }
      }
    else
      {
-        const Evas_Map *map;
-        if ((map = evas_object_map_get(obj)))
-          {
-             int i = evas_map_count_get(map);
-             for ( ; i > 0 ; i--)
-               {
-                  Evas_Coord mx, my;
-                  evas_map_point_coord_get(map, i - 1, &mx, &my, NULL);
-                  evas_object_polygon_point_add(r, mx, my);
-               }
-          }
-        else
-          {
-             evas_object_geometry_get(obj, &x, &y, &wd, &ht);
-             evas_object_polygon_point_add(r, x, y);
-             evas_object_polygon_point_add(r, x + wd, y);
-             evas_object_polygon_point_add(r, x + wd, y + ht);
-             evas_object_polygon_point_add(r, x, y + ht);
-          }
+        evas_object_geometry_get(obj, &x, &y, &wd, &ht);
+        evas_object_polygon_point_add(r, x, y);
+        evas_object_polygon_point_add(r, x + wd, y);
+        evas_object_polygon_point_add(r, x + wd, y + ht);
+        evas_object_polygon_point_add(r, x, y + ht);
      }
 
-   /* Put the object as high as possible. */
    evas_object_layer_set(r, EVAS_LAYER_MAX);
    evas_object_color_set(r,
                          HIGHLIGHT_R, HIGHLIGHT_G, HIGHLIGHT_B, HIGHLIGHT_A);
@@ -337,9 +286,6 @@ clouseau_data_object_highlight(Evas_Object *obj, 
Clouseau_Evas_Props *props, bmp
    t = ecore_animator_add(_clouseau_highlight_fade, r);
    evas_object_event_callback_add(r, EVAS_CALLBACK_DEL,
                                   _clouseau_highlight_del, t);
-/* Print backtrace info, saved for future ref
-   tmp = evas_object_data_get(obj, ".clouseau.bt");
-   fprintf(stderr, "Creation backtrace :\n%s*******\n", tmp); */
 }
 
 static Clouseau_Object *
@@ -423,7 +369,14 @@ _highlight_cb(EINA_UNUSED void *data, EINA_UNUSED 
Ecore_Con_Reply *reply,
 {  /* Highlight msg contains PTR of object to highlight */
    highlight_st *ht = value;
    Evas_Object *obj = (Evas_Object *) (uintptr_t) ht->object;
-   clouseau_data_object_highlight(obj, NULL, NULL);
+
+   if (!_clouseau_verify_e_obj(obj))
+     {
+        printf("Evas Object not found <%p> (probably deleted)\n", obj);
+        return;
+     }
+
+   clouseau_data_object_highlight(obj);
 }
 
 void
diff --git a/src/lib/clouseau_data.c b/src/lib/clouseau_data.c
index 0465e52..3dd1ba4 100644
--- a/src/lib/clouseau_data.c
+++ b/src/lib/clouseau_data.c
@@ -39,6 +39,28 @@ clouseau_eo_info_free(Clouseau_Efl_Dbg_Info *parent)
    free(parent);
 }
 
+
+EAPI Efl_Dbg_Info*
+clouseau_eo_info_find(Efl_Dbg_Info *root, const char *name)
+{
+   Eina_Value_List eo_list;
+   Eina_List *n;
+   Efl_Dbg_Info *info;
+
+   if (!root) return NULL;
+
+   eina_value_pget(&(root->value), &eo_list);
+
+   EINA_LIST_FOREACH(eo_list.list, n, info)
+     {
+        if (!strcmp(info->name, name))
+          {
+             return info;
+          }
+     }
+   return NULL;
+}
+
 static void
 _clouseau_tree_item_free(Clouseau_Tree_Item *parent)
 {
diff --git a/src/lib/clouseau_private.h b/src/lib/clouseau_private.h
index d641aa2..4e6f441 100644
--- a/src/lib/clouseau_private.h
+++ b/src/lib/clouseau_private.h
@@ -218,6 +218,8 @@ struct _Clouseau_Efl_Dbg_Info
 
 void clouseau_app_disconnect(void);
 
+
+EAPI Efl_Dbg_Info* clouseau_eo_info_find(Efl_Dbg_Info *root, const char *name);
 EAPI void clouseau_eo_info_free(Clouseau_Efl_Dbg_Info *parent);
 EAPI void clouseau_tree_item_from_legacy_convert(Clouseau_Tree_Item *treeit);
 EAPI Eina_List *clouseau_eo_to_legacy_convert(Efl_Dbg_Info *root);
@@ -230,7 +232,7 @@ EAPI Clouseau_Object * 
clouseau_object_information_get(Clouseau_Tree_Item *treei
 EAPI void clouseau_data_tree_free(Eina_List *tree);
 EAPI void *clouseau_data_packet_compose(const char *p_type, void *data, 
unsigned int *size, void *blob, int blob_size);
 EAPI void *clouseau_data_packet_info_get(const char *p_type, void *data, 
size_t size);
-EAPI void clouseau_data_object_highlight(Evas_Object *obj, Clouseau_Evas_Props 
*props, bmp_info_st *view);
+EAPI void clouseau_data_object_highlight(Evas_Object *obj);
 EAPI Eina_Bool clouseau_data_eet_info_save(const char *filename, app_info_st 
*a, tree_data_st *ftd, Eina_List *ck_list);
 EAPI Eina_Bool clouseau_data_eet_info_read(const char *filename, app_info_st 
**a, tree_data_st **ftd);
 EAPI int clouseau_data_init(void);

-- 


Reply via email to