1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Mathieu Desnoyers
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
27 #include <ltt/trace.h>
29 #include <lttv/lttv.h>
30 #include <lttv/tracecontext.h>
31 #include <lttvwindow/lttvwindow.h>
32 #include <lttv/state.h>
33 #include <lttv/hook.h>
36 #include "eventhooks.h"
39 //#define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
40 //#define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
43 // fixed #define TRACE_NUMBER 0
44 #define EXTRA_ALLOC 1024 // pixels
47 #if 0 /* colors for two lines representation */
48 GdkColor drawing_colors
[NUM_COLORS
] =
49 { /* Pixel, R, G, B */
50 { 0, 0, 0, 0 }, /* COL_BLACK */
51 { 0, 0xFFFF, 0xFFFF, 0xFFFF }, /* COL_WHITE */
52 { 0, 0x0FFF, 0xFFFF, 0xFFFF }, /* COL_WAIT_FORK : pale blue */
53 { 0, 0xFFFF, 0xFFFF, 0x0000 }, /* COL_WAIT_CPU : yellow */
54 { 0, 0xFFFF, 0xA000, 0xFCFF }, /* COL_EXIT : pale magenta */
55 { 0, 0xFFFF, 0x0000, 0xFFFF }, /* COL_ZOMBIE : purple */
56 { 0, 0xFFFF, 0x0000, 0x0000 }, /* COL_WAIT : red */
57 { 0, 0x0000, 0xFFFF, 0x0000 }, /* COL_RUN : green */
58 { 0, 0x8800, 0xFFFF, 0x8A00 }, /* COL_USER_MODE : pale green */
59 { 0, 0x09FF, 0x01FF, 0xFFFF }, /* COL_SYSCALL : blue */
60 { 0, 0xF900, 0x4200, 0xFF00 }, /* COL_TRAP : pale purple */
61 { 0, 0xFFFF, 0x5AFF, 0x01FF }, /* COL_IRQ : orange */
62 { 0, 0xFFFF, 0xFFFF, 0xFFFF } /* COL_MODE_UNKNOWN : white */
68 GdkColor drawing_colors
[NUM_COLORS
] =
69 { /* Pixel, R, G, B */
70 { 0, 0, 0, 0 }, /* COL_BLACK */
71 { 0, 0xFFFF, 0xFFFF, 0xFFFF }, /* COL_WHITE */
72 { 0, 0x0000, 0xFF00, 0x0000 }, /* COL_RUN_USER_MODE : green */
73 { 0, 0x0100, 0x9E00, 0xFFFF }, /* COL_RUN_SYSCALL : pale blue */
74 { 0, 0xFF00, 0xFF00, 0x0100 }, /* COL_RUN_TRAP : yellow */
75 { 0, 0xFFFF, 0x5E00, 0x0000 }, /* COL_RUN_IRQ : orange */
76 { 0, 0xFFFF, 0x9400, 0x9600 }, /* COL_RUN_SOFT_IRQ : pink */
77 { 0, 0x6600, 0x0000, 0x0000 }, /* COL_WAIT : dark red */
78 { 0, 0x7700, 0x7700, 0x0000 }, /* COL_WAIT_CPU : dark yellow */
79 { 0, 0x6400, 0x0000, 0x5D00 }, /* COL_ZOMBIE : dark purple */
80 { 0, 0x0700, 0x6400, 0x0000 }, /* COL_WAIT_FORK : dark green */
81 { 0, 0x8900, 0x0000, 0x8400 }, /* COL_EXIT : "less dark" magenta */
82 { 0, 0xFFFF, 0xFFFF, 0xFFFF }, /* COL_MODE_UNKNOWN : white */
83 { 0, 0xFFFF, 0xFFFF, 0xFFFF } /* COL_UNNAMED : white */
87 GdkColor drawing_colors_cpu
[NUM_COLORS_CPU
] =
88 { /* Pixel, R, G, B */
89 { 0, 0x0000, 0x0000, 0x0000 }, /* COL_CPU_UNKNOWN */
90 { 0, 0xBBBB, 0xBBBB, 0xBBBB }, /* COL_CPU_IDLE */
91 { 0, 0xFFFF, 0xFFFF, 0xFFFF }, /* COL_CPU_BUSY */
92 { 0, 0xFFFF, 0x5E00, 0x0000 }, /* COL_CPU_IRQ */
93 { 0, 0xFF00, 0xFF00, 0x0100 }, /* COL_CPU_TRAP */
96 GdkColor drawing_colors_irq
[NUM_COLORS_IRQ
] =
97 { /* Pixel, R, G, B */
98 { 0, 0x0000, 0x0000, 0x0000 }, /* COL_IRQ_UNKNOWN */
99 { 0, 0xBBBB, 0xBBBB, 0xBBBB }, /* COL_IRQ_IDLE */
100 { 0, 0xFFFF, 0x5E00, 0x0000 }, /* COL_IRQ_BUSY */
103 GdkColor drawing_colors_bdev
[NUM_COLORS_BDEV
] =
104 { /* Pixel, R, G, B */
105 { 0, 0x0000, 0x0000, 0x0000 }, /* COL_BDEV_UNKNOWN */
106 { 0, 0xBBBB, 0xBBBB, 0xBBBB }, /* COL_BDEV_IDLE */
107 { 0, 0x0000, 0x0000, 0xFFFF }, /* COL_BDEV_BUSY_READING */
108 { 0, 0xFFFF, 0x0000, 0x0000 }, /* COL_BDEV_BUSY_WRITING */
111 /*****************************************************************************
112 * drawing functions *
113 *****************************************************************************/
116 expose_ruler( GtkWidget
*widget
, GdkEventExpose
*event
, gpointer user_data
);
119 motion_notify_ruler(GtkWidget
*widget
, GdkEventMotion
*event
, gpointer user_data
);
122 /* Function responsible for updating the exposed area.
123 * It must do an events request to the lttvwindow API to ask for this update.
124 * Note : this function cannot clear the background, because it may
125 * erase drawing already present (SAFETY).
127 void drawing_data_request(Drawing_t
*drawing
,
132 if(width
< 0) return ;
133 if(height
< 0) return ;
136 Tab
*tab
= drawing
->control_flow_data
->tab
;
137 TimeWindow time_window
=
138 lttvwindow_get_time_window(tab
);
140 ControlFlowData
*control_flow_data
= drawing
->control_flow_data
;
141 // (ControlFlowData*)g_object_get_data(
142 // G_OBJECT(drawing->drawing_area), "control_flow_data");
144 LttTime start
, time_end
;
145 LttTime window_end
= time_window
.end_time
;
147 g_debug("req : window start_time : %lu, %lu", time_window
.start_time
.tv_sec
,
148 time_window
.start_time
.tv_nsec
);
150 g_debug("req : window time width : %lu, %lu", time_window
.time_width
.tv_sec
,
151 time_window
.time_width
.tv_nsec
);
153 g_debug("req : window_end : %lu, %lu", window_end
.tv_sec
,
156 g_debug("x is : %i, x+width is : %i", x
, x
+width
);
158 convert_pixels_to_time(drawing
->width
, x
,
162 convert_pixels_to_time(drawing
->width
, x
+width
,
165 time_end
= ltt_time_add(time_end
, ltt_time_one
); // because main window
166 // doesn't deliver end time.
168 lttvwindow_events_request_remove_all(tab
,
172 /* find the tracehooks */
173 LttvTracesetContext
*tsc
= lttvwindow_get_traceset_context(tab
);
175 LttvTraceset
*traceset
= tsc
->ts
;
177 guint i
, k
, l
, nb_trace
;
181 LttvTracefileState
*tfs
;
187 LttvTraceHookByFacility
*thf
;
190 gint before_hn
, after_hn
;
192 nb_trace
= lttv_traceset_number(traceset
);
193 // FIXME (fixed) : eventually request for more traces
194 for(i
= 0 ; i
< nb_trace
; i
++) {
195 //for(i = 0; i<MIN(TRACE_NUMBER+1, nb_trace);i++) {
196 EventsRequest
*events_request
= g_new(EventsRequest
, 1);
198 //LttvHooks *event = lttv_hooks_new();
199 LttvHooksById
*event_by_id
= lttv_hooks_by_id_new();
200 LttvHooks
*before_chunk_traceset
= lttv_hooks_new();
201 LttvHooks
*after_chunk_traceset
= lttv_hooks_new();
202 LttvHooks
*before_request_hook
= lttv_hooks_new();
203 LttvHooks
*after_request_hook
= lttv_hooks_new();
205 lttv_hooks_add(before_chunk_traceset
,
210 lttv_hooks_add(after_chunk_traceset
,
215 lttv_hooks_add(before_request_hook
,
220 lttv_hooks_add(after_request_hook
,
226 ts
= (LttvTraceState
*)tsc
->traces
[i
];
228 /* Find the eventtype id for the following events and register the
229 associated by id hooks. */
231 hooks
= g_array_new(FALSE
, FALSE
, sizeof(LttvTraceHook
));
232 hooks
= g_array_set_size(hooks
, 18);
233 before_hn
= after_hn
= 0;
237 // ret = lttv_trace_find_hook(ts->parent.t,
238 // LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_ENTRY,
239 // LTT_FIELD_SYSCALL_ID, 0, 0,
240 // before_execmode_hook,
242 // &g_array_index(hooks, LttvTraceHook, before_hn++));
243 // if(ret) before_hn--;
245 // ret = lttv_trace_find_hook(ts->parent.t,
246 // LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_EXIT,
248 // before_execmode_hook,
250 // &g_array_index(hooks, LttvTraceHook, before_hn++));
251 // if(ret) before_hn--;
253 ret
= lttv_trace_find_hook(ts
->parent
.t
,
254 LTT_FACILITY_KERNEL_ARCH
, LTT_EVENT_TRAP_ENTRY
,
255 LTT_FIELD_TRAP_ID
, 0, 0,
256 before_execmode_hook
,
258 &g_array_index(hooks
, LttvTraceHook
, before_hn
++));
261 ret
= lttv_trace_find_hook(ts
->parent
.t
,
262 LTT_FACILITY_KERNEL_ARCH
, LTT_EVENT_TRAP_EXIT
,
264 before_execmode_hook
,
266 &g_array_index(hooks
, LttvTraceHook
, before_hn
++));
269 ret
= lttv_trace_find_hook(ts
->parent
.t
,
270 LTT_FACILITY_KERNEL
, LTT_EVENT_IRQ_ENTRY
,
271 LTT_FIELD_IRQ_ID
, 0, 0,
272 before_execmode_hook
,
274 &g_array_index(hooks
, LttvTraceHook
, before_hn
++));
277 ret
= lttv_trace_find_hook(ts
->parent
.t
,
278 LTT_FACILITY_KERNEL
, LTT_EVENT_IRQ_EXIT
,
280 before_execmode_hook
,
282 &g_array_index(hooks
, LttvTraceHook
, before_hn
++));
285 // ret = lttv_trace_find_hook(ts->parent.t,
286 // LTT_FACILITY_KERNEL, LTT_EVENT_SOFT_IRQ_ENTRY,
287 // LTT_FIELD_SOFT_IRQ_ID, 0, 0,
288 // before_execmode_hook,
290 // &g_array_index(hooks, LttvTraceHook, before_hn++));
291 // if(ret) before_hn--;
293 // ret = lttv_trace_find_hook(ts->parent.t,
294 // LTT_FACILITY_KERNEL, LTT_EVENT_SOFT_IRQ_EXIT,
296 // before_execmode_hook,
298 // &g_array_index(hooks, LttvTraceHook, before_hn++));
299 // if(ret) before_hn--;
302 ret
= lttv_trace_find_hook(ts
->parent
.t
,
303 LTT_FACILITY_KERNEL
, LTT_EVENT_SCHED_SCHEDULE
,
304 LTT_FIELD_PREV_PID
, LTT_FIELD_NEXT_PID
, LTT_FIELD_PREV_STATE
,
305 before_schedchange_hook
,
307 &g_array_index(hooks
, LttvTraceHook
, before_hn
++));
310 // ret = lttv_trace_find_hook(ts->parent.t,
311 // LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_EXIT,
312 // LTT_FIELD_PID, 0, 0,
313 // before_process_exit_hook,
315 // &g_array_index(hooks, LttvTraceHook, before_hn++));
316 // if(ret) before_hn--;
318 // ret = lttv_trace_find_hook(ts->parent.t,
319 // LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_FREE,
320 // LTT_FIELD_PID, 0, 0,
321 // before_process_release_hook,
323 // &g_array_index(hooks, LttvTraceHook, before_hn++));
324 // if(ret) before_hn--;
326 // ret = lttv_trace_find_hook(ts->parent.t,
327 // LTT_FACILITY_LIST, LTT_EVENT_STATEDUMP_END,
329 // before_statedump_end,
331 // &g_array_index(hooks, LttvTraceHook, before_hn++));
332 // if(ret) before_hn--;
335 lttv_trace_find_hook(ts
->parent
.t
,
336 "core", "process", "event_sub_id",
337 "event_data1", "event_data2", before_process_hook
,
338 &g_array_index(hooks
, LttvTraceHook
, hn
++));
341 lttv_trace_find_hook(ts
->parent
.t
, "core", "process_fork", "child_pid",
342 NULL
, NULL
, process_fork
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
344 lttv_trace_find_hook(ts
->parent
.t
, "core", "process_exit", NULL
, NULL
,
345 NULL
, process_exit
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
351 /**** DESACTIVATED ****/
352 lttv_trace_find_hook(ts
->parent
.t
, "core","syscall_entry","syscall_id",
353 NULL
, NULL
, after_execmode_hook
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
354 /**** DESACTIVATED ****/
355 lttv_trace_find_hook(ts
->parent
.t
, "core", "syscall_exit", NULL
, NULL
,
356 NULL
, after_execmode_hook
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
358 /**** DESACTIVATED ****/
359 lttv_trace_find_hook(ts
->parent
.t
, "core", "trap_entry", "trap_id",
360 NULL
, NULL
, after_execmode_hook
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
362 /**** DESACTIVATED ****/
363 lttv_trace_find_hook(ts
->parent
.t
, "core", "trap_exit", NULL
, NULL
, NULL
,
364 after_execmode_hook
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
366 /**** DESACTIVATED ****/
367 lttv_trace_find_hook(ts
->parent
.t
, "core", "irq_entry", "irq_id", NULL
,
368 NULL
, after_execmode_hook
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
370 /**** DESACTIVATED ****/
371 lttv_trace_find_hook(ts
->parent
.t
, "core", "irq_exit", NULL
, NULL
, NULL
,
372 after_execmode_hook
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
375 lttv_trace_find_hook(ts
->parent
.t
, "core", "schedchange", "in", "out",
376 "out_state", after_schedchange_hook
,
377 &g_array_index(hooks
, LttvTraceHook
, hn
++));
379 lttv_trace_find_hook(ts
->parent
.t
, "core", "process", "event_sub_id",
380 "event_data1", "event_data2", after_process_hook
,
381 &g_array_index(hooks
, LttvTraceHook
, hn
++));
383 after_hn
= before_hn
;
385 ret
= lttv_trace_find_hook(ts
->parent
.t
,
386 LTT_FACILITY_KERNEL
, LTT_EVENT_SCHED_SCHEDULE
,
387 LTT_FIELD_PREV_PID
, LTT_FIELD_NEXT_PID
, LTT_FIELD_PREV_STATE
,
388 after_schedchange_hook
,
390 &g_array_index(hooks
, LttvTraceHook
, after_hn
++));
393 // ret = lttv_trace_find_hook(ts->parent.t,
394 // LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_FORK,
395 // LTT_FIELD_PARENT_PID, LTT_FIELD_CHILD_PID, 0,
396 // after_process_fork_hook,
398 // &g_array_index(hooks, LttvTraceHook, after_hn++));
399 // if(ret) after_hn--;
401 // ret = lttv_trace_find_hook(ts->parent.t,
402 // LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_EXIT,
403 // LTT_FIELD_PID, 0, 0,
404 // after_process_exit_hook,
406 // &g_array_index(hooks, LttvTraceHook, after_hn++));
407 // if(ret) after_hn--;
409 // ret = lttv_trace_find_hook(ts->parent.t,
410 // LTT_FACILITY_FS, LTT_EVENT_EXEC,
412 // after_fs_exec_hook,
414 // &g_array_index(hooks, LttvTraceHook, after_hn++));
415 // if(ret) after_hn--;
417 // ret = lttv_trace_find_hook(ts->parent.t,
418 // LTT_FACILITY_USER_GENERIC, LTT_EVENT_THREAD_BRAND,
419 // LTT_FIELD_NAME, 0, 0,
420 // after_user_generic_thread_brand_hook,
422 // &g_array_index(hooks, LttvTraceHook, after_hn++));
423 // if(ret) after_hn--;
425 // ret = lttv_trace_find_hook(ts->parent.t,
426 // LTT_FACILITY_LIST, LTT_EVENT_PROCESS_STATE,
427 // LTT_FIELD_PID, LTT_FIELD_PARENT_PID, LTT_FIELD_NAME,
428 // after_event_enum_process_hook,
430 // &g_array_index(hooks, LttvTraceHook, after_hn++));
431 // if(ret) after_hn--;
433 ret
= lttv_trace_find_hook(ts
->parent
.t
,
434 LTT_FACILITY_BLOCK
, LTT_EVENT_REQUEST_ISSUE
,
435 LTT_FIELD_MAJOR
, LTT_FIELD_MINOR
, LTT_FIELD_OPERATION
,
436 before_bdev_event_hook
,
438 &g_array_index(hooks
, LttvTraceHook
, after_hn
++));
441 ret
= lttv_trace_find_hook(ts
->parent
.t
,
442 LTT_FACILITY_BLOCK
, LTT_EVENT_REQUEST_COMPLETE
,
443 LTT_FIELD_MAJOR
, LTT_FIELD_MINOR
, LTT_FIELD_OPERATION
,
444 before_bdev_event_hook
,
446 &g_array_index(hooks
, LttvTraceHook
, after_hn
++));
449 hooks
= g_array_set_size(hooks
, after_hn
);
452 lttv_trace_find_hook(ts
->parent
.t
, "core", "process_fork", "child_pid",
453 NULL
, NULL
, process_fork
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
455 lttv_trace_find_hook(ts
->parent
.t
, "core", "process_exit", NULL
, NULL
,
456 NULL
, process_exit
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
461 /* Add these hooks to each event_by_id hooks list */
463 for(k
= 0 ; k
< before_hn
; k
++) {
464 hook
= &g_array_index(hooks
, LttvTraceHook
, k
);
465 for(l
=0;l
<hook
->fac_list
->len
;l
++) {
466 thf
= g_array_index(hook
->fac_list
, LttvTraceHookByFacility
*, l
);
467 lttv_hooks_add(lttv_hooks_by_id_find(event_by_id
, thf
->id
),
475 for(k
= before_hn
; k
< after_hn
; k
++) {
476 hook
= &g_array_index(hooks
, LttvTraceHook
, k
);
477 for(l
=0;l
<hook
->fac_list
->len
;l
++) {
478 thf
= g_array_index(hook
->fac_list
, LttvTraceHookByFacility
*, l
);
479 lttv_hooks_add(lttv_hooks_by_id_find(event_by_id
, thf
->id
),
486 events_request
->hooks
= hooks
;
488 // Fill the events request
489 events_request
->owner
= control_flow_data
;
490 events_request
->viewer_data
= control_flow_data
;
491 events_request
->servicing
= FALSE
;
492 events_request
->start_time
= start
;
493 events_request
->start_position
= NULL
;
494 events_request
->stop_flag
= FALSE
;
495 events_request
->end_time
= time_end
;
496 events_request
->num_events
= G_MAXUINT
;
497 events_request
->end_position
= NULL
;
498 events_request
->trace
= i
; //fixed /* FIXME */
499 events_request
->before_chunk_traceset
= before_chunk_traceset
;
500 events_request
->before_chunk_trace
= NULL
;
501 events_request
->before_chunk_tracefile
= NULL
;
502 events_request
->event
= NULL
;
503 events_request
->event_by_id
= event_by_id
;
504 events_request
->after_chunk_tracefile
= NULL
;
505 events_request
->after_chunk_trace
= NULL
;
506 events_request
->after_chunk_traceset
= after_chunk_traceset
;
507 events_request
->before_request
= before_request_hook
;
508 events_request
->after_request
= after_request_hook
;
510 g_debug("req : start : %lu, %lu", start
.tv_sec
,
513 g_debug("req : end : %lu, %lu", time_end
.tv_sec
,
516 lttvwindow_events_request(tab
, events_request
);
523 lttv_hooks_add(event
,
524 before_schedchange_hook
,
527 lttv_hooks_add(event
,
528 after_schedchange_hook
,
531 lttv_hooks_add(event
,
532 before_execmode_hook
,
535 lttv_hooks_add(event
,
539 lttv_hooks_add(event
,
543 lttv_hooks_add(event
,
552 static void set_last_start(gpointer key
, gpointer value
, gpointer user_data
)
554 ResourceInfo
*process_info
= (ResourceInfo
*)key
;
555 HashedResourceData
*hashed_process_data
= (HashedResourceData
*)value
;
556 guint x
= (guint
)user_data
;
558 hashed_process_data
->x
.over
= x
;
559 hashed_process_data
->x
.over_used
= FALSE
;
560 hashed_process_data
->x
.over_marked
= FALSE
;
561 hashed_process_data
->x
.middle
= x
;
562 hashed_process_data
->x
.middle_used
= FALSE
;
563 hashed_process_data
->x
.middle_marked
= FALSE
;
564 hashed_process_data
->x
.under
= x
;
565 hashed_process_data
->x
.under_used
= FALSE
;
566 hashed_process_data
->x
.under_marked
= FALSE
;
567 hashed_process_data
->next_good_time
= ltt_time_zero
;
572 void drawing_data_request_begin(EventsRequest
*events_request
, LttvTracesetState
*tss
)
574 g_debug("Begin of data request");
575 ControlFlowData
*cfd
= events_request
->viewer_data
;
576 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(tss
);
577 TimeWindow time_window
=
578 lttvwindow_get_time_window(cfd
->tab
);
580 guint width
= cfd
->drawing
->width
;
583 cfd
->drawing
->last_start
= events_request
->start_time
;
585 convert_time_to_pixels(
587 events_request
->start_time
,
591 g_hash_table_foreach(cfd
->process_list
->process_hash
, set_last_start
,
596 void drawing_chunk_begin(EventsRequest
*events_request
, LttvTracesetState
*tss
)
598 g_debug("Begin of chunk");
599 ControlFlowData
*cfd
= events_request
->viewer_data
;
600 LttvTracesetContext
*tsc
= &tss
->parent
.parent
;
601 //LttTime current_time = lttv_traceset_context_get_current_tfc(tsc)->timestamp;
603 LttvTraceset
*traceset
= tsc
->ts
;
604 guint nb_trace
= lttv_traceset_number(traceset
);
606 if(!cfd
->process_list
->current_hash_data
) {
607 cfd
->process_list
->current_hash_data
= g_new(HashedResourceData
**,nb_trace
);
608 for(i
= 0 ; i
< nb_trace
; i
++) {
609 guint num_cpu
= ltt_trace_get_num_cpu(tss
->parent
.traces
[i
]->t
);
610 cfd
->process_list
->current_hash_data
[i
] = g_new(HashedResourceData
*,num_cpu
);
611 memset(cfd
->process_list
->current_hash_data
[i
], 0,
612 sizeof(HashedResourceData
*)*num_cpu
);
615 //cfd->drawing->last_start = LTT_TIME_MIN(current_time,
616 // events_request->end_time);
620 void drawing_request_expose(EventsRequest
*events_request
,
621 LttvTracesetState
*tss
,
627 ControlFlowData
*cfd
= events_request
->viewer_data
;
628 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)tss
;
629 Drawing_t
*drawing
= cfd
->drawing
;
631 TimeWindow time_window
=
632 lttvwindow_get_time_window(cfd
->tab
);
634 g_debug("request expose");
636 convert_time_to_pixels(
641 x
= drawing
->damage_begin
;
645 drawing
->damage_begin
= x
+width
;
648 gtk_widget_queue_draw_area ( drawing
->drawing_area
,
650 width
, drawing
->drawing_area
->allocation
.height
);
652 /* Update directly when scrolling */
653 gdk_window_process_updates(drawing
->drawing_area
->window
,
661 /* Create a new backing pixmap of the appropriate size */
662 /* As the scaling will always change, it's of no use to copy old
665 * Only change the size if width changes. The height is specified and changed
666 * when process ID are added or removed from the process list.
669 configure_event( GtkWidget
*widget
, GdkEventConfigure
*event
,
672 Drawing_t
*drawing
= (Drawing_t
*)user_data
;
675 /* First, get the new time interval of the main window */
676 /* we assume (see documentation) that the main window
677 * has updated the time interval before this configure gets
680 //lttvwindow_get_time_window(drawing->control_flow_data->mw,
681 // &drawing->control_flow_data->time_window);
683 /* New pixmap, size of the configure event */
684 //GdkPixmap *pixmap = gdk_pixmap_new(widget->window,
685 // widget->allocation.width + SAFETY,
686 // widget->allocation.height + SAFETY,
689 if(widget
->allocation
.width
!= drawing
->width
) {
690 g_debug("drawing configure event");
691 g_debug("New alloc draw size : %i by %i",widget
->allocation
.width
,
692 widget
->allocation
.height
);
694 drawing
->width
= widget
->allocation
.width
;
696 if(drawing
->alloc_width
< widget
->allocation
.width
) {
697 //if(drawing->pixmap)
698 // gdk_pixmap_unref(drawing->pixmap);
700 //drawing->pixmap = gdk_pixmap_new(widget->window,
701 // drawing->width + SAFETY + EXTRA_ALLOC,
702 // drawing->height + EXTRA_ALLOC,
704 drawing
->alloc_width
= drawing
->width
+ SAFETY
+ EXTRA_ALLOC
;
705 drawing
->alloc_height
= drawing
->height
+ EXTRA_ALLOC
;
706 update_pixmap_size(drawing
->control_flow_data
->process_list
,
707 drawing
->alloc_width
);
708 update_index_to_pixmap(drawing
->control_flow_data
->process_list
);
710 //drawing->height = widget->allocation.height;
712 //ProcessList_get_height
713 // (GuiControlFlow_get_process_list(drawing->control_flow_data)),
717 //gdk_draw_rectangle (drawing->pixmap,
718 // widget->style->black_gc,
721 // drawing->width+SAFETY,
724 //g_info("init data request");
727 /* Initial data request */
728 /* no, do initial data request in the expose event */
729 // Do not need to ask for data of 1 pixel : not synchronized with
730 // main window time at this moment.
731 //drawing_data_request(drawing, &drawing->pixmap, 0, 0,
732 // widget->allocation.width,
733 // widget->allocation.height);
735 //drawing->width = widget->allocation.width;
736 //drawing->height = widget->allocation.height;
738 drawing
->damage_begin
= 0;
739 drawing
->damage_end
= widget
->allocation
.width
;
741 if((widget
->allocation
.width
!= 1 &&
742 widget
->allocation
.height
!= 1)
743 && drawing
->damage_begin
< drawing
->damage_end
)
746 rectangle_pixmap (drawing
->control_flow_data
->process_list
,
747 drawing
->drawing_area
->style
->black_gc
,
750 drawing
->alloc_width
, // do not overlap
754 drawing_data_request(drawing
,
755 drawing
->damage_begin
,
757 drawing
->damage_end
- drawing
->damage_begin
,
765 /* Redraw the screen from the backing pixmap */
767 expose_event( GtkWidget
*widget
, GdkEventExpose
*event
, gpointer user_data
)
769 Drawing_t
*drawing
= (Drawing_t
*)user_data
;
771 ControlFlowData
*control_flow_data
=
772 (ControlFlowData
*)g_object_get_data(
774 "control_flow_data");
776 if(unlikely(drawing
->gc
== NULL
)) {
777 drawing
->gc
= gdk_gc_new(drawing
->drawing_area
->window
);
778 gdk_gc_copy(drawing
->gc
, drawing
->drawing_area
->style
->black_gc
);
781 TimeWindow time_window
=
782 lttvwindow_get_time_window(control_flow_data
->tab
);
783 LttTime current_time
=
784 lttvwindow_get_current_time(control_flow_data
->tab
);
788 LttTime window_end
= time_window
.end_time
;
790 /* update the screen from the pixmap buffer */
792 gdk_draw_pixmap(widget
->window
,
793 widget
->style
->fg_gc
[GTK_WIDGET_STATE (widget
)],
795 event
->area
.x
, event
->area
.y
,
796 event
->area
.x
, event
->area
.y
,
797 event
->area
.width
, event
->area
.height
);
799 drawing
->height
= processlist_get_height(control_flow_data
->process_list
);
801 copy_pixmap_to_screen(control_flow_data
->process_list
,
803 widget
->style
->fg_gc
[GTK_WIDGET_STATE (widget
)],
804 event
->area
.x
, event
->area
.y
,
805 event
->area
.width
, event
->area
.height
);
807 copy_pixmap_to_screen(control_flow_data
->process_list
,
810 event
->area
.x
, event
->area
.y
,
811 event
->area
.width
, event
->area
.height
);
814 /* Erase the dotted lines left.. */
815 if(widget
->allocation
.height
> drawing
->height
)
817 gdk_draw_rectangle (widget
->window
,
818 drawing
->drawing_area
->style
->black_gc
,
820 event
->area
.x
, drawing
->height
,
821 event
->area
.width
, // do not overlap
822 widget
->allocation
.height
- drawing
->height
);
824 if(ltt_time_compare(time_window
.start_time
, current_time
) <= 0 &&
825 ltt_time_compare(window_end
, current_time
) >= 0)
827 /* Draw the dotted lines */
828 convert_time_to_pixels(
835 if(drawing
->dotted_gc
== NULL
) {
837 drawing
->dotted_gc
= gdk_gc_new(drawing
->drawing_area
->window
);
838 gdk_gc_copy(drawing
->dotted_gc
, widget
->style
->white_gc
);
840 gint8 dash_list
[] = { 1, 2 };
841 gdk_gc_set_line_attributes(drawing
->dotted_gc
,
843 GDK_LINE_ON_OFF_DASH
,
846 gdk_gc_set_dashes(drawing
->dotted_gc
,
852 gint height_tot
= MAX(widget
->allocation
.height
, drawing
->height
);
853 gdk_draw_line(widget
->window
,
856 cursor_x
, height_tot
);
862 after_expose_event( GtkWidget
*widget
, GdkEventExpose
*event
, gpointer user_data
)
865 g_debug("AFTER EXPOSE");
874 tree_row_activated(GtkTreeModel
*treemodel
,
876 GtkTreeViewColumn
*arg2
,
879 ControlFlowData
*cfd
= (ControlFlowData
*)user_data
;
880 Drawing_t
*drawing
= cfd
->drawing
;
881 GtkTreeView
*treeview
= cfd
->process_list
->process_list_widget
;
885 path_indices
= gtk_tree_path_get_indices (arg1
);
887 height
= get_cell_height(cfd
->process_list
,
888 GTK_TREE_VIEW(treeview
));
889 drawing
->horizontal_sel
= height
* path_indices
[0];
890 g_critical("new hor sel : %i", drawing
->horizontal_sel
);
896 button_press_event( GtkWidget
*widget
, GdkEventButton
*event
, gpointer user_data
)
898 ControlFlowData
*control_flow_data
=
899 (ControlFlowData
*)g_object_get_data(
901 "control_flow_data");
902 Drawing_t
*drawing
= control_flow_data
->drawing
;
903 TimeWindow time_window
=
904 lttvwindow_get_time_window(control_flow_data
->tab
);
907 if(event
->button
== 1)
911 /* left mouse button click */
912 g_debug("x click is : %f", event
->x
);
914 convert_pixels_to_time(drawing
->width
, (guint
)event
->x
,
918 lttvwindow_report_current_time(control_flow_data
->tab
, time
);
926 scrollbar_size_allocate(GtkWidget
*widget
,
927 GtkAllocation
*allocation
,
930 Drawing_t
*drawing
= (Drawing_t
*)user_data
;
932 gtk_widget_set_size_request(drawing
->padding
, allocation
->width
, -1);
933 //gtk_widget_queue_resize(drawing->padding);
934 //gtk_widget_queue_resize(drawing->ruler);
935 gtk_container_check_resize(GTK_CONTAINER(drawing
->ruler_hbox
));
941 Drawing_t
*drawing_construct(ControlFlowData
*control_flow_data
)
943 Drawing_t
*drawing
= g_new(Drawing_t
, 1);
945 drawing
->control_flow_data
= control_flow_data
;
947 drawing
->vbox
= gtk_vbox_new(FALSE
, 1);
950 drawing
->ruler_hbox
= gtk_hbox_new(FALSE
, 1);
951 drawing
->ruler
= gtk_drawing_area_new ();
952 //gtk_widget_set_size_request(drawing->ruler, -1, 27);
954 drawing
->padding
= gtk_drawing_area_new ();
955 //gtk_widget_set_size_request(drawing->padding, -1, 27);
956 gtk_box_pack_start(GTK_BOX(drawing
->ruler_hbox
), drawing
->ruler
,
958 gtk_box_pack_end(GTK_BOX(drawing
->ruler_hbox
), drawing
->padding
,
963 drawing
->drawing_area
= gtk_drawing_area_new ();
967 drawing
->hbox
= gtk_hbox_new(FALSE
, 1);
968 drawing
->viewport
= gtk_viewport_new(NULL
, control_flow_data
->v_adjust
);
969 drawing
->scrollbar
= gtk_vscrollbar_new(control_flow_data
->v_adjust
);
970 gtk_box_pack_start(GTK_BOX(drawing
->hbox
), drawing
->viewport
,
972 gtk_box_pack_end(GTK_BOX(drawing
->hbox
), drawing
->scrollbar
,
975 //drawing->scrolled_window =
976 // gtk_scrolled_window_new (NULL,
977 // control_flow_data->v_adjust);
979 //gtk_scrolled_window_set_policy(
980 // GTK_SCROLLED_WINDOW(drawing->scrolled_window),
982 // GTK_POLICY_AUTOMATIC);
984 gtk_container_add(GTK_CONTAINER(drawing
->viewport
),
985 drawing
->drawing_area
);
986 //gtk_scrolled_window_add_with_viewport(
987 // GTK_SCROLLED_WINDOW(drawing->scrolled_window),
988 // drawing->drawing_area);
990 gtk_box_pack_start(GTK_BOX(drawing
->vbox
), drawing
->ruler_hbox
,
992 gtk_box_pack_end(GTK_BOX(drawing
->vbox
), drawing
->hbox
,
995 drawing
->pango_layout
=
996 gtk_widget_create_pango_layout(drawing
->drawing_area
, NULL
);
1001 drawing
->alloc_height
= 1;
1002 drawing
->alloc_width
= 1;
1004 drawing
->damage_begin
= 0;
1005 drawing
->damage_end
= 0;
1006 drawing
->horizontal_sel
= -1;
1008 //gtk_widget_set_size_request(drawing->drawing_area->window, 50, 50);
1009 g_object_set_data_full(
1010 G_OBJECT(drawing
->drawing_area
),
1011 "Link_drawing_Data",
1013 (GDestroyNotify
)drawing_destroy
);
1016 G_OBJECT(drawing
->ruler
),
1021 //gtk_widget_modify_bg( drawing->drawing_area,
1022 // GTK_STATE_NORMAL,
1023 // &CF_Colors[BLACK]);
1025 //gdk_window_get_geometry(drawing->drawing_area->window,
1027 // &(drawing->width),
1028 // &(drawing->height),
1031 //drawing->pixmap = gdk_pixmap_new(
1032 // drawing->drawing_area->window,
1037 //drawing->pixmap = NULL;
1039 // drawing->pixmap = gdk_pixmap_new(drawing->drawing_area->window,
1040 // drawing->drawing_area->allocation.width,
1041 // drawing->drawing_area->allocation.height,
1044 g_signal_connect (G_OBJECT(drawing
->drawing_area
),
1046 G_CALLBACK (configure_event
),
1049 g_signal_connect (G_OBJECT(drawing
->ruler
),
1051 G_CALLBACK(expose_ruler
),
1054 gtk_widget_add_events(drawing
->ruler
, GDK_POINTER_MOTION_MASK
);
1056 g_signal_connect (G_OBJECT(drawing
->ruler
),
1057 "motion-notify-event",
1058 G_CALLBACK(motion_notify_ruler
),
1062 g_signal_connect (G_OBJECT(drawing
->scrollbar
),
1064 G_CALLBACK(scrollbar_size_allocate
),
1069 g_signal_connect (G_OBJECT(drawing
->drawing_area
),
1071 G_CALLBACK (expose_event
),
1074 g_signal_connect_after (G_OBJECT(drawing
->drawing_area
),
1076 G_CALLBACK (after_expose_event
),
1079 g_signal_connect (G_OBJECT(drawing
->drawing_area
),
1080 "button-press-event",
1081 G_CALLBACK (button_press_event
),
1085 gtk_widget_show(drawing
->ruler
);
1086 gtk_widget_show(drawing
->padding
);
1087 gtk_widget_show(drawing
->ruler_hbox
);
1089 gtk_widget_show(drawing
->drawing_area
);
1090 //gtk_widget_show(drawing->scrolled_window);
1091 gtk_widget_show(drawing
->viewport
);
1092 gtk_widget_show(drawing
->scrollbar
);
1093 gtk_widget_show(drawing
->hbox
);
1095 /* Allocate the colors */
1096 GdkColormap
* colormap
= gdk_colormap_get_system();
1097 gboolean success
[NUM_COLORS
];
1098 gdk_colormap_alloc_colors(colormap
, drawing_colors
, NUM_COLORS
, FALSE
,
1100 gdk_colormap_alloc_colors(colormap
, drawing_colors_cpu
, NUM_COLORS_CPU
, FALSE
,
1102 gdk_colormap_alloc_colors(colormap
, drawing_colors_irq
, NUM_COLORS_IRQ
, FALSE
,
1104 gdk_colormap_alloc_colors(colormap
, drawing_colors_bdev
, NUM_COLORS_BDEV
, FALSE
,
1108 gdk_gc_new(GDK_DRAWABLE(main_window_get_widget(control_flow_data
->tab
)->window
));
1109 drawing
->dotted_gc
=
1110 gdk_gc_new(GDK_DRAWABLE(main_window_get_widget(control_flow_data
->tab
)->window
));
1112 gdk_gc_copy(drawing
->gc
,
1113 main_window_get_widget(control_flow_data
->tab
)->style
->black_gc
);
1114 gdk_gc_copy(drawing
->dotted_gc
,
1115 main_window_get_widget(control_flow_data
->tab
)->style
->white_gc
);
1117 gint8 dash_list
[] = { 1, 2 };
1118 gdk_gc_set_line_attributes(drawing
->dotted_gc
,
1120 GDK_LINE_ON_OFF_DASH
,
1123 gdk_gc_set_dashes(drawing
->dotted_gc
,
1128 drawing
->ruler_gc_butt
=
1129 gdk_gc_new(GDK_DRAWABLE(main_window_get_widget(control_flow_data
->tab
)->window
));
1130 gdk_gc_copy(drawing
->ruler_gc_butt
,
1131 main_window_get_widget(control_flow_data
->tab
)->style
->black_gc
);
1132 drawing
->ruler_gc_round
=
1133 gdk_gc_new(GDK_DRAWABLE(main_window_get_widget(control_flow_data
->tab
)->window
));
1134 gdk_gc_copy(drawing
->ruler_gc_round
,
1135 main_window_get_widget(control_flow_data
->tab
)->style
->black_gc
);
1138 gdk_gc_set_line_attributes(drawing
->ruler_gc_butt
,
1144 gdk_gc_set_line_attributes(drawing
->ruler_gc_round
,
1154 void drawing_destroy(Drawing_t
*drawing
)
1156 g_info("drawing_destroy %p", drawing
);
1158 /* Free the colors */
1159 GdkColormap
* colormap
= gdk_colormap_get_system();
1161 gdk_colormap_free_colors(colormap
, drawing_colors
, NUM_COLORS
);
1162 gdk_colormap_free_colors(colormap
, drawing_colors_cpu
, NUM_COLORS_CPU
);
1163 gdk_colormap_free_colors(colormap
, drawing_colors_irq
, NUM_COLORS_IRQ
);
1164 gdk_colormap_free_colors(colormap
, drawing_colors_bdev
, NUM_COLORS_BDEV
);
1166 // Do not unref here, Drawing_t destroyed by it's widget.
1167 //g_object_unref( G_OBJECT(drawing->drawing_area));
1168 if(drawing
->gc
!= NULL
)
1169 gdk_gc_unref(drawing
->gc
);
1171 g_object_unref(drawing
->pango_layout
);
1172 if(drawing
->dotted_gc
!= NULL
) gdk_gc_unref(drawing
->dotted_gc
);
1173 if(drawing
->ruler_gc_butt
!= NULL
) gdk_gc_unref(drawing
->ruler_gc_butt
);
1174 if(drawing
->ruler_gc_round
!= NULL
) gdk_gc_unref(drawing
->ruler_gc_round
);
1177 g_info("drawing_destroy end");
1180 GtkWidget
*drawing_get_drawing_area(Drawing_t
*drawing
)
1182 return drawing
->drawing_area
;
1185 GtkWidget
*drawing_get_widget(Drawing_t
*drawing
)
1187 return drawing
->vbox
;
1190 void drawing_draw_line( Drawing_t
*drawing
,
1196 gdk_draw_line (pixmap
,
1201 void drawing_clear(Drawing_t
*drawing
)
1203 //if (drawing->pixmap)
1204 // gdk_pixmap_unref(drawing->pixmap);
1205 ControlFlowData
*cfd
= drawing
->control_flow_data
;
1208 rectangle_pixmap(cfd
->process_list
,
1209 drawing
->drawing_area
->style
->black_gc
,
1212 drawing
->alloc_width
, // do not overlap
1215 //drawing->height = 1;
1216 /* Allocate a new pixmap with new height */
1217 //drawing->pixmap = gdk_pixmap_new(drawing->drawing_area->window,
1218 // drawing->width + SAFETY + EXTRA_ALLOC,
1219 // drawing->height + EXTRA_ALLOC,
1221 //drawing->alloc_width = drawing->width + SAFETY + EXTRA_ALLOC;
1222 //drawing->alloc_height = drawing->height + EXTRA_ALLOC;
1224 //gtk_widget_set_size_request(drawing->drawing_area,
1226 // drawing->height);
1227 //gtk_widget_queue_resize_no_redraw(drawing->drawing_area);
1229 /* ask for the buffer to be redrawn */
1230 gtk_widget_queue_draw ( drawing
->drawing_area
);
1234 /* Insert a square corresponding to a new process in the list */
1235 /* Applies to whole drawing->width */
1236 void drawing_insert_square(Drawing_t
*drawing
,
1240 //GdkRectangle update_rect;
1241 gboolean reallocate
= FALSE
;
1242 GdkPixmap
*new_pixmap
;
1244 /* Allocate a new pixmap with new height */
1245 if(drawing
->alloc_height
< drawing
->height
+ height
) {
1247 new_pixmap
= gdk_pixmap_new(drawing
->drawing_area
->window
,
1248 drawing
->width
+ SAFETY
+ EXTRA_ALLOC
,
1249 drawing
->height
+ height
+ EXTRA_ALLOC
,
1251 drawing
->alloc_width
= drawing
->width
+ SAFETY
+ EXTRA_ALLOC
;
1252 drawing
->alloc_height
= drawing
->height
+ height
+ EXTRA_ALLOC
;
1255 /* Copy the high region */
1256 gdk_draw_pixmap (new_pixmap
,
1257 drawing
->drawing_area
->style
->black_gc
,
1261 drawing
->width
+ SAFETY
, y
);
1264 new_pixmap
= drawing
->pixmap
;
1267 //GdkPixmap *pixmap = gdk_pixmap_new(drawing->drawing_area->window,
1268 // drawing->width + SAFETY,
1269 // drawing->height + height,
1272 /* add an empty square */
1273 gdk_draw_rectangle (new_pixmap
,
1274 drawing
->drawing_area
->style
->black_gc
,
1277 drawing
->width
+ SAFETY
, // do not overlap
1280 /* copy the bottom of the region */
1281 gdk_draw_pixmap (new_pixmap
,
1282 drawing
->drawing_area
->style
->black_gc
,
1286 drawing
->width
+SAFETY
, drawing
->height
- y
);
1289 if(reallocate
&& likely(drawing
->pixmap
)) {
1290 gdk_pixmap_unref(drawing
->pixmap
);
1291 drawing
->pixmap
= new_pixmap
;
1294 if(unlikely(drawing
->height
==1)) drawing
->height
= height
;
1295 else drawing
->height
+= height
;
1297 gtk_widget_set_size_request(drawing
->drawing_area
,
1300 gtk_widget_queue_resize_no_redraw(drawing
->drawing_area
);
1302 /* ask for the buffer to be redrawn */
1303 gtk_widget_queue_draw_area ( drawing
->drawing_area
,
1305 drawing
->width
, drawing
->height
-y
);
1309 /* Remove a square corresponding to a removed process in the list */
1310 void drawing_remove_square(Drawing_t
*drawing
,
1316 if(unlikely((guint
)drawing
->height
== height
)) {
1317 //pixmap = gdk_pixmap_new(
1318 // drawing->drawing_area->window,
1319 // drawing->width + SAFETY,
1322 pixmap
= drawing
->pixmap
;
1325 /* Allocate a new pixmap with new height */
1326 //pixmap = gdk_pixmap_new(
1327 // drawing->drawing_area->window,
1328 // drawing->width + SAFETY,
1329 // drawing->height - height,
1331 /* Keep the same preallocated pixmap */
1332 pixmap
= drawing
->pixmap
;
1334 /* Copy the high region */
1335 gdk_draw_pixmap (pixmap
,
1336 drawing
->drawing_area
->style
->black_gc
,
1340 drawing
->width
+ SAFETY
, y
);
1342 /* Copy up the bottom of the region */
1343 gdk_draw_pixmap (pixmap
,
1344 drawing
->drawing_area
->style
->black_gc
,
1348 drawing
->width
, drawing
->height
- y
- height
);
1350 drawing
->height
-=height
;
1353 //if(likely(drawing->pixmap))
1354 // gdk_pixmap_unref(drawing->pixmap);
1356 //drawing->pixmap = pixmap;
1358 gtk_widget_set_size_request(drawing
->drawing_area
,
1361 gtk_widget_queue_resize_no_redraw(drawing
->drawing_area
);
1362 /* ask for the buffer to be redrawn */
1363 gtk_widget_queue_draw_area ( drawing
->drawing_area
,
1365 drawing
->width
, MAX(drawing
->height
-y
, 1));
1369 void drawing_update_ruler(Drawing_t
*drawing
, TimeWindow
*time_window
)
1374 req
.width
= drawing
->ruler
->allocation
.width
;
1375 req
.height
= drawing
->ruler
->allocation
.height
;
1380 rect
.width
= req
.width
;
1381 rect
.height
= req
.height
;
1383 gtk_widget_queue_draw(drawing
->ruler
);
1384 //gtk_widget_draw( drawing->ruler, &rect);
1387 /* Redraw the ruler */
1389 expose_ruler( GtkWidget
*widget
, GdkEventExpose
*event
, gpointer user_data
)
1391 Drawing_t
*drawing
= (Drawing_t
*)user_data
;
1392 TimeWindow time_window
= lttvwindow_get_time_window(drawing
->control_flow_data
->tab
);
1395 PangoContext
*context
;
1396 PangoLayout
*layout
;
1397 PangoFontDescription
*FontDesc
;
1398 PangoRectangle ink_rect
;
1399 gint global_width
=0;
1400 GdkColor foreground
= { 0, 0, 0, 0 };
1401 GdkColor background
= { 0, 0xffff, 0xffff, 0xffff };
1403 LttTime window_end
= time_window
.end_time
;
1404 LttTime half_width
=
1405 ltt_time_div(time_window
.time_width
,2.0);
1406 LttTime window_middle
=
1407 ltt_time_add(half_width
,
1408 time_window
.start_time
);
1409 g_debug("ruler expose event");
1411 gdk_draw_rectangle (drawing
->ruler
->window
,
1412 drawing
->ruler
->style
->white_gc
,
1414 event
->area
.x
, event
->area
.y
,
1416 event
->area
.height
);
1418 gdk_draw_line (drawing
->ruler
->window
,
1419 drawing
->ruler_gc_butt
,
1421 event
->area
.x
+ event
->area
.width
, 1);
1424 snprintf(text
, 255, "%lus\n%luns",
1425 time_window
.start_time
.tv_sec
,
1426 time_window
.start_time
.tv_nsec
);
1428 layout
= gtk_widget_create_pango_layout(drawing
->drawing_area
, NULL
);
1430 context
= pango_layout_get_context(layout
);
1431 FontDesc
= pango_context_get_font_description(context
);
1433 pango_font_description_set_size(FontDesc
, 6*PANGO_SCALE
);
1434 pango_layout_context_changed(layout
);
1436 pango_layout_set_text(layout
, text
, -1);
1437 pango_layout_get_pixel_extents(layout
, &ink_rect
, NULL
);
1438 global_width
+= ink_rect
.width
;
1440 gdk_draw_layout_with_colors(drawing
->ruler
->window
,
1441 drawing
->ruler_gc_butt
,
1444 layout
, &foreground
, &background
);
1446 gdk_draw_line (drawing
->ruler
->window
,
1447 drawing
->ruler_gc_round
,
1452 snprintf(text
, 255, "%lus\n%luns", window_end
.tv_sec
,
1453 window_end
.tv_nsec
);
1455 pango_layout_set_text(layout
, text
, -1);
1456 pango_layout_get_pixel_extents(layout
, &ink_rect
, NULL
);
1457 global_width
+= ink_rect
.width
;
1459 if(global_width
<= drawing
->ruler
->allocation
.width
)
1461 gdk_draw_layout_with_colors(drawing
->ruler
->window
,
1462 drawing
->ruler_gc_butt
,
1463 drawing
->ruler
->allocation
.width
- ink_rect
.width
,
1465 layout
, &foreground
, &background
);
1467 gdk_draw_line (drawing
->ruler
->window
,
1468 drawing
->ruler_gc_butt
,
1469 drawing
->ruler
->allocation
.width
-1, 1,
1470 drawing
->ruler
->allocation
.width
-1, 7);
1474 snprintf(text
, 255, "%lus\n%luns", window_middle
.tv_sec
,
1475 window_middle
.tv_nsec
);
1477 pango_layout_set_text(layout
, text
, -1);
1478 pango_layout_get_pixel_extents(layout
, &ink_rect
, NULL
);
1479 global_width
+= ink_rect
.width
;
1481 if(global_width
<= drawing
->ruler
->allocation
.width
)
1483 gdk_draw_layout_with_colors(drawing
->ruler
->window
,
1484 drawing
->ruler_gc_butt
,
1485 (drawing
->ruler
->allocation
.width
- ink_rect
.width
)/2,
1487 layout
, &foreground
, &background
);
1489 gdk_draw_line (drawing
->ruler
->window
,
1490 drawing
->ruler_gc_butt
,
1491 drawing
->ruler
->allocation
.width
/2, 1,
1492 drawing
->ruler
->allocation
.width
/2, 7);
1499 g_object_unref(layout
);
1505 /* notify mouse on ruler */
1507 motion_notify_ruler(GtkWidget
*widget
, GdkEventMotion
*event
, gpointer user_data
)
1509 //g_debug("motion");
1510 //eventually follow mouse and show time here