1 /*****************************************************************************
2 * Hooks to be called by the main window *
3 *****************************************************************************/
6 //#define PANGO_ENABLE_BACKEND
11 //#include <pango/pango.h>
13 #include <lttv/hook.h>
14 #include <lttv/common.h>
16 #include "Event_Hooks.h"
18 #include "Process_List.h"
20 #include "CFV-private.h"
23 /* NOTE : no drawing data should be sent there, as the drawing widget
24 * has not been initialized */
25 void send_test_drawing(ProcessList
*Process_List
,
28 gint x
, gint y
, // y not used here?
30 gint height
) // height won't be used here ?
33 ProcessInfo Process_Info
= {10000, 12000, 55600};
34 //ProcessInfo Process_Info = {156, 14000, 55500};
35 GtkTreeRowReference
*got_RowRef
;
36 PangoContext
*context
;
38 PangoFontDescription
*FontDesc
;// = pango_font_description_new();
42 layout
= gtk_widget_create_pango_layout(Drawing
->Drawing_Area_V
,
44 context
= pango_layout_get_context(layout
);
45 FontDesc
= pango_context_get_font_description(context
);
46 Font_Size
= pango_font_description_get_size(FontDesc
);
47 pango_font_description_set_size(FontDesc
, Font_Size
-3*PANGO_SCALE
);
54 birth
.tv_nsec
= 55500;
55 g_critical("we have : x : %u, y : %u, width : %u, height : %u", x
, y
, width
, height
);
56 ProcessList_get_process_pixels(Process_List
,
62 g_critical("we draw : x : %u, y : %u, width : %u, height : %u", x
, y
, width
, height
);
65 y
+(height
/2), x
+ width
, y
+(height
/2),
66 Drawing
->Drawing_Area_V
->style
->black_gc
);
68 pango_layout_set_text(layout
, "Test", -1);
69 gdk_draw_layout(Pixmap
, Drawing
->Drawing_Area_V
->style
->black_gc
,
73 birth
.tv_nsec
= 55500;
75 ProcessList_get_process_pixels(Process_List
,
84 y
+(height
/2), x
+ width
, y
+(height
/2),
85 Drawing
->Drawing_Area_V
->style
->black_gc
);
87 g_critical("y : %u, height : %u", y
, height
);
90 birth
.tv_nsec
= 55700;
92 ProcessList_get_process_pixels(Process_List
,
101 y
+(height
/2), x
+ width
, y
+(height
/2),
102 Drawing
->Drawing_Area_V
->style
->black_gc
);
104 g_critical("y : %u, height : %u", y
, height
);
108 birth
.tv_sec
= i
*12000;
109 birth
.tv_nsec
= i
*55700;
111 ProcessList_get_process_pixels(Process_List
,
120 y
+(height
/2), x
+ width
, y
+(height
/2),
121 Drawing
->Drawing_Area_V
->style
->black_gc
);
123 g_critical("y : %u, height : %u", y
, height
);
127 birth
.tv_sec
= 12000;
128 birth
.tv_nsec
= 55600;
130 ProcessList_get_process_pixels(Process_List
,
139 y
+(height
/2), x
+ width
, y
+(height
/2),
140 Drawing
->Drawing_Area_V
->style
->black_gc
);
142 g_critical("y : %u, height : %u", y
, height
);
145 pango_font_description_set_size(FontDesc
, Font_Size
);
150 void send_test_process(ProcessList
*Process_List
, Drawing_t
*Drawing
)
154 ProcessInfo Process_Info
= {10000, 12000, 55600};
155 //ProcessInfo Process_Info = {156, 14000, 55500};
156 GtkTreeRowReference
*got_RowRef
;
160 if(Process_List
->Test_Process_Sent
) return;
162 birth
.tv_sec
= 12000;
163 birth
.tv_nsec
= 55500;
165 ProcessList_add(Process_List
,
169 ProcessList_get_process_pixels(Process_List
,
174 Drawing_Insert_Square( Drawing
, y
, height
);
176 //g_critical("y : %u, height : %u", y, height);
178 birth
.tv_sec
= 14000;
179 birth
.tv_nsec
= 55500;
181 ProcessList_add(Process_List
,
185 ProcessList_get_process_pixels(Process_List
,
190 Drawing_Insert_Square( Drawing
, y
, height
);
192 //g_critical("y : %u, height : %u", y, height);
194 birth
.tv_sec
= 12000;
195 birth
.tv_nsec
= 55700;
197 ProcessList_add(Process_List
,
201 ProcessList_get_process_pixels(Process_List
,
206 Drawing_Insert_Square( Drawing
, y
, height
);
208 //g_critical("y : %u, height : %u", y, height);
210 //Drawing_Insert_Square( Drawing, height, 5);
214 birth
.tv_sec
= i
*12000;
215 birth
.tv_nsec
= i
*55700;
217 ProcessList_add(Process_List
,
221 ProcessList_get_process_pixels(Process_List
,
226 Drawing_Insert_Square( Drawing
, y
, height
);
228 // g_critical("y : %u, height : %u", y, height);
231 //g_critical("height : %u", height);
233 birth
.tv_sec
= 12000;
234 birth
.tv_nsec
= 55600;
236 ProcessList_add(Process_List
,
240 ProcessList_get_process_pixels(Process_List
,
245 Drawing_Insert_Square( Drawing
, y
, height
);
247 //g_critical("y : %u, height : %u", y, height);
249 ProcessList_add(Process_List
,
253 ProcessList_get_process_pixels(Process_List
,
258 Drawing_Insert_Square( Drawing
, y
, height
);
260 //g_critical("y : %u, height : %u", y, height);
262 //Drawing_Insert_Square( Drawing, height, 5);
263 //g_critical("height : %u", height);
266 ProcessList_get_process_pixels(Process_List
,
270 ProcessList_remove( Process_List
,
274 Drawing_Remove_Square( Drawing
, y
, height
);
277 (GtkTreeRowReference
*)g_hash_table_lookup(
278 Process_List
->Process_Hash
,
281 g_critical("key found");
282 g_critical("position in the list : %s",
283 gtk_tree_path_to_string (
284 gtk_tree_row_reference_get_path(
285 (GtkTreeRowReference
*)got_RowRef
)
290 Process_List
->Test_Process_Sent
= TRUE
;
297 * Event Viewer's constructor hook
299 * This constructor is given as a parameter to the menuitem and toolbar button
300 * registration. It creates the list.
301 * @param pmParentWindow A pointer to the parent window.
302 * @return The widget created.
305 hGuiControlFlow(MainWindow
*pmParentWindow
, LttvTracesetSelector
* s
, char * key
)
307 g_critical("hGuiControlFlow");
308 ControlFlowData
*Control_Flow_Data
= GuiControlFlow() ;
310 get_time_window(pmParentWindow
,
311 GuiControlFlow_get_Time_Window(Control_Flow_Data
));
312 get_current_time(pmParentWindow
,
313 GuiControlFlow_get_Current_Time(Control_Flow_Data
));
315 // Unreg done in the GuiControlFlow_Destructor
316 reg_update_time_window(Update_Time_Window_Hook
, Control_Flow_Data
,
318 reg_update_current_time(Update_Current_Time_Hook
, Control_Flow_Data
,
320 return GuiControlFlow_get_Widget(Control_Flow_Data
) ;
324 int Event_Selected_Hook(void *hook_data
, void *call_data
)
326 ControlFlowData
*Control_Flow_Data
= (ControlFlowData
*) hook_data
;
327 guint
*Event_Number
= (guint
*) call_data
;
329 g_critical("DEBUG : event selected by main window : %u", *Event_Number
);
331 // Control_Flow_Data->Currently_Selected_Event = *Event_Number;
332 // Control_Flow_Data->Selected_Event = TRUE ;
334 // Tree_V_set_cursor(Control_Flow_Data);
339 /* Hook called before drawing. Gets the initial context at the beginning of the
340 * drawing interval and copy it to the context in Event_Request.
342 int Draw_Before_Hook(void *hook_data
, void *call_data
)
344 EventRequest
*Event_Request
= (EventRequest
*)hook_data
;
345 EventsContext Events_Context
= (EventsContext
*)call_data
;
347 Event_Request
->Events_Context
= Events_Context
;
353 * The draw event hook is called by the reading API to have a
354 * particular event drawn on the screen.
355 * @param hook_data ControlFlowData structure of the viewer.
356 * @param call_data Event context.
358 * This function basically draw lines and icons. Two types of lines are drawn :
359 * one small (3 pixels?) representing the state of the process and the second
360 * type is thicker (10 pixels?) representing on which CPU a process is running
361 * (and this only in running state).
363 * Extremums of the lines :
364 * x_min : time of the last event context for this process kept in memory.
365 * x_max : time of the current event.
366 * y : middle of the process in the process list. The process is found in the
367 * list, therefore is it's position in pixels.
369 * The choice of lines'color is defined by the context of the last event for this
372 int Draw_Event_Hook(void *hook_data
, void *call_data
)
374 EventRequest
*Event_Request
= (EventRequest
*)hook_data
;
380 int Draw_After_Hook(void *hook_data
, void *call_data
)
382 EventRequest
*Event_Request
= (EventRequest
*)hook_data
;
384 g_free(Event_Request
);
392 void Update_Time_Window_Hook(void *hook_data
, void *call_data
)
394 ControlFlowData
*Control_Flow_Data
= (ControlFlowData
*) hook_data
;
395 TimeWindow
* Time_Window
=
396 GuiControlFlow_get_Time_Window(Control_Flow_Data
);
397 TimeWindow
*New_Time_Window
= ((TimeWindow
*)call_data
);
399 // As the time interval change will mostly be used for
400 // zoom in and out, it's not useful to keep old drawing
401 // sections, as scale will be changed.
404 *Time_Window
= *New_Time_Window
;
405 g_critical("New time window HOOK : %u, %u to %u, %u",
406 Time_Window
->start_time
.tv_sec
,
407 Time_Window
->start_time
.tv_nsec
,
408 Time_Window
->time_width
.tv_sec
,
409 Time_Window
->time_width
.tv_nsec
);
411 Drawing_Data_Request(Control_Flow_Data
->Drawing
,
412 &Control_Flow_Data
->Drawing
->Pixmap
,
414 Control_Flow_Data
->Drawing
->width
,
415 Control_Flow_Data
->Drawing
->height
);
417 Drawing_Refresh(Control_Flow_Data
->Drawing
,
419 Control_Flow_Data
->Drawing
->width
,
420 Control_Flow_Data
->Drawing
->height
);
424 void Update_Current_Time_Hook(void *hook_data
, void *call_data
)
426 ControlFlowData
*Control_Flow_Data
= (ControlFlowData
*) hook_data
;
427 LttTime
* Current_Time
=
428 GuiControlFlow_get_Current_Time(Control_Flow_Data
);
429 *Current_Time
= *((LttTime
*)call_data
);
430 g_critical("New Current time HOOK : %u, %u", Current_Time
->tv_sec
,
431 Current_Time
->tv_nsec
);
433 /* If current time is inside time interval, just move the highlight
436 /* Else, we have to change the time interval. We have to tell it
437 * to the main window. */
438 /* The time interval change will take care of placing the current
439 * time at the center of the visible area */