f0d936c0 |
1 | /***************************************************************************** |
2 | * Hooks to be called by the main window * |
3 | *****************************************************************************/ |
4 | |
f0d936c0 |
5 | |
189a5d08 |
6 | #define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format) |
7 | #define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format) |
8 | |
cf6cb7e0 |
9 | //#define PANGO_ENABLE_BACKEND |
558aa013 |
10 | #include <gtk/gtk.h> |
11 | #include <gdk/gdk.h> |
5f16133f |
12 | #include <glib.h> |
80a52ff8 |
13 | #include <assert.h> |
5f16133f |
14 | |
cf6cb7e0 |
15 | //#include <pango/pango.h> |
16 | |
80a52ff8 |
17 | #include <ltt/event.h> |
4ba42155 |
18 | #include <ltt/time.h> |
80a52ff8 |
19 | |
558aa013 |
20 | #include <lttv/hook.h> |
21 | #include <lttv/common.h> |
80a52ff8 |
22 | #include <lttv/state.h> |
23 | |
f0d936c0 |
24 | |
1ab818de |
25 | #include "Event_Hooks.h" |
f0d936c0 |
26 | #include "CFV.h" |
5f16133f |
27 | #include "Process_List.h" |
1ab3d149 |
28 | #include "Drawing.h" |
f7afe191 |
29 | #include "CFV-private.h" |
5f16133f |
30 | |
80a52ff8 |
31 | |
1a31868c |
32 | #define MAX_PATH_LEN 256 |
33 | |
34 | //FIXME : remove this include when tests finished. |
1a31868c |
35 | #include <string.h> |
36 | |
1a31868c |
37 | void test_draw_item(Drawing_t *Drawing, |
38 | GdkPixmap *Pixmap) |
39 | { |
40 | PropertiesIcon properties_icon; |
41 | DrawContext draw_context; |
42 | |
43 | DrawInfo current, previous; |
44 | ItemInfo over, middle, under, modify_over, modify_middle, modify_under; |
45 | |
80a52ff8 |
46 | int i=0,j=0; |
1a31868c |
47 | |
80a52ff8 |
48 | //for(i=0; i<1024;i=i+15) |
1a31868c |
49 | { |
80a52ff8 |
50 | // for(j=0;j<768;j=j+15) |
1a31868c |
51 | { |
52 | over.x = i; |
53 | over.y = j; |
1a31868c |
54 | |
55 | current.modify_over = &over; |
56 | |
57 | draw_context.drawable = Pixmap; |
58 | draw_context.gc = Drawing->Drawing_Area_V->style->black_gc; |
59 | |
60 | draw_context.Current = ¤t; |
61 | draw_context.Previous = NULL; |
62 | |
63 | properties_icon.icon_name = g_new(char, MAX_PATH_LEN); |
64 | strncpy(properties_icon.icon_name, |
65 | "/home/compudj/local/share/LinuxTraceToolkit/pixmaps/mini-display.xpm", |
66 | MAX_PATH_LEN); |
67 | properties_icon.width = -1; |
68 | properties_icon.height = -1; |
69 | properties_icon.position = OVER; |
1a31868c |
70 | draw_icon(&properties_icon, &draw_context); |
8d088fb2 |
71 | g_free(properties_icon.icon_name); |
1a31868c |
72 | } |
73 | } |
74 | |
75 | } |
f7afe191 |
76 | |
80a52ff8 |
77 | #ifdef NOTUSE |
189a5d08 |
78 | /* NOTE : no drawing data should be sent there, since the drawing widget |
96cfe486 |
79 | * has not been initialized */ |
f7afe191 |
80 | void send_test_drawing(ProcessList *Process_List, |
81 | Drawing_t *Drawing, |
82 | GdkPixmap *Pixmap, |
83 | gint x, gint y, // y not used here? |
8d088fb2 |
84 | gint width, |
f7afe191 |
85 | gint height) // height won't be used here ? |
86 | { |
1a31868c |
87 | int i,j; |
f7afe191 |
88 | ProcessInfo Process_Info = {10000, 12000, 55600}; |
89 | //ProcessInfo Process_Info = {156, 14000, 55500}; |
90 | GtkTreeRowReference *got_RowRef; |
cf6cb7e0 |
91 | PangoContext *context; |
92 | PangoLayout *layout; |
93 | PangoFontDescription *FontDesc;// = pango_font_description_new(); |
94 | gint Font_Size; |
95 | |
189a5d08 |
96 | //icon |
8d088fb2 |
97 | //GdkBitmap *mask = g_new(GdkBitmap, 1); |
98 | //GdkPixmap *icon_pixmap = g_new(GdkPixmap, 1); |
99 | GdkGC * gc; |
6d5ed1c3 |
100 | // rectangle |
101 | GdkColor color = { 0, 0xffff, 0x0000, 0x0000 }; |
102 | |
80ff382d |
103 | gc = gdk_gc_new(Pixmap); |
cf6cb7e0 |
104 | /* Sent text data */ |
80ff382d |
105 | layout = gtk_widget_create_pango_layout(Drawing->Drawing_Area_V, |
106 | NULL); |
107 | context = pango_layout_get_context(layout); |
108 | FontDesc = pango_context_get_font_description(context); |
109 | Font_Size = pango_font_description_get_size(FontDesc); |
110 | pango_font_description_set_size(FontDesc, Font_Size-3*PANGO_SCALE); |
cf6cb7e0 |
111 | |
f7afe191 |
112 | |
cf6cb7e0 |
113 | |
114 | |
f7afe191 |
115 | LttTime birth; |
116 | birth.tv_sec = 12000; |
117 | birth.tv_nsec = 55500; |
189a5d08 |
118 | g_info("we have : x : %u, y : %u, width : %u, height : %u", x, y, width, height); |
4c69e0cc |
119 | processlist_get_process_pixels(Process_List, |
f7afe191 |
120 | 1, |
121 | &birth, |
122 | &y, |
123 | &height); |
124 | |
189a5d08 |
125 | g_info("we draw : x : %u, y : %u, width : %u, height : %u", x, y, width, height); |
4c69e0cc |
126 | drawing_draw_line( |
f7afe191 |
127 | Drawing, Pixmap, x, |
128 | y+(height/2), x + width, y+(height/2), |
129 | Drawing->Drawing_Area_V->style->black_gc); |
130 | |
80ff382d |
131 | pango_layout_set_text(layout, "Test", -1); |
132 | gdk_draw_layout(Pixmap, Drawing->Drawing_Area_V->style->black_gc, |
133 | 0, y+height, layout); |
cf6cb7e0 |
134 | |
f7afe191 |
135 | birth.tv_sec = 14000; |
136 | birth.tv_nsec = 55500; |
137 | |
4c69e0cc |
138 | processlist_get_process_pixels(Process_List, |
f7afe191 |
139 | 156, |
140 | &birth, |
141 | &y, |
142 | &height); |
143 | |
144 | |
4c69e0cc |
145 | drawing_draw_line( |
f7afe191 |
146 | Drawing, Pixmap, x, |
147 | y+(height/2), x + width, y+(height/2), |
148 | Drawing->Drawing_Area_V->style->black_gc); |
149 | |
189a5d08 |
150 | g_info("y : %u, height : %u", y, height); |
f7afe191 |
151 | |
6d5ed1c3 |
152 | |
153 | |
f7afe191 |
154 | birth.tv_sec = 12000; |
155 | birth.tv_nsec = 55700; |
156 | |
4c69e0cc |
157 | processlist_get_process_pixels(Process_List, |
f7afe191 |
158 | 10, |
159 | &birth, |
160 | &y, |
161 | &height); |
6d5ed1c3 |
162 | |
163 | /* Draw rectangle (background color) */ |
80ff382d |
164 | gdk_gc_copy(gc, Drawing->Drawing_Area_V->style->black_gc); |
165 | gdk_gc_set_rgb_fg_color(gc, &color); |
166 | gdk_draw_rectangle(Pixmap, gc, |
167 | TRUE, |
168 | x, y, width, height); |
f7afe191 |
169 | |
4c69e0cc |
170 | drawing_draw_line( |
f7afe191 |
171 | Drawing, Pixmap, x, |
172 | y+(height/2), x + width, y+(height/2), |
173 | Drawing->Drawing_Area_V->style->black_gc); |
174 | |
6d5ed1c3 |
175 | |
176 | /* Draw arc */ |
177 | gdk_draw_arc(Pixmap, Drawing->Drawing_Area_V->style->black_gc, |
2f9f7ee0 |
178 | TRUE, 100, y, height/2, height/2, 0, 360*64); |
6d5ed1c3 |
179 | |
189a5d08 |
180 | g_info("y : %u, height : %u", y, height); |
f7afe191 |
181 | |
182 | for(i=0; i<10; i++) |
183 | { |
184 | birth.tv_sec = i*12000; |
185 | birth.tv_nsec = i*55700; |
186 | |
4c69e0cc |
187 | processlist_get_process_pixels(Process_List, |
f7afe191 |
188 | i, |
189 | &birth, |
190 | &y, |
191 | &height); |
192 | |
193 | |
4c69e0cc |
194 | drawing_draw_line( |
f7afe191 |
195 | Drawing, Pixmap, x, |
196 | y+(height/2), x + width, y+(height/2), |
197 | Drawing->Drawing_Area_V->style->black_gc); |
198 | |
199 | g_critical("y : %u, height : %u", y, height); |
200 | |
201 | } |
202 | |
203 | birth.tv_sec = 12000; |
204 | birth.tv_nsec = 55600; |
205 | |
4c69e0cc |
206 | processlist_get_process_pixels(Process_List, |
f7afe191 |
207 | 10, |
208 | &birth, |
209 | &y, |
210 | &height); |
211 | |
212 | |
4c69e0cc |
213 | drawing_draw_line( |
f7afe191 |
214 | Drawing, Pixmap, x, |
215 | y+(height/2), x + width, y+(height/2), |
216 | Drawing->Drawing_Area_V->style->black_gc); |
217 | |
189a5d08 |
218 | g_info("y : %u, height : %u", y, height); |
1a31868c |
219 | |
220 | |
221 | /* IMPORTANT : This action uses the cpu heavily! */ |
222 | //icon_pixmap = gdk_pixmap_create_from_xpm(Pixmap, &mask, NULL, |
223 | // "/home/compudj/local/share/LinuxTraceToolkit/pixmaps/move_message.xpm"); |
224 | // "/home/compudj/local/share/LinuxTraceToolkit/pixmaps/mini-display.xpm"); |
225 | |
226 | // gdk_gc_set_clip_mask(Drawing->Drawing_Area_V->style->black_gc, mask); |
227 | |
228 | // for(i=x;i<x+width;i=i+15) |
229 | // { |
230 | // for(j=0;j<height*20;j=j+15) |
231 | // { |
232 | |
233 | /* Draw icon */ |
234 | //gdk_gc_copy(gc, Drawing->Drawing_Area_V->style->black_gc); |
235 | // gdk_gc_set_clip_origin(Drawing->Drawing_Area_V->style->black_gc, i, j); |
236 | // gdk_draw_drawable(Pixmap, |
237 | // Drawing->Drawing_Area_V->style->black_gc, |
238 | // icon_pixmap, |
239 | // 0, 0, i, j, -1, -1); |
240 | |
241 | // } |
242 | // } |
8d088fb2 |
243 | |
1a31868c |
244 | test_draw_item(Drawing,Pixmap); |
245 | |
246 | //gdk_gc_set_clip_origin(Drawing->Drawing_Area_V->style->black_gc, 0, 0); |
247 | //gdk_gc_set_clip_mask(Drawing->Drawing_Area_V->style->black_gc, NULL); |
248 | |
249 | //g_free(icon_pixmap); |
250 | //g_free(mask); |
251 | |
252 | |
253 | |
254 | |
cf6cb7e0 |
255 | |
256 | |
80ff382d |
257 | pango_font_description_set_size(FontDesc, Font_Size); |
258 | g_object_unref(layout); |
259 | g_free(gc); |
f7afe191 |
260 | } |
261 | |
262 | void send_test_process(ProcessList *Process_List, Drawing_t *Drawing) |
5f16133f |
263 | { |
f7afe191 |
264 | guint height, y; |
5f16133f |
265 | int i; |
266 | ProcessInfo Process_Info = {10000, 12000, 55600}; |
267 | //ProcessInfo Process_Info = {156, 14000, 55500}; |
268 | GtkTreeRowReference *got_RowRef; |
269 | |
270 | LttTime birth; |
f7afe191 |
271 | |
272 | if(Process_List->Test_Process_Sent) return; |
273 | |
5f16133f |
274 | birth.tv_sec = 12000; |
275 | birth.tv_nsec = 55500; |
276 | |
4c69e0cc |
277 | processlist_add(Process_List, |
5f16133f |
278 | 1, |
279 | &birth, |
f7afe191 |
280 | &y); |
4c69e0cc |
281 | processlist_get_process_pixels(Process_List, |
f7afe191 |
282 | 1, |
283 | &birth, |
284 | &y, |
285 | &height); |
4c69e0cc |
286 | drawing_insert_square( Drawing, y, height); |
1ab3d149 |
287 | |
f7afe191 |
288 | //g_critical("y : %u, height : %u", y, height); |
5f16133f |
289 | |
290 | birth.tv_sec = 14000; |
291 | birth.tv_nsec = 55500; |
292 | |
4c69e0cc |
293 | processlist_add(Process_List, |
5f16133f |
294 | 156, |
295 | &birth, |
f7afe191 |
296 | &y); |
4c69e0cc |
297 | processlist_get_process_pixels(Process_List, |
f7afe191 |
298 | 156, |
299 | &birth, |
300 | &y, |
301 | &height); |
4c69e0cc |
302 | drawing_insert_square( Drawing, y, height); |
f7afe191 |
303 | |
304 | //g_critical("y : %u, height : %u", y, height); |
305 | |
5f16133f |
306 | birth.tv_sec = 12000; |
307 | birth.tv_nsec = 55700; |
308 | |
4c69e0cc |
309 | processlist_add(Process_List, |
5f16133f |
310 | 10, |
311 | &birth, |
312 | &height); |
4c69e0cc |
313 | processlist_get_process_pixels(Process_List, |
f7afe191 |
314 | 10, |
315 | &birth, |
316 | &y, |
317 | &height); |
4c69e0cc |
318 | drawing_insert_square( Drawing, y, height); |
f7afe191 |
319 | |
320 | //g_critical("y : %u, height : %u", y, height); |
321 | |
4c69e0cc |
322 | //drawing_insert_square( Drawing, height, 5); |
5f16133f |
323 | |
324 | for(i=0; i<10; i++) |
325 | { |
326 | birth.tv_sec = i*12000; |
327 | birth.tv_nsec = i*55700; |
328 | |
4c69e0cc |
329 | processlist_add(Process_List, |
5f16133f |
330 | i, |
331 | &birth, |
332 | &height); |
4c69e0cc |
333 | processlist_get_process_pixels(Process_List, |
f7afe191 |
334 | i, |
335 | &birth, |
336 | &y, |
337 | &height); |
4c69e0cc |
338 | drawing_insert_square( Drawing, y, height); |
f7afe191 |
339 | |
340 | // g_critical("y : %u, height : %u", y, height); |
341 | |
5f16133f |
342 | } |
f7afe191 |
343 | //g_critical("height : %u", height); |
5f16133f |
344 | |
345 | birth.tv_sec = 12000; |
346 | birth.tv_nsec = 55600; |
347 | |
4c69e0cc |
348 | processlist_add(Process_List, |
5f16133f |
349 | 10, |
350 | &birth, |
f7afe191 |
351 | &y); |
4c69e0cc |
352 | processlist_get_process_pixels(Process_List, |
f7afe191 |
353 | 10, |
354 | &birth, |
355 | &y, |
356 | &height); |
4c69e0cc |
357 | drawing_insert_square( Drawing, y, height); |
f7afe191 |
358 | |
359 | //g_critical("y : %u, height : %u", y, height); |
360 | |
4c69e0cc |
361 | processlist_add(Process_List, |
5f16133f |
362 | 10000, |
363 | &birth, |
364 | &height); |
4c69e0cc |
365 | processlist_get_process_pixels(Process_List, |
f7afe191 |
366 | 10000, |
367 | &birth, |
368 | &y, |
369 | &height); |
4c69e0cc |
370 | drawing_insert_square( Drawing, y, height); |
f7afe191 |
371 | |
372 | //g_critical("y : %u, height : %u", y, height); |
373 | |
4c69e0cc |
374 | //drawing_insert_square( Drawing, height, 5); |
f7afe191 |
375 | //g_critical("height : %u", height); |
5f16133f |
376 | |
377 | |
4c69e0cc |
378 | processlist_get_process_pixels(Process_List, |
1ab3d149 |
379 | 10000, |
380 | &birth, |
f7afe191 |
381 | &y, &height); |
4c69e0cc |
382 | processlist_remove( Process_List, |
5f16133f |
383 | 10000, |
384 | &birth); |
1ab3d149 |
385 | |
4c69e0cc |
386 | drawing_remove_square( Drawing, y, height); |
5f16133f |
387 | |
388 | if(got_RowRef = |
389 | (GtkTreeRowReference*)g_hash_table_lookup( |
390 | Process_List->Process_Hash, |
391 | &Process_Info)) |
392 | { |
393 | g_critical("key found"); |
394 | g_critical("position in the list : %s", |
395 | gtk_tree_path_to_string ( |
396 | gtk_tree_row_reference_get_path( |
397 | (GtkTreeRowReference*)got_RowRef) |
398 | )); |
399 | |
400 | } |
401 | |
f7afe191 |
402 | Process_List->Test_Process_Sent = TRUE; |
403 | |
5f16133f |
404 | } |
80a52ff8 |
405 | #endif//NOTUSE |
5f16133f |
406 | |
f0d936c0 |
407 | |
408 | /** |
409 | * Event Viewer's constructor hook |
410 | * |
411 | * This constructor is given as a parameter to the menuitem and toolbar button |
412 | * registration. It creates the list. |
413 | * @param pmParentWindow A pointer to the parent window. |
414 | * @return The widget created. |
415 | */ |
416 | GtkWidget * |
4c69e0cc |
417 | h_guicontrolflow(MainWindow *pmParentWindow, LttvTracesetSelector * s, char * key) |
f0d936c0 |
418 | { |
189a5d08 |
419 | g_info("h_guicontrolflow, %p, %p, %s", pmParentWindow, s, key); |
4c69e0cc |
420 | ControlFlowData *Control_Flow_Data = guicontrolflow() ; |
189a5d08 |
421 | |
422 | Control_Flow_Data->Parent_Window = pmParentWindow; |
f66eba62 |
423 | TimeWindow *time_window = guicontrolflow_get_time_window(Control_Flow_Data); |
424 | time_window->start_time.tv_sec = 0; |
425 | time_window->start_time.tv_nsec = 0; |
426 | time_window->time_width.tv_sec = 0; |
427 | time_window->time_width.tv_nsec = 0; |
f0d936c0 |
428 | |
f66eba62 |
429 | LttTime *current_time = guicontrolflow_get_current_time(Control_Flow_Data); |
430 | current_time->tv_sec = 0; |
431 | current_time->tv_nsec = 0; |
432 | |
433 | //g_critical("time width1 : %u",time_window->time_width); |
434 | |
41a76985 |
435 | get_time_window(pmParentWindow, |
f66eba62 |
436 | time_window); |
41a76985 |
437 | get_current_time(pmParentWindow, |
f66eba62 |
438 | current_time); |
f7afe191 |
439 | |
f66eba62 |
440 | //g_critical("time width2 : %u",time_window->time_width); |
f7afe191 |
441 | // Unreg done in the GuiControlFlow_Destructor |
3cff8cc1 |
442 | reg_update_time_window(update_time_window_hook, Control_Flow_Data, |
f7afe191 |
443 | pmParentWindow); |
3cff8cc1 |
444 | reg_update_current_time(update_current_time_hook, Control_Flow_Data, |
f7afe191 |
445 | pmParentWindow); |
3cff8cc1 |
446 | return guicontrolflow_get_widget(Control_Flow_Data) ; |
f0d936c0 |
447 | |
448 | } |
449 | |
3cff8cc1 |
450 | int event_selected_hook(void *hook_data, void *call_data) |
f0d936c0 |
451 | { |
452 | ControlFlowData *Control_Flow_Data = (ControlFlowData*) hook_data; |
453 | guint *Event_Number = (guint*) call_data; |
454 | |
455 | g_critical("DEBUG : event selected by main window : %u", *Event_Number); |
456 | |
457 | // Control_Flow_Data->Currently_Selected_Event = *Event_Number; |
458 | // Control_Flow_Data->Selected_Event = TRUE ; |
459 | |
4c69e0cc |
460 | // tree_v_set_cursor(Control_Flow_Data); |
f0d936c0 |
461 | |
462 | } |
463 | |
f0d936c0 |
464 | /* Hook called before drawing. Gets the initial context at the beginning of the |
465 | * drawing interval and copy it to the context in Event_Request. |
466 | */ |
4c69e0cc |
467 | int draw_before_hook(void *hook_data, void *call_data) |
f0d936c0 |
468 | { |
469 | EventRequest *Event_Request = (EventRequest*)hook_data; |
f66eba62 |
470 | //EventsContext Events_Context = (EventsContext*)call_data; |
f0d936c0 |
471 | |
f66eba62 |
472 | //Event_Request->Events_Context = Events_Context; |
f0d936c0 |
473 | |
474 | return 0; |
475 | } |
476 | |
477 | /* |
478 | * The draw event hook is called by the reading API to have a |
479 | * particular event drawn on the screen. |
480 | * @param hook_data ControlFlowData structure of the viewer. |
481 | * @param call_data Event context. |
482 | * |
483 | * This function basically draw lines and icons. Two types of lines are drawn : |
484 | * one small (3 pixels?) representing the state of the process and the second |
485 | * type is thicker (10 pixels?) representing on which CPU a process is running |
486 | * (and this only in running state). |
487 | * |
488 | * Extremums of the lines : |
489 | * x_min : time of the last event context for this process kept in memory. |
490 | * x_max : time of the current event. |
491 | * y : middle of the process in the process list. The process is found in the |
492 | * list, therefore is it's position in pixels. |
493 | * |
494 | * The choice of lines'color is defined by the context of the last event for this |
495 | * process. |
496 | */ |
4c69e0cc |
497 | int draw_event_hook(void *hook_data, void *call_data) |
f0d936c0 |
498 | { |
499 | EventRequest *Event_Request = (EventRequest*)hook_data; |
80a52ff8 |
500 | ControlFlowData *control_flow_data = Event_Request->Control_Flow_Data; |
e9a9c513 |
501 | //static int i=0; |
502 | |
503 | //i++; |
504 | //g_critical("%i", i); |
80a52ff8 |
505 | LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; |
e9a9c513 |
506 | |
507 | LttvTracefileState *tfs = (LttvTracefileState *)call_data; |
508 | |
509 | LttEvent *e; |
e9a9c513 |
510 | e = tfc->e; |
511 | |
80a52ff8 |
512 | /* Temp dump */ |
513 | #ifdef DONTSHOW |
514 | GString *string = g_string_new("");; |
515 | gboolean field_names = TRUE, state = TRUE; |
516 | |
e9a9c513 |
517 | lttv_event_to_string(e, tfc->tf, string, TRUE, field_names, tfs); |
518 | g_string_append_printf(string,"\n"); |
519 | |
520 | if(state) { |
521 | g_string_append_printf(string, " %s", |
522 | g_quark_to_string(tfs->process->state->s)); |
523 | } |
524 | |
525 | g_info("%s",string->str); |
526 | |
527 | g_string_free(string, TRUE); |
528 | |
529 | /* End of text dump */ |
80a52ff8 |
530 | #endif //DONTSHOW |
e9a9c513 |
531 | /* Add process to process list (if not present) and get drawing "y" from |
532 | * process position */ |
533 | guint pid = tfs->process->pid; |
534 | LttTime birth = tfs->process->creation_time; |
432a7065 |
535 | gchar *name = strdup("name"); |
80a52ff8 |
536 | guint y = 0, height = 0, pl_height = 0; |
537 | HashedProcessData *Hashed_Process_Data = NULL; |
538 | |
e9a9c513 |
539 | ProcessList *process_list = |
540 | guicontrolflow_get_process_list(Event_Request->Control_Flow_Data); |
541 | |
542 | if(processlist_get_process_pixels(process_list, |
543 | pid, |
544 | &birth, |
545 | &y, |
80a52ff8 |
546 | &height, |
547 | &Hashed_Process_Data) == 1) |
e9a9c513 |
548 | { |
549 | /* Process not present */ |
550 | processlist_add(process_list, |
551 | pid, |
552 | &birth, |
432a7065 |
553 | name, |
80a52ff8 |
554 | &pl_height, |
555 | &Hashed_Process_Data); |
432a7065 |
556 | g_free(name); |
e9a9c513 |
557 | drawing_insert_square( Event_Request->Control_Flow_Data->Drawing, y, height); |
558 | } |
80a52ff8 |
559 | |
e9a9c513 |
560 | /* Find pixels corresponding to time of the event. If the time does |
561 | * not fit in the window, show a warning, not supposed to happend. */ |
80a52ff8 |
562 | guint x = 0; |
563 | guint width = control_flow_data->Drawing->Drawing_Area_V->allocation.width; |
e9a9c513 |
564 | |
80a52ff8 |
565 | LttTime time = ltt_event_time(e); |
566 | |
567 | LttTime window_end = ltt_time_add(control_flow_data->Time_Window.time_width, |
568 | control_flow_data->Time_Window.start_time); |
569 | |
570 | |
571 | convert_time_to_pixels( |
572 | control_flow_data->Time_Window.start_time, |
573 | window_end, |
574 | time, |
575 | width, |
576 | &x); |
e9a9c513 |
577 | |
80a52ff8 |
578 | assert(x <= width); |
f66eba62 |
579 | |
80a52ff8 |
580 | /* Finally, draw what represents the event. */ |
581 | |
582 | GdkColor color = { 0, 0xffff, 0x0000, 0x0000 }; |
583 | PropertiesArc prop_arc; |
584 | prop_arc.color = &color; |
585 | prop_arc.size = 10; |
586 | prop_arc.filled = TRUE; |
587 | prop_arc.position = OVER; |
34b04882 |
588 | |
80a52ff8 |
589 | DrawContext *draw_context = Hashed_Process_Data->draw_context; |
590 | draw_context->Current->modify_over->x = x; |
80a52ff8 |
591 | draw_context->Current->modify_over->y = y; |
80a52ff8 |
592 | draw_context->drawable = control_flow_data->Drawing->Pixmap; |
34b04882 |
593 | draw_context->pango_layout = control_flow_data->Drawing->pango_layout; |
80a52ff8 |
594 | GtkWidget *widget = control_flow_data->Drawing->Drawing_Area_V; |
595 | //draw_context->gc = widget->style->fg_gc[GTK_WIDGET_STATE (widget)]; |
596 | draw_context->gc = widget->style->black_gc; |
597 | |
34b04882 |
598 | //draw_arc((void*)&prop_arc, (void*)draw_context); |
80a52ff8 |
599 | //test_draw_item(control_flow_data->Drawing, control_flow_data->Drawing->Pixmap); |
34b04882 |
600 | |
601 | GdkColor colorfg = { 0, 0x0000, 0x0000, 0x0000 }; |
602 | GdkColor colorbg = { 0, 0xffff, 0x0000, 0xffff }; |
603 | PropertiesText prop_text; |
604 | prop_text.foreground = &colorfg; |
605 | prop_text.background = &colorbg; |
606 | prop_text.size = 10; |
607 | prop_text.position = OVER; |
608 | |
609 | /* Print status of the process : U, WF, WC, E, W, R */ |
610 | if(tfs->process->state->s == LTTV_STATE_UNNAMED) |
611 | prop_text.Text = "U"; |
612 | else if(tfs->process->state->s == LTTV_STATE_WAIT_FORK) |
613 | prop_text.Text = "WF"; |
614 | else if(tfs->process->state->s == LTTV_STATE_WAIT_CPU) |
615 | prop_text.Text = "WC"; |
616 | else if(tfs->process->state->s == LTTV_STATE_EXIT) |
617 | prop_text.Text = "E"; |
618 | else if(tfs->process->state->s == LTTV_STATE_WAIT) |
619 | prop_text.Text = "W"; |
620 | else if(tfs->process->state->s == LTTV_STATE_RUN) |
621 | prop_text.Text = "R"; |
622 | else |
623 | prop_text.Text = "U"; |
624 | |
625 | draw_text((void*)&prop_text, (void*)draw_context); |
626 | |
f0d936c0 |
627 | return 0; |
628 | } |
629 | |
630 | |
4c69e0cc |
631 | int draw_after_hook(void *hook_data, void *call_data) |
f0d936c0 |
632 | { |
633 | EventRequest *Event_Request = (EventRequest*)hook_data; |
634 | |
635 | g_free(Event_Request); |
636 | return 0; |
637 | } |
f7afe191 |
638 | |
639 | |
640 | |
641 | |
4c69e0cc |
642 | void update_time_window_hook(void *hook_data, void *call_data) |
f7afe191 |
643 | { |
4ba42155 |
644 | ControlFlowData *control_flow_data = (ControlFlowData*) hook_data; |
645 | TimeWindow *Old_Time_Window = |
646 | guicontrolflow_get_time_window(control_flow_data); |
f7afe191 |
647 | TimeWindow *New_Time_Window = ((TimeWindow*)call_data); |
bd24a9af |
648 | |
4ba42155 |
649 | /* Two cases : zoom in/out or scrolling */ |
bd24a9af |
650 | |
4ba42155 |
651 | /* In order to make sure we can reuse the old drawing, the scale must |
652 | * be the same and the new time interval being partly located in the |
653 | * currently shown time interval. (reuse is only for scrolling) |
654 | */ |
655 | |
656 | g_info("Old time window HOOK : %u, %u to %u, %u", |
657 | Old_Time_Window->start_time.tv_sec, |
658 | Old_Time_Window->start_time.tv_nsec, |
659 | Old_Time_Window->time_width.tv_sec, |
660 | Old_Time_Window->time_width.tv_nsec); |
f7afe191 |
661 | |
189a5d08 |
662 | g_info("New time window HOOK : %u, %u to %u, %u", |
4ba42155 |
663 | New_Time_Window->start_time.tv_sec, |
664 | New_Time_Window->start_time.tv_nsec, |
665 | New_Time_Window->time_width.tv_sec, |
666 | New_Time_Window->time_width.tv_nsec); |
667 | |
668 | if( New_Time_Window->time_width.tv_sec == Old_Time_Window->time_width.tv_sec |
669 | && New_Time_Window->time_width.tv_nsec == Old_Time_Window->time_width.tv_nsec) |
670 | { |
671 | /* Same scale (scrolling) */ |
672 | g_info("scrolling"); |
673 | LttTime *ns = &New_Time_Window->start_time; |
674 | LttTime *os = &Old_Time_Window->start_time; |
675 | LttTime old_end = ltt_time_add(Old_Time_Window->start_time, |
676 | Old_Time_Window->time_width); |
677 | LttTime new_end = ltt_time_add(New_Time_Window->start_time, |
678 | New_Time_Window->time_width); |
679 | //if(ns<os+w<ns+w) |
680 | //if(ns<os+w && os+w<ns+w) |
681 | //if(ns<old_end && os<ns) |
682 | if(ltt_time_compare(*ns, old_end) == -1 |
683 | && ltt_time_compare(*os, *ns) == -1) |
684 | { |
685 | g_info("scrolling near right"); |
686 | /* Scroll right, keep right part of the screen */ |
687 | guint x = 0; |
688 | guint width = control_flow_data->Drawing->Drawing_Area_V->allocation.width; |
689 | convert_time_to_pixels( |
690 | *os, |
691 | old_end, |
692 | *ns, |
693 | width, |
694 | &x); |
695 | |
696 | /* Copy old data to new location */ |
697 | gdk_draw_drawable (control_flow_data->Drawing->Pixmap, |
698 | control_flow_data->Drawing->Drawing_Area_V->style->white_gc, |
699 | control_flow_data->Drawing->Pixmap, |
700 | x, 0, |
701 | 0, 0, |
702 | -1, -1); |
432a7065 |
703 | |
704 | convert_time_to_pixels( |
705 | *ns, |
706 | new_end, |
707 | old_end, |
708 | width, |
709 | &x); |
4ba42155 |
710 | |
3a941e84 |
711 | *Old_Time_Window = *New_Time_Window; |
432a7065 |
712 | /* Clear the data request background, but not SAFETY */ |
713 | gdk_draw_rectangle (control_flow_data->Drawing->Pixmap, |
714 | control_flow_data->Drawing->Drawing_Area_V->style->white_gc, |
715 | TRUE, |
716 | x+SAFETY, 0, |
717 | control_flow_data->Drawing->width - x, // do not overlap |
718 | control_flow_data->Drawing->height+SAFETY); |
4ba42155 |
719 | /* Get new data for the rest. */ |
720 | drawing_data_request(control_flow_data->Drawing, |
721 | &control_flow_data->Drawing->Pixmap, |
722 | x, 0, |
723 | control_flow_data->Drawing->width - x, |
724 | control_flow_data->Drawing->height); |
725 | |
726 | drawing_refresh(control_flow_data->Drawing, |
727 | 0, 0, |
728 | control_flow_data->Drawing->width, |
729 | control_flow_data->Drawing->height); |
730 | |
731 | |
732 | } else { |
733 | //if(ns<os<ns+w) |
734 | //if(ns<os && os<ns+w) |
735 | //if(ns<os && os<new_end) |
736 | if(ltt_time_compare(*ns,*os) == -1 |
737 | && ltt_time_compare(*os,new_end) == -1) |
738 | { |
739 | g_info("scrolling near left"); |
740 | /* Scroll left, keep left part of the screen */ |
741 | guint x = 0; |
742 | guint width = control_flow_data->Drawing->Drawing_Area_V->allocation.width; |
743 | convert_time_to_pixels( |
744 | *ns, |
745 | new_end, |
746 | *os, |
747 | width, |
748 | &x); |
749 | |
750 | /* Copy old data to new location */ |
751 | gdk_draw_drawable (control_flow_data->Drawing->Pixmap, |
752 | control_flow_data->Drawing->Drawing_Area_V->style->white_gc, |
753 | control_flow_data->Drawing->Pixmap, |
754 | 0, 0, |
755 | x, 0, |
756 | -1, -1); |
757 | |
3a941e84 |
758 | *Old_Time_Window = *New_Time_Window; |
432a7065 |
759 | |
760 | /* Clean the data request background */ |
761 | gdk_draw_rectangle (control_flow_data->Drawing->Pixmap, |
762 | control_flow_data->Drawing->Drawing_Area_V->style->white_gc, |
763 | TRUE, |
764 | 0, 0, |
765 | x, // do not overlap |
766 | control_flow_data->Drawing->height+SAFETY); |
4ba42155 |
767 | /* Get new data for the rest. */ |
768 | drawing_data_request(control_flow_data->Drawing, |
769 | &control_flow_data->Drawing->Pixmap, |
770 | 0, 0, |
771 | x, |
772 | control_flow_data->Drawing->height); |
773 | |
774 | drawing_refresh(control_flow_data->Drawing, |
775 | 0, 0, |
776 | control_flow_data->Drawing->width, |
777 | control_flow_data->Drawing->height); |
778 | |
779 | } else { |
780 | g_info("scrolling far"); |
781 | /* Cannot reuse any part of the screen : far jump */ |
782 | *Old_Time_Window = *New_Time_Window; |
432a7065 |
783 | |
bd24a9af |
784 | |
432a7065 |
785 | gdk_draw_rectangle (control_flow_data->Drawing->Pixmap, |
786 | control_flow_data->Drawing->Drawing_Area_V->style->white_gc, |
787 | TRUE, |
788 | 0, 0, |
789 | control_flow_data->Drawing->width+SAFETY, // do not overlap |
790 | control_flow_data->Drawing->height+SAFETY); |
4ba42155 |
791 | |
792 | drawing_data_request(control_flow_data->Drawing, |
793 | &control_flow_data->Drawing->Pixmap, |
794 | 0, 0, |
795 | control_flow_data->Drawing->width, |
796 | control_flow_data->Drawing->height); |
797 | |
798 | drawing_refresh(control_flow_data->Drawing, |
799 | 0, 0, |
800 | control_flow_data->Drawing->width, |
801 | control_flow_data->Drawing->height); |
802 | } |
803 | } |
804 | } else { |
805 | /* Different scale (zoom) */ |
806 | g_info("zoom"); |
f7afe191 |
807 | |
4ba42155 |
808 | *Old_Time_Window = *New_Time_Window; |
432a7065 |
809 | |
810 | gdk_draw_rectangle (control_flow_data->Drawing->Pixmap, |
811 | control_flow_data->Drawing->Drawing_Area_V->style->white_gc, |
812 | TRUE, |
813 | 0, 0, |
814 | control_flow_data->Drawing->width+SAFETY, // do not overlap |
815 | control_flow_data->Drawing->height+SAFETY); |
816 | |
817 | |
4ba42155 |
818 | drawing_data_request(control_flow_data->Drawing, |
819 | &control_flow_data->Drawing->Pixmap, |
820 | 0, 0, |
821 | control_flow_data->Drawing->width, |
822 | control_flow_data->Drawing->height); |
823 | |
824 | drawing_refresh(control_flow_data->Drawing, |
825 | 0, 0, |
826 | control_flow_data->Drawing->width, |
827 | control_flow_data->Drawing->height); |
828 | } |
829 | |
830 | |
f7afe191 |
831 | } |
832 | |
4c69e0cc |
833 | void update_current_time_hook(void *hook_data, void *call_data) |
f7afe191 |
834 | { |
835 | ControlFlowData *Control_Flow_Data = (ControlFlowData*) hook_data; |
836 | LttTime* Current_Time = |
4c69e0cc |
837 | guicontrolflow_get_current_time(Control_Flow_Data); |
f7afe191 |
838 | *Current_Time = *((LttTime*)call_data); |
189a5d08 |
839 | g_info("New Current time HOOK : %u, %u", Current_Time->tv_sec, |
f7afe191 |
840 | Current_Time->tv_nsec); |
841 | |
842 | /* If current time is inside time interval, just move the highlight |
843 | * bar */ |
844 | |
845 | /* Else, we have to change the time interval. We have to tell it |
846 | * to the main window. */ |
847 | /* The time interval change will take care of placing the current |
848 | * time at the center of the visible area */ |
849 | |
850 | } |
851 | |