1 /*****************************************************************************
2 * Hooks to be called by the main window *
3 *****************************************************************************/
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)
9 //#define PANGO_ENABLE_BACKEND
14 //#include <pango/pango.h>
16 #include <lttv/hook.h>
17 #include <lttv/common.h>
19 #include "Event_Hooks.h"
21 #include "Process_List.h"
23 #include "CFV-private.h"
26 /* NOTE : no drawing data should be sent there, since the drawing widget
27 * has not been initialized */
28 void send_test_drawing(ProcessList
*Process_List
,
31 gint x
, gint y
, // y not used here?
33 gint height
) // height won't be used here ?
36 ProcessInfo Process_Info
= {10000, 12000, 55600};
37 //ProcessInfo Process_Info = {156, 14000, 55500};
38 GtkTreeRowReference
*got_RowRef
;
39 PangoContext
*context
;
41 PangoFontDescription
*FontDesc
;// = pango_font_description_new();
45 GdkBitmap
*mask
= g_new(GdkBitmap
, 1);
46 GdkPixmap
*icon_pixmap
= g_new(GdkPixmap
, 1);
47 GdkGC
* gc
= gdk_gc_new(Pixmap
);
50 layout
= gtk_widget_create_pango_layout(Drawing
->Drawing_Area_V
,
52 context
= pango_layout_get_context(layout
);
53 FontDesc
= pango_context_get_font_description(context
);
54 Font_Size
= pango_font_description_get_size(FontDesc
);
55 pango_font_description_set_size(FontDesc
, Font_Size
-3*PANGO_SCALE
);
62 birth
.tv_nsec
= 55500;
63 g_info("we have : x : %u, y : %u, width : %u, height : %u", x
, y
, width
, height
);
64 processlist_get_process_pixels(Process_List
,
70 g_info("we draw : x : %u, y : %u, width : %u, height : %u", x
, y
, width
, height
);
73 y
+(height
/2), x
+ width
, y
+(height
/2),
74 Drawing
->Drawing_Area_V
->style
->black_gc
);
76 pango_layout_set_text(layout
, "Test", -1);
77 gdk_draw_layout(Pixmap
, Drawing
->Drawing_Area_V
->style
->black_gc
,
81 birth
.tv_nsec
= 55500;
83 processlist_get_process_pixels(Process_List
,
92 y
+(height
/2), x
+ width
, y
+(height
/2),
93 Drawing
->Drawing_Area_V
->style
->black_gc
);
97 icon_pixmap
= gdk_pixmap_create_from_xpm(Pixmap
, &mask
, NULL
,
98 // "/home/compudj/local/share/LinuxTraceToolkit/pixmaps/move_message.xpm");
99 "/home/compudj/local/share/LinuxTraceToolkit/pixmaps/mini-display.xpm");
100 gdk_gc_copy(gc
, Drawing
->Drawing_Area_V
->style
->black_gc
);
101 gdk_gc_set_clip_mask(gc
, mask
);
102 gdk_draw_drawable(Pixmap
,
111 g_info("y : %u, height : %u", y
, height
);
113 birth
.tv_sec
= 12000;
114 birth
.tv_nsec
= 55700;
116 processlist_get_process_pixels(Process_List
,
125 y
+(height
/2), x
+ width
, y
+(height
/2),
126 Drawing
->Drawing_Area_V
->style
->black_gc
);
128 g_info("y : %u, height : %u", y
, height
);
132 birth
.tv_sec
= i
*12000;
133 birth
.tv_nsec
= i
*55700;
135 processlist_get_process_pixels(Process_List
,
144 y
+(height
/2), x
+ width
, y
+(height
/2),
145 Drawing
->Drawing_Area_V
->style
->black_gc
);
147 g_critical("y : %u, height : %u", y
, height
);
151 birth
.tv_sec
= 12000;
152 birth
.tv_nsec
= 55600;
154 processlist_get_process_pixels(Process_List
,
163 y
+(height
/2), x
+ width
, y
+(height
/2),
164 Drawing
->Drawing_Area_V
->style
->black_gc
);
166 g_info("y : %u, height : %u", y
, height
);
169 pango_font_description_set_size(FontDesc
, Font_Size
);
174 void send_test_process(ProcessList
*Process_List
, Drawing_t
*Drawing
)
178 ProcessInfo Process_Info
= {10000, 12000, 55600};
179 //ProcessInfo Process_Info = {156, 14000, 55500};
180 GtkTreeRowReference
*got_RowRef
;
184 if(Process_List
->Test_Process_Sent
) return;
186 birth
.tv_sec
= 12000;
187 birth
.tv_nsec
= 55500;
189 processlist_add(Process_List
,
193 processlist_get_process_pixels(Process_List
,
198 drawing_insert_square( Drawing
, y
, height
);
200 //g_critical("y : %u, height : %u", y, height);
202 birth
.tv_sec
= 14000;
203 birth
.tv_nsec
= 55500;
205 processlist_add(Process_List
,
209 processlist_get_process_pixels(Process_List
,
214 drawing_insert_square( Drawing
, y
, height
);
216 //g_critical("y : %u, height : %u", y, height);
218 birth
.tv_sec
= 12000;
219 birth
.tv_nsec
= 55700;
221 processlist_add(Process_List
,
225 processlist_get_process_pixels(Process_List
,
230 drawing_insert_square( Drawing
, y
, height
);
232 //g_critical("y : %u, height : %u", y, height);
234 //drawing_insert_square( Drawing, height, 5);
238 birth
.tv_sec
= i
*12000;
239 birth
.tv_nsec
= i
*55700;
241 processlist_add(Process_List
,
245 processlist_get_process_pixels(Process_List
,
250 drawing_insert_square( Drawing
, y
, height
);
252 // g_critical("y : %u, height : %u", y, height);
255 //g_critical("height : %u", height);
257 birth
.tv_sec
= 12000;
258 birth
.tv_nsec
= 55600;
260 processlist_add(Process_List
,
264 processlist_get_process_pixels(Process_List
,
269 drawing_insert_square( Drawing
, y
, height
);
271 //g_critical("y : %u, height : %u", y, height);
273 processlist_add(Process_List
,
277 processlist_get_process_pixels(Process_List
,
282 drawing_insert_square( Drawing
, y
, height
);
284 //g_critical("y : %u, height : %u", y, height);
286 //drawing_insert_square( Drawing, height, 5);
287 //g_critical("height : %u", height);
290 processlist_get_process_pixels(Process_List
,
294 processlist_remove( Process_List
,
298 drawing_remove_square( Drawing
, y
, height
);
301 (GtkTreeRowReference
*)g_hash_table_lookup(
302 Process_List
->Process_Hash
,
305 g_critical("key found");
306 g_critical("position in the list : %s",
307 gtk_tree_path_to_string (
308 gtk_tree_row_reference_get_path(
309 (GtkTreeRowReference
*)got_RowRef
)
314 Process_List
->Test_Process_Sent
= TRUE
;
321 * Event Viewer's constructor hook
323 * This constructor is given as a parameter to the menuitem and toolbar button
324 * registration. It creates the list.
325 * @param pmParentWindow A pointer to the parent window.
326 * @return The widget created.
329 h_guicontrolflow(MainWindow
*pmParentWindow
, LttvTracesetSelector
* s
, char * key
)
331 g_info("h_guicontrolflow, %p, %p, %s", pmParentWindow
, s
, key
);
332 ControlFlowData
*Control_Flow_Data
= guicontrolflow() ;
334 Control_Flow_Data
->Parent_Window
= pmParentWindow
;
336 get_time_window(pmParentWindow
,
337 guicontrolflow_get_time_window(Control_Flow_Data
));
338 get_current_time(pmParentWindow
,
339 guicontrolflow_get_current_time(Control_Flow_Data
));
341 // Unreg done in the GuiControlFlow_Destructor
342 reg_update_time_window(update_time_window_hook
, Control_Flow_Data
,
344 reg_update_current_time(update_current_time_hook
, Control_Flow_Data
,
346 return guicontrolflow_get_widget(Control_Flow_Data
) ;
350 int event_selected_hook(void *hook_data
, void *call_data
)
352 ControlFlowData
*Control_Flow_Data
= (ControlFlowData
*) hook_data
;
353 guint
*Event_Number
= (guint
*) call_data
;
355 g_critical("DEBUG : event selected by main window : %u", *Event_Number
);
357 // Control_Flow_Data->Currently_Selected_Event = *Event_Number;
358 // Control_Flow_Data->Selected_Event = TRUE ;
360 // tree_v_set_cursor(Control_Flow_Data);
365 /* Hook called before drawing. Gets the initial context at the beginning of the
366 * drawing interval and copy it to the context in Event_Request.
368 int draw_before_hook(void *hook_data
, void *call_data
)
370 EventRequest
*Event_Request
= (EventRequest
*)hook_data
;
371 EventsContext Events_Context
= (EventsContext
*)call_data
;
373 Event_Request
->Events_Context
= Events_Context
;
379 * The draw event hook is called by the reading API to have a
380 * particular event drawn on the screen.
381 * @param hook_data ControlFlowData structure of the viewer.
382 * @param call_data Event context.
384 * This function basically draw lines and icons. Two types of lines are drawn :
385 * one small (3 pixels?) representing the state of the process and the second
386 * type is thicker (10 pixels?) representing on which CPU a process is running
387 * (and this only in running state).
389 * Extremums of the lines :
390 * x_min : time of the last event context for this process kept in memory.
391 * x_max : time of the current event.
392 * y : middle of the process in the process list. The process is found in the
393 * list, therefore is it's position in pixels.
395 * The choice of lines'color is defined by the context of the last event for this
398 int draw_event_hook(void *hook_data
, void *call_data
)
400 EventRequest
*Event_Request
= (EventRequest
*)hook_data
;
406 int draw_after_hook(void *hook_data
, void *call_data
)
408 EventRequest
*Event_Request
= (EventRequest
*)hook_data
;
410 g_free(Event_Request
);
418 void update_time_window_hook(void *hook_data
, void *call_data
)
420 ControlFlowData
*Control_Flow_Data
= (ControlFlowData
*) hook_data
;
421 TimeWindow
* Time_Window
=
422 guicontrolflow_get_time_window(Control_Flow_Data
);
423 TimeWindow
*New_Time_Window
= ((TimeWindow
*)call_data
);
425 // As the time interval change will mostly be used for
426 // zoom in and out, it's not useful to keep old drawing
427 // sections, as scale will be changed.
430 *Time_Window
= *New_Time_Window
;
431 g_info("New time window HOOK : %u, %u to %u, %u",
432 Time_Window
->start_time
.tv_sec
,
433 Time_Window
->start_time
.tv_nsec
,
434 Time_Window
->time_width
.tv_sec
,
435 Time_Window
->time_width
.tv_nsec
);
437 drawing_data_request(Control_Flow_Data
->Drawing
,
438 &Control_Flow_Data
->Drawing
->Pixmap
,
440 Control_Flow_Data
->Drawing
->width
,
441 Control_Flow_Data
->Drawing
->height
);
443 drawing_refresh(Control_Flow_Data
->Drawing
,
445 Control_Flow_Data
->Drawing
->width
,
446 Control_Flow_Data
->Drawing
->height
);
450 void update_current_time_hook(void *hook_data
, void *call_data
)
452 ControlFlowData
*Control_Flow_Data
= (ControlFlowData
*) hook_data
;
453 LttTime
* Current_Time
=
454 guicontrolflow_get_current_time(Control_Flow_Data
);
455 *Current_Time
= *((LttTime
*)call_data
);
456 g_info("New Current time HOOK : %u, %u", Current_Time
->tv_sec
,
457 Current_Time
->tv_nsec
);
459 /* If current time is inside time interval, just move the highlight
462 /* Else, we have to change the time interval. We have to tell it
463 * to the main window. */
464 /* The time interval change will take care of placing the current
465 * time at the center of the visible area */