From 042f284bc2ca467e9a105de24bf384b6aaed9558 Mon Sep 17 00:00:00 2001
From: Cedric Roux <cedric.roux@eurecom.fr>
Date: Mon, 2 May 2016 14:33:07 +0200
Subject: [PATCH] introduce widget_dirty - not only text list might want the
 optimization

---
 common/utils/T/tracer/gui/gui.h       | 2 +-
 common/utils/T/tracer/gui/text_list.c | 9 ---------
 common/utils/T/tracer/gui/widget.c    | 9 +++++++++
 common/utils/T/tracer/view/textlist.c | 2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/common/utils/T/tracer/gui/gui.h b/common/utils/T/tracer/gui/gui.h
index ed763fa84c..142e34a0a8 100644
--- a/common/utils/T/tracer/gui/gui.h
+++ b/common/utils/T/tracer/gui/gui.h
@@ -16,6 +16,7 @@ gui *gui_init(void);
 
 /* position = -1 to put at the end */
 void widget_add_child(gui *gui, widget *parent, widget *child, int position);
+void widget_dirty(gui *gui, widget *this);
 
 widget *new_toplevel_window(gui *gui, int width, int height, char *title);
 widget *new_container(gui *gui, int vertical);
@@ -44,7 +45,6 @@ void text_list_set_start_line(gui *gui, widget *this, int line);
 void text_list_get_line(gui *gui, widget *this, int line,
     char **text, int *color);
 void text_list_set_color(gui *gui, widget *this, int line, int color);
-void text_list_dirty(gui *_gui, widget *_this);
 
 void gui_loop(gui *gui);
 
diff --git a/common/utils/T/tracer/gui/text_list.c b/common/utils/T/tracer/gui/text_list.c
index 416ae10d25..c37aa774d3 100644
--- a/common/utils/T/tracer/gui/text_list.c
+++ b/common/utils/T/tracer/gui/text_list.c
@@ -242,12 +242,3 @@ void text_list_set_color(gui *_gui, widget *_this, int line, int color)
 
   gunlock(g);
 }
-
-void text_list_dirty(gui *_gui, widget *_this)
-{
-  struct gui *g = _gui;
-  struct text_list_widget *this = _this;
-  glock(g);
-  send_event(g, DIRTY, this->common.id);
-  gunlock(g);
-}
diff --git a/common/utils/T/tracer/gui/widget.c b/common/utils/T/tracer/gui/widget.c
index 6a34d00d06..8411a4602f 100644
--- a/common/utils/T/tracer/gui/widget.c
+++ b/common/utils/T/tracer/gui/widget.c
@@ -180,6 +180,15 @@ void widget_add_child(gui *_gui, widget *parent, widget *child, int position)
   gunlock(_gui);
 }
 
+void widget_dirty(gui *_gui, widget *_this)
+{
+  struct gui *g = _gui;
+  struct widget *this = _this;
+  glock(g);
+  send_event(g, DIRTY, this->id);
+  gunlock(g);
+}
+
 static const char *names[] = {
   "TOPLEVEL_WINDOW", "CONTAINER", "TEXT_LIST", "XY_PLOT", "BUTTON", "LABEL"
 };
diff --git a/common/utils/T/tracer/view/textlist.c b/common/utils/T/tracer/view/textlist.c
index 7572f79e54..de453a67cf 100644
--- a/common/utils/T/tracer/view/textlist.c
+++ b/common/utils/T/tracer/view/textlist.c
@@ -42,7 +42,7 @@ static void *textlist_thread(void *_this)
       free(s);
     }
     if (pthread_mutex_unlock(&this->lock)) abort();
-    if (dirty) text_list_dirty(this->g, this->w);
+    if (dirty) widget_dirty(this->g, this->w);
     sleepms(1000/this->refresh_rate);
   }
 
-- 
GitLab