diff options
| author | Steven Rostedt <rostedt@goodmis.org> | 2009-12-23 18:48:18 -0500 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2009-12-23 18:48:18 -0500 |
| commit | bd33669eec11ba0b7e6dc1ac1dc861b14cabdd17 (patch) | |
| tree | d29b105f0ed1bb934f65f9cfc0eb7322c81b4914 /trace-graph.c | |
| parent | d67b55244fa62504372710e7ec8fe276b24e1575 (diff) | |
kernelshark: Add double click on row to select in graph
This adds the ability to double click on a row and it selects the
graph location, moving the viewable area if necessary.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'trace-graph.c')
| -rw-r--r-- | trace-graph.c | 107 |
1 files changed, 89 insertions, 18 deletions
diff --git a/trace-graph.c b/trace-graph.c index 15dfbd7..d880f39 100644 --- a/trace-graph.c +++ b/trace-graph.c | |||
| @@ -42,6 +42,8 @@ static gint event_sched_switch_id = -1; | |||
| 42 | 42 | ||
| 43 | static gint largest_cpu_label = 0; | 43 | static gint largest_cpu_label = 0; |
| 44 | 44 | ||
| 45 | static void redraw_pixmap_backend(struct graph_info *ginfo); | ||
| 46 | |||
| 45 | static void convert_nano(unsigned long long time, unsigned long *sec, | 47 | static void convert_nano(unsigned long long time, unsigned long *sec, |
| 46 | unsigned long *usec) | 48 | unsigned long *usec) |
| 47 | { | 49 | { |
| @@ -517,11 +519,21 @@ static void update_graph(struct graph_info *ginfo, gdouble percent) | |||
| 517 | 519 | ||
| 518 | static void update_graph_to_start_x(struct graph_info *ginfo) | 520 | static void update_graph_to_start_x(struct graph_info *ginfo) |
| 519 | { | 521 | { |
| 522 | gint width = ginfo->draw_width;; | ||
| 523 | |||
| 524 | if (!width) { | ||
| 525 | ginfo->view_start_time = ginfo->start_time; | ||
| 526 | ginfo->view_end_time = ginfo->end_time; | ||
| 527 | return; | ||
| 528 | } | ||
| 529 | |||
| 520 | ginfo->view_start_time = ginfo->start_x / ginfo->resolution + | 530 | ginfo->view_start_time = ginfo->start_x / ginfo->resolution + |
| 521 | ginfo->start_time; | 531 | ginfo->start_time; |
| 522 | 532 | ||
| 523 | ginfo->view_end_time = ginfo->draw_width / ginfo->resolution + | 533 | ginfo->view_end_time = width / ginfo->resolution + |
| 524 | ginfo->view_start_time; | 534 | ginfo->view_start_time; |
| 535 | |||
| 536 | g_assert (ginfo->view_start_time < ginfo->end_time); | ||
| 525 | } | 537 | } |
| 526 | 538 | ||
| 527 | static void reset_graph(struct graph_info *ginfo, gdouble view_width) | 539 | static void reset_graph(struct graph_info *ginfo, gdouble view_width) |
| @@ -1084,33 +1096,84 @@ static void draw_info(struct graph_info *ginfo, | |||
| 1084 | draw_cpu_labels(ginfo); | 1096 | draw_cpu_labels(ginfo); |
| 1085 | } | 1097 | } |
| 1086 | 1098 | ||
| 1087 | static gboolean | 1099 | void trace_graph_select_by_time(struct graph_info *ginfo, guint64 time) |
| 1088 | configure_event(GtkWidget *widget, GdkEventMotion *event, gpointer data) | ||
| 1089 | { | 1100 | { |
| 1090 | struct graph_info *ginfo = data; | 1101 | gint view_width; |
| 1091 | GdkPixmap *old_pix; | 1102 | gint width; |
| 1103 | gint mid; | ||
| 1104 | gint start; | ||
| 1105 | gint end; | ||
| 1106 | guint64 old_start_time = ginfo->view_start_time; | ||
| 1092 | 1107 | ||
| 1093 | gtk_widget_set_size_request(widget, ginfo->draw_width, ginfo->draw_height); | 1108 | view_width = gtk_adjustment_get_page_size(ginfo->vadj); |
| 1109 | width = ginfo->draw_width ? : view_width; | ||
| 1110 | |||
| 1111 | mid = (time - ginfo->start_time) * ginfo->resolution; | ||
| 1112 | start = mid - width / 2; | ||
| 1113 | if (start < 0) | ||
| 1114 | start = 0; | ||
| 1115 | end = start + width; | ||
| 1116 | |||
| 1117 | /* | ||
| 1118 | * Readjust the drawing to be centered on the selection. | ||
| 1119 | */ | ||
| 1120 | |||
| 1121 | if (end > ginfo->full_width) { | ||
| 1122 | start -= end - ginfo->full_width; | ||
| 1123 | end = ginfo->full_width; | ||
| 1124 | g_assert(start >= 0); | ||
| 1125 | } | ||
| 1126 | |||
| 1127 | ginfo->start_x = start; | ||
| 1128 | |||
| 1129 | update_graph_to_start_x(ginfo); | ||
| 1130 | |||
| 1131 | /* force redraw if we changed the time*/ | ||
| 1132 | if (old_start_time != ginfo->view_start_time) | ||
| 1133 | redraw_pixmap_backend(ginfo); | ||
| 1134 | |||
| 1135 | /* Adjust start to be the location for the vadj */ | ||
| 1136 | mid = (time - ginfo->view_start_time) * ginfo->resolution; | ||
| 1137 | start = mid - view_width / 2; | ||
| 1138 | if (start < 0) | ||
| 1139 | start = 0; | ||
| 1140 | |||
| 1141 | if (start > (width - view_width)) | ||
| 1142 | start = width - view_width; | ||
| 1143 | gtk_adjustment_set_value(ginfo->vadj, start); | ||
| 1144 | |||
| 1145 | ginfo->last_x = (ginfo->cursor - ginfo->view_start_time) | ||
| 1146 | * ginfo->resolution; | ||
| 1147 | ginfo->cursor = 0; | ||
| 1148 | clear_last_line(ginfo->draw, ginfo); | ||
| 1149 | ginfo->cursor = time; | ||
| 1150 | |||
| 1151 | update_with_backend(ginfo, 0, 0, width, ginfo->draw_height); | ||
| 1152 | } | ||
| 1153 | |||
| 1154 | static void redraw_pixmap_backend(struct graph_info *ginfo) | ||
| 1155 | { | ||
| 1156 | GdkPixmap *old_pix; | ||
| 1094 | 1157 | ||
| 1095 | old_pix = ginfo->curr_pixmap; | 1158 | old_pix = ginfo->curr_pixmap; |
| 1096 | 1159 | ||
| 1097 | /* initialize full width if needed */ | 1160 | /* initialize full width if needed */ |
| 1098 | if (!ginfo->full_width) | 1161 | if (!ginfo->full_width) |
| 1099 | ginfo->full_width = widget->allocation.width; | 1162 | ginfo->full_width = ginfo->draw->allocation.width; |
| 1100 | 1163 | ||
| 1101 | ginfo->curr_pixmap = gdk_pixmap_new(widget->window, | 1164 | ginfo->curr_pixmap = gdk_pixmap_new(ginfo->draw->window, |
| 1102 | widget->allocation.width, | 1165 | ginfo->draw->allocation.width, |
| 1103 | widget->allocation.height, | 1166 | ginfo->draw->allocation.height, |
| 1104 | -1); | 1167 | -1); |
| 1105 | 1168 | ||
| 1106 | gdk_draw_rectangle(ginfo->curr_pixmap, | 1169 | gdk_draw_rectangle(ginfo->curr_pixmap, |
| 1107 | widget->style->white_gc, | 1170 | ginfo->draw->style->white_gc, |
| 1108 | TRUE, | 1171 | TRUE, |
| 1109 | 0, 0, | 1172 | 0, 0, |
| 1110 | widget->allocation.width, | 1173 | ginfo->draw->allocation.width, |
| 1111 | widget->allocation.height); | 1174 | ginfo->draw->allocation.height); |
| 1112 | 1175 | ||
| 1113 | draw_info(ginfo, widget->allocation.width); | 1176 | draw_info(ginfo, ginfo->draw->allocation.width); |
| 1114 | 1177 | ||
| 1115 | if (old_pix) { | 1178 | if (old_pix) { |
| 1116 | #if 0 | 1179 | #if 0 |
| @@ -1124,12 +1187,20 @@ configure_event(GtkWidget *widget, GdkEventMotion *event, gpointer data) | |||
| 1124 | g_object_unref(old_pix); | 1187 | g_object_unref(old_pix); |
| 1125 | } | 1188 | } |
| 1126 | 1189 | ||
| 1127 | if (!ginfo->vadj_value) | 1190 | if (ginfo->vadj_value) { |
| 1128 | return TRUE; | 1191 | // gtk_adjustment_set_lower(ginfo->vadj, -100.0); |
| 1192 | gtk_adjustment_set_value(ginfo->vadj, ginfo->vadj_value); | ||
| 1193 | } | ||
| 1194 | } | ||
| 1129 | 1195 | ||
| 1130 | // gtk_adjustment_set_lower(ginfo->vadj, -100.0); | 1196 | static gboolean |
| 1131 | gtk_adjustment_set_value(ginfo->vadj, ginfo->vadj_value); | 1197 | configure_event(GtkWidget *widget, GdkEventMotion *event, gpointer data) |
| 1198 | { | ||
| 1199 | struct graph_info *ginfo = data; | ||
| 1200 | |||
| 1201 | gtk_widget_set_size_request(widget, ginfo->draw_width, ginfo->draw_height); | ||
| 1132 | 1202 | ||
| 1203 | redraw_pixmap_backend(ginfo); | ||
| 1133 | 1204 | ||
| 1134 | /* debug */ | 1205 | /* debug */ |
| 1135 | ginfo->vadj_value = gtk_adjustment_get_value(ginfo->vadj); | 1206 | ginfo->vadj_value = gtk_adjustment_get_value(ginfo->vadj); |
