1 /*****************************************************************************
2 * Hooks to be called by the main window *
3 *****************************************************************************/
10 #include <lttv/hook.h>
11 #include <lttv/common.h>
13 #include "Event_Hooks.h"
15 #include "Process_List.h"
17 #include "CFV-private.h"
20 /* NOTE : no drawing data should be sent there, as the drawing widget
21 * has not been initialized */
22 void send_test_drawing(ProcessList
*Process_List
,
25 gint x
, gint y
, // y not used here?
27 gint height
) // height won't be used here ?
30 ProcessInfo Process_Info
= {10000, 12000, 55600};
31 //ProcessInfo Process_Info = {156, 14000, 55500};
32 GtkTreeRowReference
*got_RowRef
;
36 birth
.tv_nsec
= 55500;
37 g_critical("we have : x : %u, y : %u, width : %u, height : %u", x
, y
, width
, height
);
38 ProcessList_get_process_pixels(Process_List
,
44 g_critical("we draw : x : %u, y : %u, width : %u, height : %u", x
, y
, width
, height
);
47 y
+(height
/2), x
+ width
, y
+(height
/2),
48 Drawing
->Drawing_Area_V
->style
->black_gc
);
51 birth
.tv_nsec
= 55500;
53 ProcessList_get_process_pixels(Process_List
,
62 y
+(height
/2), x
+ width
, y
+(height
/2),
63 Drawing
->Drawing_Area_V
->style
->black_gc
);
65 g_critical("y : %u, height : %u", y
, height
);
68 birth
.tv_nsec
= 55700;
70 ProcessList_get_process_pixels(Process_List
,
79 y
+(height
/2), x
+ width
, y
+(height
/2),
80 Drawing
->Drawing_Area_V
->style
->black_gc
);
82 g_critical("y : %u, height : %u", y
, height
);
86 birth
.tv_sec
= i
*12000;
87 birth
.tv_nsec
= i
*55700;
89 ProcessList_get_process_pixels(Process_List
,
98 y
+(height
/2), x
+ width
, y
+(height
/2),
99 Drawing
->Drawing_Area_V
->style
->black_gc
);
101 g_critical("y : %u, height : %u", y
, height
);
105 birth
.tv_sec
= 12000;
106 birth
.tv_nsec
= 55600;
108 ProcessList_get_process_pixels(Process_List
,
117 y
+(height
/2), x
+ width
, y
+(height
/2),
118 Drawing
->Drawing_Area_V
->style
->black_gc
);
120 g_critical("y : %u, height : %u", y
, height
);
124 void send_test_process(ProcessList
*Process_List
, Drawing_t
*Drawing
)
128 ProcessInfo Process_Info
= {10000, 12000, 55600};
129 //ProcessInfo Process_Info = {156, 14000, 55500};
130 GtkTreeRowReference
*got_RowRef
;
134 if(Process_List
->Test_Process_Sent
) return;
136 birth
.tv_sec
= 12000;
137 birth
.tv_nsec
= 55500;
139 ProcessList_add(Process_List
,
143 ProcessList_get_process_pixels(Process_List
,
148 Drawing_Insert_Square( Drawing
, y
, height
);
150 //g_critical("y : %u, height : %u", y, height);
152 birth
.tv_sec
= 14000;
153 birth
.tv_nsec
= 55500;
155 ProcessList_add(Process_List
,
159 ProcessList_get_process_pixels(Process_List
,
164 Drawing_Insert_Square( Drawing
, y
, height
);
166 //g_critical("y : %u, height : %u", y, height);
168 birth
.tv_sec
= 12000;
169 birth
.tv_nsec
= 55700;
171 ProcessList_add(Process_List
,
175 ProcessList_get_process_pixels(Process_List
,
180 Drawing_Insert_Square( Drawing
, y
, height
);
182 //g_critical("y : %u, height : %u", y, height);
184 //Drawing_Insert_Square( Drawing, height, 5);
188 birth
.tv_sec
= i
*12000;
189 birth
.tv_nsec
= i
*55700;
191 ProcessList_add(Process_List
,
195 ProcessList_get_process_pixels(Process_List
,
200 Drawing_Insert_Square( Drawing
, y
, height
);
202 // g_critical("y : %u, height : %u", y, height);
205 //g_critical("height : %u", height);
207 birth
.tv_sec
= 12000;
208 birth
.tv_nsec
= 55600;
210 ProcessList_add(Process_List
,
214 ProcessList_get_process_pixels(Process_List
,
219 Drawing_Insert_Square( Drawing
, y
, height
);
221 //g_critical("y : %u, height : %u", y, height);
223 ProcessList_add(Process_List
,
227 ProcessList_get_process_pixels(Process_List
,
232 Drawing_Insert_Square( Drawing
, y
, height
);
234 //g_critical("y : %u, height : %u", y, height);
236 //Drawing_Insert_Square( Drawing, height, 5);
237 //g_critical("height : %u", height);
240 ProcessList_get_process_pixels(Process_List
,
244 ProcessList_remove( Process_List
,
248 Drawing_Remove_Square( Drawing
, y
, height
);
251 (GtkTreeRowReference
*)g_hash_table_lookup(
252 Process_List
->Process_Hash
,
255 g_critical("key found");
256 g_critical("position in the list : %s",
257 gtk_tree_path_to_string (
258 gtk_tree_row_reference_get_path(
259 (GtkTreeRowReference
*)got_RowRef
)
264 Process_List
->Test_Process_Sent
= TRUE
;
271 * Event Viewer's constructor hook
273 * This constructor is given as a parameter to the menuitem and toolbar button
274 * registration. It creates the list.
275 * @param pmParentWindow A pointer to the parent window.
276 * @return The widget created.
279 hGuiControlFlow(mainWindow
*pmParentWindow
)
281 g_critical("hGuiControlFlow");
282 ControlFlowData
*Control_Flow_Data
= GuiControlFlow() ;
284 GetTimeWindow(pmParentWindow
,
285 GuiControlFlow_get_Time_Window(Control_Flow_Data
));
286 GetCurrentTime(pmParentWindow
,
287 GuiControlFlow_get_Current_Time(Control_Flow_Data
));
289 // Unreg done in the GuiControlFlow_Destructor
290 RegUpdateTimeWindow(Update_Time_Window_Hook
, Control_Flow_Data
,
292 RegUpdateCurrentTime(Update_Current_Time_Hook
, Control_Flow_Data
,
294 return GuiControlFlow_get_Widget(Control_Flow_Data
) ;
298 int Event_Selected_Hook(void *hook_data
, void *call_data
)
300 ControlFlowData
*Control_Flow_Data
= (ControlFlowData
*) hook_data
;
301 guint
*Event_Number
= (guint
*) call_data
;
303 g_critical("DEBUG : event selected by main window : %u", *Event_Number
);
305 // Control_Flow_Data->Currently_Selected_Event = *Event_Number;
306 // Control_Flow_Data->Selected_Event = TRUE ;
308 // Tree_V_set_cursor(Control_Flow_Data);
313 /* Hook called before drawing. Gets the initial context at the beginning of the
314 * drawing interval and copy it to the context in Event_Request.
316 int Draw_Before_Hook(void *hook_data
, void *call_data
)
318 EventRequest
*Event_Request
= (EventRequest
*)hook_data
;
319 EventsContext Events_Context
= (EventsContext
*)call_data
;
321 Event_Request
->Events_Context
= Events_Context
;
327 * The draw event hook is called by the reading API to have a
328 * particular event drawn on the screen.
329 * @param hook_data ControlFlowData structure of the viewer.
330 * @param call_data Event context.
332 * This function basically draw lines and icons. Two types of lines are drawn :
333 * one small (3 pixels?) representing the state of the process and the second
334 * type is thicker (10 pixels?) representing on which CPU a process is running
335 * (and this only in running state).
337 * Extremums of the lines :
338 * x_min : time of the last event context for this process kept in memory.
339 * x_max : time of the current event.
340 * y : middle of the process in the process list. The process is found in the
341 * list, therefore is it's position in pixels.
343 * The choice of lines'color is defined by the context of the last event for this
346 int Draw_Event_Hook(void *hook_data
, void *call_data
)
348 EventRequest
*Event_Request
= (EventRequest
*)hook_data
;
354 int Draw_After_Hook(void *hook_data
, void *call_data
)
356 EventRequest
*Event_Request
= (EventRequest
*)hook_data
;
358 g_free(Event_Request
);
366 void Update_Time_Window_Hook(void *hook_data
, void *call_data
)
368 ControlFlowData
*Control_Flow_Data
= (ControlFlowData
*) hook_data
;
369 TimeWindow
* Time_Window
=
370 GuiControlFlow_get_Time_Window(Control_Flow_Data
);
371 TimeWindow
*New_Time_Window
= ((TimeWindow
*)call_data
);
373 // As the time interval change will mostly be used for
374 // zoom in and out, it's not useful to keep old drawing
375 // sections, as scale will be changed.
378 *Time_Window
= *New_Time_Window
;
379 g_critical("New time window HOOK : %u, %u to %u, %u",
380 Time_Window
->startTime
.tv_sec
,
381 Time_Window
->startTime
.tv_nsec
,
382 Time_Window
->Time_Width
.tv_sec
,
383 Time_Window
->Time_Width
.tv_nsec
);
385 Drawing_Data_Request(Control_Flow_Data
->Drawing
,
386 &Control_Flow_Data
->Drawing
->Pixmap
,
388 Control_Flow_Data
->Drawing
->width
,
389 Control_Flow_Data
->Drawing
->height
);
391 Drawing_Refresh(Control_Flow_Data
->Drawing
,
393 Control_Flow_Data
->Drawing
->width
,
394 Control_Flow_Data
->Drawing
->height
);
398 void Update_Current_Time_Hook(void *hook_data
, void *call_data
)
400 ControlFlowData
*Control_Flow_Data
= (ControlFlowData
*) hook_data
;
401 LttTime
* Current_Time
=
402 GuiControlFlow_get_Current_Time(Control_Flow_Data
);
403 *Current_Time
= *((LttTime
*)call_data
);
404 g_critical("New Current time HOOK : %u, %u", Current_Time
->tv_sec
,
405 Current_Time
->tv_nsec
);
407 /* If current time is inside time interval, just move the highlight
410 /* Else, we have to change the time interval. We have to tell it
411 * to the main window. */
412 /* The time interval change will take care of placing the current
413 * time at the center of the visible area */