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