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 /*****************************************************************************
104 * drawing functions *
105 *****************************************************************************/
108 expose_ruler( GtkWidget
*widget
, GdkEventExpose
*event
, gpointer user_data
);
111 motion_notify_ruler(GtkWidget
*widget
, GdkEventMotion
*event
, gpointer user_data
);
114 /* Function responsible for updating the exposed area.
115 * It must do an events request to the lttvwindow API to ask for this update.
116 * Note : this function cannot clear the background, because it may
117 * erase drawing already present (SAFETY).
119 void drawing_data_request(Drawing_t
*drawing
,
124 if(width
< 0) return ;
125 if(height
< 0) return ;
128 Tab
*tab
= drawing
->control_flow_data
->tab
;
129 TimeWindow time_window
=
130 lttvwindow_get_time_window(tab
);
132 ControlFlowData
*control_flow_data
= drawing
->control_flow_data
;
133 // (ControlFlowData*)g_object_get_data(
134 // G_OBJECT(drawing->drawing_area), "control_flow_data");
136 LttTime start
, time_end
;
137 LttTime window_end
= time_window
.end_time
;
139 g_debug("req : window start_time : %lu, %lu", time_window
.start_time
.tv_sec
,
140 time_window
.start_time
.tv_nsec
);
142 g_debug("req : window time width : %lu, %lu", time_window
.time_width
.tv_sec
,
143 time_window
.time_width
.tv_nsec
);
145 g_debug("req : window_end : %lu, %lu", window_end
.tv_sec
,
148 g_debug("x is : %i, x+width is : %i", x
, x
+width
);
150 convert_pixels_to_time(drawing
->width
, x
,
154 convert_pixels_to_time(drawing
->width
, x
+width
,
157 time_end
= ltt_time_add(time_end
, ltt_time_one
); // because main window
158 // doesn't deliver end time.
160 lttvwindow_events_request_remove_all(tab
,
164 /* find the tracehooks */
165 LttvTracesetContext
*tsc
= lttvwindow_get_traceset_context(tab
);
167 LttvTraceset
*traceset
= tsc
->ts
;
169 guint i
, k
, l
, nb_trace
;
173 LttvTracefileState
*tfs
;
179 LttvTraceHookByFacility
*thf
;
182 gint before_hn
, after_hn
;
184 nb_trace
= lttv_traceset_number(traceset
);
185 // FIXME (fixed) : eventually request for more traces
186 for(i
= 0 ; i
< nb_trace
; i
++) {
187 //for(i = 0; i<MIN(TRACE_NUMBER+1, nb_trace);i++) {
188 EventsRequest
*events_request
= g_new(EventsRequest
, 1);
190 //LttvHooks *event = lttv_hooks_new();
191 LttvHooksById
*event_by_id
= lttv_hooks_by_id_new();
192 LttvHooks
*before_chunk_traceset
= lttv_hooks_new();
193 LttvHooks
*after_chunk_traceset
= lttv_hooks_new();
194 LttvHooks
*before_request_hook
= lttv_hooks_new();
195 LttvHooks
*after_request_hook
= lttv_hooks_new();
197 lttv_hooks_add(before_chunk_traceset
,
202 lttv_hooks_add(after_chunk_traceset
,
207 lttv_hooks_add(before_request_hook
,
212 lttv_hooks_add(after_request_hook
,
218 ts
= (LttvTraceState
*)tsc
->traces
[i
];
220 /* Find the eventtype id for the following events and register the
221 associated by id hooks. */
223 hooks
= g_array_new(FALSE
, FALSE
, sizeof(LttvTraceHook
));
224 hooks
= g_array_set_size(hooks
, 18);
225 before_hn
= after_hn
= 0;
229 // ret = lttv_trace_find_hook(ts->parent.t,
230 // LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_ENTRY,
231 // LTT_FIELD_SYSCALL_ID, 0, 0,
232 // before_execmode_hook,
234 // &g_array_index(hooks, LttvTraceHook, before_hn++));
235 // if(ret) before_hn--;
237 // ret = lttv_trace_find_hook(ts->parent.t,
238 // LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_EXIT,
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_TRAP_ENTRY
,
247 LTT_FIELD_TRAP_ID
, 0, 0,
248 before_execmode_hook
,
250 &g_array_index(hooks
, LttvTraceHook
, before_hn
++));
253 ret
= lttv_trace_find_hook(ts
->parent
.t
,
254 LTT_FACILITY_KERNEL_ARCH
, LTT_EVENT_TRAP_EXIT
,
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
, LTT_EVENT_IRQ_ENTRY
,
263 LTT_FIELD_IRQ_ID
, 0, 0,
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_EXIT
,
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_SOFT_IRQ_ENTRY,
279 // LTT_FIELD_SOFT_IRQ_ID, 0, 0,
280 // before_execmode_hook,
282 // &g_array_index(hooks, LttvTraceHook, before_hn++));
283 // if(ret) before_hn--;
285 // ret = lttv_trace_find_hook(ts->parent.t,
286 // LTT_FACILITY_KERNEL, LTT_EVENT_SOFT_IRQ_EXIT,
288 // before_execmode_hook,
290 // &g_array_index(hooks, LttvTraceHook, before_hn++));
291 // if(ret) before_hn--;
294 ret
= lttv_trace_find_hook(ts
->parent
.t
,
295 LTT_FACILITY_KERNEL
, LTT_EVENT_SCHED_SCHEDULE
,
296 LTT_FIELD_PREV_PID
, LTT_FIELD_NEXT_PID
, LTT_FIELD_PREV_STATE
,
297 before_schedchange_hook
,
299 &g_array_index(hooks
, LttvTraceHook
, before_hn
++));
302 // ret = lttv_trace_find_hook(ts->parent.t,
303 // LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_EXIT,
304 // LTT_FIELD_PID, 0, 0,
305 // before_process_exit_hook,
307 // &g_array_index(hooks, LttvTraceHook, before_hn++));
308 // if(ret) before_hn--;
310 // ret = lttv_trace_find_hook(ts->parent.t,
311 // LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_FREE,
312 // LTT_FIELD_PID, 0, 0,
313 // before_process_release_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_LIST, LTT_EVENT_STATEDUMP_END,
321 // before_statedump_end,
323 // &g_array_index(hooks, LttvTraceHook, before_hn++));
324 // if(ret) before_hn--;
327 lttv_trace_find_hook(ts
->parent
.t
,
328 "core", "process", "event_sub_id",
329 "event_data1", "event_data2", before_process_hook
,
330 &g_array_index(hooks
, LttvTraceHook
, hn
++));
333 lttv_trace_find_hook(ts
->parent
.t
, "core", "process_fork", "child_pid",
334 NULL
, NULL
, process_fork
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
336 lttv_trace_find_hook(ts
->parent
.t
, "core", "process_exit", NULL
, NULL
,
337 NULL
, process_exit
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
343 /**** DESACTIVATED ****/
344 lttv_trace_find_hook(ts
->parent
.t
, "core","syscall_entry","syscall_id",
345 NULL
, NULL
, after_execmode_hook
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
346 /**** DESACTIVATED ****/
347 lttv_trace_find_hook(ts
->parent
.t
, "core", "syscall_exit", NULL
, NULL
,
348 NULL
, after_execmode_hook
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
350 /**** DESACTIVATED ****/
351 lttv_trace_find_hook(ts
->parent
.t
, "core", "trap_entry", "trap_id",
352 NULL
, NULL
, after_execmode_hook
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
354 /**** DESACTIVATED ****/
355 lttv_trace_find_hook(ts
->parent
.t
, "core", "trap_exit", NULL
, NULL
, NULL
,
356 after_execmode_hook
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
358 /**** DESACTIVATED ****/
359 lttv_trace_find_hook(ts
->parent
.t
, "core", "irq_entry", "irq_id", NULL
,
360 NULL
, after_execmode_hook
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
362 /**** DESACTIVATED ****/
363 lttv_trace_find_hook(ts
->parent
.t
, "core", "irq_exit", NULL
, NULL
, NULL
,
364 after_execmode_hook
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
367 lttv_trace_find_hook(ts
->parent
.t
, "core", "schedchange", "in", "out",
368 "out_state", after_schedchange_hook
,
369 &g_array_index(hooks
, LttvTraceHook
, hn
++));
371 lttv_trace_find_hook(ts
->parent
.t
, "core", "process", "event_sub_id",
372 "event_data1", "event_data2", after_process_hook
,
373 &g_array_index(hooks
, LttvTraceHook
, hn
++));
375 after_hn
= before_hn
;
377 ret
= lttv_trace_find_hook(ts
->parent
.t
,
378 LTT_FACILITY_KERNEL
, LTT_EVENT_SCHED_SCHEDULE
,
379 LTT_FIELD_PREV_PID
, LTT_FIELD_NEXT_PID
, LTT_FIELD_PREV_STATE
,
380 after_schedchange_hook
,
382 &g_array_index(hooks
, LttvTraceHook
, after_hn
++));
385 // ret = lttv_trace_find_hook(ts->parent.t,
386 // LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_FORK,
387 // LTT_FIELD_PARENT_PID, LTT_FIELD_CHILD_PID, 0,
388 // after_process_fork_hook,
390 // &g_array_index(hooks, LttvTraceHook, after_hn++));
391 // if(ret) after_hn--;
393 // ret = lttv_trace_find_hook(ts->parent.t,
394 // LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_EXIT,
395 // LTT_FIELD_PID, 0, 0,
396 // after_process_exit_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_FS, LTT_EVENT_EXEC,
404 // after_fs_exec_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_USER_GENERIC, LTT_EVENT_THREAD_BRAND,
411 // LTT_FIELD_NAME, 0, 0,
412 // after_user_generic_thread_brand_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_LIST, LTT_EVENT_PROCESS_STATE,
419 // LTT_FIELD_PID, LTT_FIELD_PARENT_PID, LTT_FIELD_NAME,
420 // after_event_enum_process_hook,
422 // &g_array_index(hooks, LttvTraceHook, after_hn++));
423 // if(ret) after_hn--;
425 hooks
= g_array_set_size(hooks
, after_hn
);
428 lttv_trace_find_hook(ts
->parent
.t
, "core", "process_fork", "child_pid",
429 NULL
, NULL
, process_fork
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
431 lttv_trace_find_hook(ts
->parent
.t
, "core", "process_exit", NULL
, NULL
,
432 NULL
, process_exit
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
437 /* Add these hooks to each event_by_id hooks list */
439 for(k
= 0 ; k
< before_hn
; k
++) {
440 hook
= &g_array_index(hooks
, LttvTraceHook
, k
);
441 for(l
=0;l
<hook
->fac_list
->len
;l
++) {
442 thf
= g_array_index(hook
->fac_list
, LttvTraceHookByFacility
*, l
);
443 lttv_hooks_add(lttv_hooks_by_id_find(event_by_id
, thf
->id
),
451 for(k
= before_hn
; k
< after_hn
; k
++) {
452 hook
= &g_array_index(hooks
, LttvTraceHook
, k
);
453 for(l
=0;l
<hook
->fac_list
->len
;l
++) {
454 thf
= g_array_index(hook
->fac_list
, LttvTraceHookByFacility
*, l
);
455 lttv_hooks_add(lttv_hooks_by_id_find(event_by_id
, thf
->id
),
462 events_request
->hooks
= hooks
;
464 // Fill the events request
465 events_request
->owner
= control_flow_data
;
466 events_request
->viewer_data
= control_flow_data
;
467 events_request
->servicing
= FALSE
;
468 events_request
->start_time
= start
;
469 events_request
->start_position
= NULL
;
470 events_request
->stop_flag
= FALSE
;
471 events_request
->end_time
= time_end
;
472 events_request
->num_events
= G_MAXUINT
;
473 events_request
->end_position
= NULL
;
474 events_request
->trace
= i
; //fixed /* FIXME */
475 events_request
->before_chunk_traceset
= before_chunk_traceset
;
476 events_request
->before_chunk_trace
= NULL
;
477 events_request
->before_chunk_tracefile
= NULL
;
478 events_request
->event
= NULL
;
479 events_request
->event_by_id
= event_by_id
;
480 events_request
->after_chunk_tracefile
= NULL
;
481 events_request
->after_chunk_trace
= NULL
;
482 events_request
->after_chunk_traceset
= after_chunk_traceset
;
483 events_request
->before_request
= before_request_hook
;
484 events_request
->after_request
= after_request_hook
;
486 g_debug("req : start : %lu, %lu", start
.tv_sec
,
489 g_debug("req : end : %lu, %lu", time_end
.tv_sec
,
492 lttvwindow_events_request(tab
, events_request
);
499 lttv_hooks_add(event
,
500 before_schedchange_hook
,
503 lttv_hooks_add(event
,
504 after_schedchange_hook
,
507 lttv_hooks_add(event
,
508 before_execmode_hook
,
511 lttv_hooks_add(event
,
515 lttv_hooks_add(event
,
519 lttv_hooks_add(event
,
528 static void set_last_start(gpointer key
, gpointer value
, gpointer user_data
)
530 ResourceInfo
*process_info
= (ResourceInfo
*)key
;
531 HashedResourceData
*hashed_process_data
= (HashedResourceData
*)value
;
532 guint x
= (guint
)user_data
;
534 hashed_process_data
->x
.over
= x
;
535 hashed_process_data
->x
.over_used
= FALSE
;
536 hashed_process_data
->x
.over_marked
= FALSE
;
537 hashed_process_data
->x
.middle
= x
;
538 hashed_process_data
->x
.middle_used
= FALSE
;
539 hashed_process_data
->x
.middle_marked
= FALSE
;
540 hashed_process_data
->x
.under
= x
;
541 hashed_process_data
->x
.under_used
= FALSE
;
542 hashed_process_data
->x
.under_marked
= FALSE
;
543 hashed_process_data
->next_good_time
= ltt_time_zero
;
548 void drawing_data_request_begin(EventsRequest
*events_request
, LttvTracesetState
*tss
)
550 g_debug("Begin of data request");
551 ControlFlowData
*cfd
= events_request
->viewer_data
;
552 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(tss
);
553 TimeWindow time_window
=
554 lttvwindow_get_time_window(cfd
->tab
);
556 guint width
= cfd
->drawing
->width
;
559 cfd
->drawing
->last_start
= events_request
->start_time
;
561 convert_time_to_pixels(
563 events_request
->start_time
,
567 g_hash_table_foreach(cfd
->process_list
->process_hash
, set_last_start
,
572 void drawing_chunk_begin(EventsRequest
*events_request
, LttvTracesetState
*tss
)
574 g_debug("Begin of chunk");
575 ControlFlowData
*cfd
= events_request
->viewer_data
;
576 LttvTracesetContext
*tsc
= &tss
->parent
.parent
;
577 //LttTime current_time = lttv_traceset_context_get_current_tfc(tsc)->timestamp;
579 LttvTraceset
*traceset
= tsc
->ts
;
580 guint nb_trace
= lttv_traceset_number(traceset
);
582 if(!cfd
->process_list
->current_hash_data
) {
583 cfd
->process_list
->current_hash_data
= g_new(HashedResourceData
**,nb_trace
);
584 for(i
= 0 ; i
< nb_trace
; i
++) {
585 guint num_cpu
= ltt_trace_get_num_cpu(tss
->parent
.traces
[i
]->t
);
586 cfd
->process_list
->current_hash_data
[i
] = g_new(HashedResourceData
*,num_cpu
);
587 memset(cfd
->process_list
->current_hash_data
[i
], 0,
588 sizeof(HashedResourceData
*)*num_cpu
);
591 //cfd->drawing->last_start = LTT_TIME_MIN(current_time,
592 // events_request->end_time);
596 void drawing_request_expose(EventsRequest
*events_request
,
597 LttvTracesetState
*tss
,
603 ControlFlowData
*cfd
= events_request
->viewer_data
;
604 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)tss
;
605 Drawing_t
*drawing
= cfd
->drawing
;
607 TimeWindow time_window
=
608 lttvwindow_get_time_window(cfd
->tab
);
610 g_debug("request expose");
612 convert_time_to_pixels(
617 x
= drawing
->damage_begin
;
621 drawing
->damage_begin
= x
+width
;
624 gtk_widget_queue_draw_area ( drawing
->drawing_area
,
626 width
, drawing
->drawing_area
->allocation
.height
);
628 /* Update directly when scrolling */
629 gdk_window_process_updates(drawing
->drawing_area
->window
,
637 /* Create a new backing pixmap of the appropriate size */
638 /* As the scaling will always change, it's of no use to copy old
641 * Only change the size if width changes. The height is specified and changed
642 * when process ID are added or removed from the process list.
645 configure_event( GtkWidget
*widget
, GdkEventConfigure
*event
,
648 Drawing_t
*drawing
= (Drawing_t
*)user_data
;
651 /* First, get the new time interval of the main window */
652 /* we assume (see documentation) that the main window
653 * has updated the time interval before this configure gets
656 //lttvwindow_get_time_window(drawing->control_flow_data->mw,
657 // &drawing->control_flow_data->time_window);
659 /* New pixmap, size of the configure event */
660 //GdkPixmap *pixmap = gdk_pixmap_new(widget->window,
661 // widget->allocation.width + SAFETY,
662 // widget->allocation.height + SAFETY,
665 if(widget
->allocation
.width
!= drawing
->width
) {
666 g_debug("drawing configure event");
667 g_debug("New alloc draw size : %i by %i",widget
->allocation
.width
,
668 widget
->allocation
.height
);
670 drawing
->width
= widget
->allocation
.width
;
672 if(drawing
->alloc_width
< widget
->allocation
.width
) {
673 //if(drawing->pixmap)
674 // gdk_pixmap_unref(drawing->pixmap);
676 //drawing->pixmap = gdk_pixmap_new(widget->window,
677 // drawing->width + SAFETY + EXTRA_ALLOC,
678 // drawing->height + EXTRA_ALLOC,
680 drawing
->alloc_width
= drawing
->width
+ SAFETY
+ EXTRA_ALLOC
;
681 drawing
->alloc_height
= drawing
->height
+ EXTRA_ALLOC
;
682 update_pixmap_size(drawing
->control_flow_data
->process_list
,
683 drawing
->alloc_width
);
684 update_index_to_pixmap(drawing
->control_flow_data
->process_list
);
686 //drawing->height = widget->allocation.height;
688 //ProcessList_get_height
689 // (GuiControlFlow_get_process_list(drawing->control_flow_data)),
693 //gdk_draw_rectangle (drawing->pixmap,
694 // widget->style->black_gc,
697 // drawing->width+SAFETY,
700 //g_info("init data request");
703 /* Initial data request */
704 /* no, do initial data request in the expose event */
705 // Do not need to ask for data of 1 pixel : not synchronized with
706 // main window time at this moment.
707 //drawing_data_request(drawing, &drawing->pixmap, 0, 0,
708 // widget->allocation.width,
709 // widget->allocation.height);
711 //drawing->width = widget->allocation.width;
712 //drawing->height = widget->allocation.height;
714 drawing
->damage_begin
= 0;
715 drawing
->damage_end
= widget
->allocation
.width
;
717 if((widget
->allocation
.width
!= 1 &&
718 widget
->allocation
.height
!= 1)
719 && drawing
->damage_begin
< drawing
->damage_end
)
722 rectangle_pixmap (drawing
->control_flow_data
->process_list
,
723 drawing
->drawing_area
->style
->black_gc
,
726 drawing
->alloc_width
, // do not overlap
730 drawing_data_request(drawing
,
731 drawing
->damage_begin
,
733 drawing
->damage_end
- drawing
->damage_begin
,
741 /* Redraw the screen from the backing pixmap */
743 expose_event( GtkWidget
*widget
, GdkEventExpose
*event
, gpointer user_data
)
745 Drawing_t
*drawing
= (Drawing_t
*)user_data
;
747 ControlFlowData
*control_flow_data
=
748 (ControlFlowData
*)g_object_get_data(
750 "control_flow_data");
752 if(unlikely(drawing
->gc
== NULL
)) {
753 drawing
->gc
= gdk_gc_new(drawing
->drawing_area
->window
);
754 gdk_gc_copy(drawing
->gc
, drawing
->drawing_area
->style
->black_gc
);
757 TimeWindow time_window
=
758 lttvwindow_get_time_window(control_flow_data
->tab
);
759 LttTime current_time
=
760 lttvwindow_get_current_time(control_flow_data
->tab
);
764 LttTime window_end
= time_window
.end_time
;
766 /* update the screen from the pixmap buffer */
768 gdk_draw_pixmap(widget
->window
,
769 widget
->style
->fg_gc
[GTK_WIDGET_STATE (widget
)],
771 event
->area
.x
, event
->area
.y
,
772 event
->area
.x
, event
->area
.y
,
773 event
->area
.width
, event
->area
.height
);
775 drawing
->height
= processlist_get_height(control_flow_data
->process_list
);
777 copy_pixmap_to_screen(control_flow_data
->process_list
,
779 widget
->style
->fg_gc
[GTK_WIDGET_STATE (widget
)],
780 event
->area
.x
, event
->area
.y
,
781 event
->area
.width
, event
->area
.height
);
783 copy_pixmap_to_screen(control_flow_data
->process_list
,
786 event
->area
.x
, event
->area
.y
,
787 event
->area
.width
, event
->area
.height
);
790 /* Erase the dotted lines left.. */
791 if(widget
->allocation
.height
> drawing
->height
)
793 gdk_draw_rectangle (widget
->window
,
794 drawing
->drawing_area
->style
->black_gc
,
796 event
->area
.x
, drawing
->height
,
797 event
->area
.width
, // do not overlap
798 widget
->allocation
.height
- drawing
->height
);
800 if(ltt_time_compare(time_window
.start_time
, current_time
) <= 0 &&
801 ltt_time_compare(window_end
, current_time
) >= 0)
803 /* Draw the dotted lines */
804 convert_time_to_pixels(
811 if(drawing
->dotted_gc
== NULL
) {
813 drawing
->dotted_gc
= gdk_gc_new(drawing
->drawing_area
->window
);
814 gdk_gc_copy(drawing
->dotted_gc
, widget
->style
->white_gc
);
816 gint8 dash_list
[] = { 1, 2 };
817 gdk_gc_set_line_attributes(drawing
->dotted_gc
,
819 GDK_LINE_ON_OFF_DASH
,
822 gdk_gc_set_dashes(drawing
->dotted_gc
,
828 gint height_tot
= MAX(widget
->allocation
.height
, drawing
->height
);
829 gdk_draw_line(widget
->window
,
832 cursor_x
, height_tot
);
838 after_expose_event( GtkWidget
*widget
, GdkEventExpose
*event
, gpointer user_data
)
841 g_debug("AFTER EXPOSE");
850 tree_row_activated(GtkTreeModel
*treemodel
,
852 GtkTreeViewColumn
*arg2
,
855 ControlFlowData
*cfd
= (ControlFlowData
*)user_data
;
856 Drawing_t
*drawing
= cfd
->drawing
;
857 GtkTreeView
*treeview
= cfd
->process_list
->process_list_widget
;
861 path_indices
= gtk_tree_path_get_indices (arg1
);
863 height
= get_cell_height(cfd
->process_list
,
864 GTK_TREE_VIEW(treeview
));
865 drawing
->horizontal_sel
= height
* path_indices
[0];
866 g_critical("new hor sel : %i", drawing
->horizontal_sel
);
872 button_press_event( GtkWidget
*widget
, GdkEventButton
*event
, gpointer user_data
)
874 ControlFlowData
*control_flow_data
=
875 (ControlFlowData
*)g_object_get_data(
877 "control_flow_data");
878 Drawing_t
*drawing
= control_flow_data
->drawing
;
879 TimeWindow time_window
=
880 lttvwindow_get_time_window(control_flow_data
->tab
);
883 if(event
->button
== 1)
887 /* left mouse button click */
888 g_debug("x click is : %f", event
->x
);
890 convert_pixels_to_time(drawing
->width
, (guint
)event
->x
,
894 lttvwindow_report_current_time(control_flow_data
->tab
, time
);
902 scrollbar_size_allocate(GtkWidget
*widget
,
903 GtkAllocation
*allocation
,
906 Drawing_t
*drawing
= (Drawing_t
*)user_data
;
908 gtk_widget_set_size_request(drawing
->padding
, allocation
->width
, -1);
909 //gtk_widget_queue_resize(drawing->padding);
910 //gtk_widget_queue_resize(drawing->ruler);
911 gtk_container_check_resize(GTK_CONTAINER(drawing
->ruler_hbox
));
917 Drawing_t
*drawing_construct(ControlFlowData
*control_flow_data
)
919 Drawing_t
*drawing
= g_new(Drawing_t
, 1);
921 drawing
->control_flow_data
= control_flow_data
;
923 drawing
->vbox
= gtk_vbox_new(FALSE
, 1);
926 drawing
->ruler_hbox
= gtk_hbox_new(FALSE
, 1);
927 drawing
->ruler
= gtk_drawing_area_new ();
928 //gtk_widget_set_size_request(drawing->ruler, -1, 27);
930 drawing
->padding
= gtk_drawing_area_new ();
931 //gtk_widget_set_size_request(drawing->padding, -1, 27);
932 gtk_box_pack_start(GTK_BOX(drawing
->ruler_hbox
), drawing
->ruler
,
934 gtk_box_pack_end(GTK_BOX(drawing
->ruler_hbox
), drawing
->padding
,
939 drawing
->drawing_area
= gtk_drawing_area_new ();
943 drawing
->hbox
= gtk_hbox_new(FALSE
, 1);
944 drawing
->viewport
= gtk_viewport_new(NULL
, control_flow_data
->v_adjust
);
945 drawing
->scrollbar
= gtk_vscrollbar_new(control_flow_data
->v_adjust
);
946 gtk_box_pack_start(GTK_BOX(drawing
->hbox
), drawing
->viewport
,
948 gtk_box_pack_end(GTK_BOX(drawing
->hbox
), drawing
->scrollbar
,
951 //drawing->scrolled_window =
952 // gtk_scrolled_window_new (NULL,
953 // control_flow_data->v_adjust);
955 //gtk_scrolled_window_set_policy(
956 // GTK_SCROLLED_WINDOW(drawing->scrolled_window),
958 // GTK_POLICY_AUTOMATIC);
960 gtk_container_add(GTK_CONTAINER(drawing
->viewport
),
961 drawing
->drawing_area
);
962 //gtk_scrolled_window_add_with_viewport(
963 // GTK_SCROLLED_WINDOW(drawing->scrolled_window),
964 // drawing->drawing_area);
966 gtk_box_pack_start(GTK_BOX(drawing
->vbox
), drawing
->ruler_hbox
,
968 gtk_box_pack_end(GTK_BOX(drawing
->vbox
), drawing
->hbox
,
971 drawing
->pango_layout
=
972 gtk_widget_create_pango_layout(drawing
->drawing_area
, NULL
);
977 drawing
->alloc_height
= 1;
978 drawing
->alloc_width
= 1;
980 drawing
->damage_begin
= 0;
981 drawing
->damage_end
= 0;
982 drawing
->horizontal_sel
= -1;
984 //gtk_widget_set_size_request(drawing->drawing_area->window, 50, 50);
985 g_object_set_data_full(
986 G_OBJECT(drawing
->drawing_area
),
989 (GDestroyNotify
)drawing_destroy
);
992 G_OBJECT(drawing
->ruler
),
997 //gtk_widget_modify_bg( drawing->drawing_area,
999 // &CF_Colors[BLACK]);
1001 //gdk_window_get_geometry(drawing->drawing_area->window,
1003 // &(drawing->width),
1004 // &(drawing->height),
1007 //drawing->pixmap = gdk_pixmap_new(
1008 // drawing->drawing_area->window,
1013 //drawing->pixmap = NULL;
1015 // drawing->pixmap = gdk_pixmap_new(drawing->drawing_area->window,
1016 // drawing->drawing_area->allocation.width,
1017 // drawing->drawing_area->allocation.height,
1020 g_signal_connect (G_OBJECT(drawing
->drawing_area
),
1022 G_CALLBACK (configure_event
),
1025 g_signal_connect (G_OBJECT(drawing
->ruler
),
1027 G_CALLBACK(expose_ruler
),
1030 gtk_widget_add_events(drawing
->ruler
, GDK_POINTER_MOTION_MASK
);
1032 g_signal_connect (G_OBJECT(drawing
->ruler
),
1033 "motion-notify-event",
1034 G_CALLBACK(motion_notify_ruler
),
1038 g_signal_connect (G_OBJECT(drawing
->scrollbar
),
1040 G_CALLBACK(scrollbar_size_allocate
),
1045 g_signal_connect (G_OBJECT(drawing
->drawing_area
),
1047 G_CALLBACK (expose_event
),
1050 g_signal_connect_after (G_OBJECT(drawing
->drawing_area
),
1052 G_CALLBACK (after_expose_event
),
1055 g_signal_connect (G_OBJECT(drawing
->drawing_area
),
1056 "button-press-event",
1057 G_CALLBACK (button_press_event
),
1061 gtk_widget_show(drawing
->ruler
);
1062 gtk_widget_show(drawing
->padding
);
1063 gtk_widget_show(drawing
->ruler_hbox
);
1065 gtk_widget_show(drawing
->drawing_area
);
1066 //gtk_widget_show(drawing->scrolled_window);
1067 gtk_widget_show(drawing
->viewport
);
1068 gtk_widget_show(drawing
->scrollbar
);
1069 gtk_widget_show(drawing
->hbox
);
1071 /* Allocate the colors */
1072 GdkColormap
* colormap
= gdk_colormap_get_system();
1073 gboolean success
[NUM_COLORS
];
1074 gdk_colormap_alloc_colors(colormap
, drawing_colors
, NUM_COLORS
, FALSE
,
1076 gdk_colormap_alloc_colors(colormap
, drawing_colors_cpu
, NUM_COLORS_CPU
, FALSE
,
1078 gdk_colormap_alloc_colors(colormap
, drawing_colors_irq
, NUM_COLORS_IRQ
, FALSE
,
1082 gdk_gc_new(GDK_DRAWABLE(main_window_get_widget(control_flow_data
->tab
)->window
));
1083 drawing
->dotted_gc
=
1084 gdk_gc_new(GDK_DRAWABLE(main_window_get_widget(control_flow_data
->tab
)->window
));
1086 gdk_gc_copy(drawing
->gc
,
1087 main_window_get_widget(control_flow_data
->tab
)->style
->black_gc
);
1088 gdk_gc_copy(drawing
->dotted_gc
,
1089 main_window_get_widget(control_flow_data
->tab
)->style
->white_gc
);
1091 gint8 dash_list
[] = { 1, 2 };
1092 gdk_gc_set_line_attributes(drawing
->dotted_gc
,
1094 GDK_LINE_ON_OFF_DASH
,
1097 gdk_gc_set_dashes(drawing
->dotted_gc
,
1102 drawing
->ruler_gc_butt
=
1103 gdk_gc_new(GDK_DRAWABLE(main_window_get_widget(control_flow_data
->tab
)->window
));
1104 gdk_gc_copy(drawing
->ruler_gc_butt
,
1105 main_window_get_widget(control_flow_data
->tab
)->style
->black_gc
);
1106 drawing
->ruler_gc_round
=
1107 gdk_gc_new(GDK_DRAWABLE(main_window_get_widget(control_flow_data
->tab
)->window
));
1108 gdk_gc_copy(drawing
->ruler_gc_round
,
1109 main_window_get_widget(control_flow_data
->tab
)->style
->black_gc
);
1112 gdk_gc_set_line_attributes(drawing
->ruler_gc_butt
,
1118 gdk_gc_set_line_attributes(drawing
->ruler_gc_round
,
1128 void drawing_destroy(Drawing_t
*drawing
)
1130 g_info("drawing_destroy %p", drawing
);
1132 /* Free the colors */
1133 GdkColormap
* colormap
= gdk_colormap_get_system();
1135 gdk_colormap_free_colors(colormap
, drawing_colors
, NUM_COLORS
);
1136 gdk_colormap_free_colors(colormap
, drawing_colors_cpu
, NUM_COLORS_CPU
);
1137 gdk_colormap_free_colors(colormap
, drawing_colors_irq
, NUM_COLORS_IRQ
);
1139 // Do not unref here, Drawing_t destroyed by it's widget.
1140 //g_object_unref( G_OBJECT(drawing->drawing_area));
1141 if(drawing
->gc
!= NULL
)
1142 gdk_gc_unref(drawing
->gc
);
1144 g_object_unref(drawing
->pango_layout
);
1145 if(drawing
->dotted_gc
!= NULL
) gdk_gc_unref(drawing
->dotted_gc
);
1146 if(drawing
->ruler_gc_butt
!= NULL
) gdk_gc_unref(drawing
->ruler_gc_butt
);
1147 if(drawing
->ruler_gc_round
!= NULL
) gdk_gc_unref(drawing
->ruler_gc_round
);
1150 g_info("drawing_destroy end");
1153 GtkWidget
*drawing_get_drawing_area(Drawing_t
*drawing
)
1155 return drawing
->drawing_area
;
1158 GtkWidget
*drawing_get_widget(Drawing_t
*drawing
)
1160 return drawing
->vbox
;
1163 void drawing_draw_line( Drawing_t
*drawing
,
1169 gdk_draw_line (pixmap
,
1174 void drawing_clear(Drawing_t
*drawing
)
1176 //if (drawing->pixmap)
1177 // gdk_pixmap_unref(drawing->pixmap);
1178 ControlFlowData
*cfd
= drawing
->control_flow_data
;
1181 rectangle_pixmap(cfd
->process_list
,
1182 drawing
->drawing_area
->style
->black_gc
,
1185 drawing
->alloc_width
, // do not overlap
1188 //drawing->height = 1;
1189 /* Allocate a new pixmap with new height */
1190 //drawing->pixmap = gdk_pixmap_new(drawing->drawing_area->window,
1191 // drawing->width + SAFETY + EXTRA_ALLOC,
1192 // drawing->height + EXTRA_ALLOC,
1194 //drawing->alloc_width = drawing->width + SAFETY + EXTRA_ALLOC;
1195 //drawing->alloc_height = drawing->height + EXTRA_ALLOC;
1197 //gtk_widget_set_size_request(drawing->drawing_area,
1199 // drawing->height);
1200 //gtk_widget_queue_resize_no_redraw(drawing->drawing_area);
1202 /* ask for the buffer to be redrawn */
1203 gtk_widget_queue_draw ( drawing
->drawing_area
);
1207 /* Insert a square corresponding to a new process in the list */
1208 /* Applies to whole drawing->width */
1209 void drawing_insert_square(Drawing_t
*drawing
,
1213 //GdkRectangle update_rect;
1214 gboolean reallocate
= FALSE
;
1215 GdkPixmap
*new_pixmap
;
1217 /* Allocate a new pixmap with new height */
1218 if(drawing
->alloc_height
< drawing
->height
+ height
) {
1220 new_pixmap
= gdk_pixmap_new(drawing
->drawing_area
->window
,
1221 drawing
->width
+ SAFETY
+ EXTRA_ALLOC
,
1222 drawing
->height
+ height
+ EXTRA_ALLOC
,
1224 drawing
->alloc_width
= drawing
->width
+ SAFETY
+ EXTRA_ALLOC
;
1225 drawing
->alloc_height
= drawing
->height
+ height
+ EXTRA_ALLOC
;
1228 /* Copy the high region */
1229 gdk_draw_pixmap (new_pixmap
,
1230 drawing
->drawing_area
->style
->black_gc
,
1234 drawing
->width
+ SAFETY
, y
);
1237 new_pixmap
= drawing
->pixmap
;
1240 //GdkPixmap *pixmap = gdk_pixmap_new(drawing->drawing_area->window,
1241 // drawing->width + SAFETY,
1242 // drawing->height + height,
1245 /* add an empty square */
1246 gdk_draw_rectangle (new_pixmap
,
1247 drawing
->drawing_area
->style
->black_gc
,
1250 drawing
->width
+ SAFETY
, // do not overlap
1253 /* copy the bottom of the region */
1254 gdk_draw_pixmap (new_pixmap
,
1255 drawing
->drawing_area
->style
->black_gc
,
1259 drawing
->width
+SAFETY
, drawing
->height
- y
);
1262 if(reallocate
&& likely(drawing
->pixmap
)) {
1263 gdk_pixmap_unref(drawing
->pixmap
);
1264 drawing
->pixmap
= new_pixmap
;
1267 if(unlikely(drawing
->height
==1)) drawing
->height
= height
;
1268 else drawing
->height
+= height
;
1270 gtk_widget_set_size_request(drawing
->drawing_area
,
1273 gtk_widget_queue_resize_no_redraw(drawing
->drawing_area
);
1275 /* ask for the buffer to be redrawn */
1276 gtk_widget_queue_draw_area ( drawing
->drawing_area
,
1278 drawing
->width
, drawing
->height
-y
);
1282 /* Remove a square corresponding to a removed process in the list */
1283 void drawing_remove_square(Drawing_t
*drawing
,
1289 if(unlikely((guint
)drawing
->height
== height
)) {
1290 //pixmap = gdk_pixmap_new(
1291 // drawing->drawing_area->window,
1292 // drawing->width + SAFETY,
1295 pixmap
= drawing
->pixmap
;
1298 /* Allocate a new pixmap with new height */
1299 //pixmap = gdk_pixmap_new(
1300 // drawing->drawing_area->window,
1301 // drawing->width + SAFETY,
1302 // drawing->height - height,
1304 /* Keep the same preallocated pixmap */
1305 pixmap
= drawing
->pixmap
;
1307 /* Copy the high region */
1308 gdk_draw_pixmap (pixmap
,
1309 drawing
->drawing_area
->style
->black_gc
,
1313 drawing
->width
+ SAFETY
, y
);
1315 /* Copy up the bottom of the region */
1316 gdk_draw_pixmap (pixmap
,
1317 drawing
->drawing_area
->style
->black_gc
,
1321 drawing
->width
, drawing
->height
- y
- height
);
1323 drawing
->height
-=height
;
1326 //if(likely(drawing->pixmap))
1327 // gdk_pixmap_unref(drawing->pixmap);
1329 //drawing->pixmap = pixmap;
1331 gtk_widget_set_size_request(drawing
->drawing_area
,
1334 gtk_widget_queue_resize_no_redraw(drawing
->drawing_area
);
1335 /* ask for the buffer to be redrawn */
1336 gtk_widget_queue_draw_area ( drawing
->drawing_area
,
1338 drawing
->width
, MAX(drawing
->height
-y
, 1));
1342 void drawing_update_ruler(Drawing_t
*drawing
, TimeWindow
*time_window
)
1347 req
.width
= drawing
->ruler
->allocation
.width
;
1348 req
.height
= drawing
->ruler
->allocation
.height
;
1353 rect
.width
= req
.width
;
1354 rect
.height
= req
.height
;
1356 gtk_widget_queue_draw(drawing
->ruler
);
1357 //gtk_widget_draw( drawing->ruler, &rect);
1360 /* Redraw the ruler */
1362 expose_ruler( GtkWidget
*widget
, GdkEventExpose
*event
, gpointer user_data
)
1364 Drawing_t
*drawing
= (Drawing_t
*)user_data
;
1365 TimeWindow time_window
= lttvwindow_get_time_window(drawing
->control_flow_data
->tab
);
1368 PangoContext
*context
;
1369 PangoLayout
*layout
;
1370 PangoFontDescription
*FontDesc
;
1371 PangoRectangle ink_rect
;
1372 gint global_width
=0;
1373 GdkColor foreground
= { 0, 0, 0, 0 };
1374 GdkColor background
= { 0, 0xffff, 0xffff, 0xffff };
1376 LttTime window_end
= time_window
.end_time
;
1377 LttTime half_width
=
1378 ltt_time_div(time_window
.time_width
,2.0);
1379 LttTime window_middle
=
1380 ltt_time_add(half_width
,
1381 time_window
.start_time
);
1382 g_debug("ruler expose event");
1384 gdk_draw_rectangle (drawing
->ruler
->window
,
1385 drawing
->ruler
->style
->white_gc
,
1387 event
->area
.x
, event
->area
.y
,
1389 event
->area
.height
);
1391 gdk_draw_line (drawing
->ruler
->window
,
1392 drawing
->ruler_gc_butt
,
1394 event
->area
.x
+ event
->area
.width
, 1);
1397 snprintf(text
, 255, "%lus\n%luns",
1398 time_window
.start_time
.tv_sec
,
1399 time_window
.start_time
.tv_nsec
);
1401 layout
= gtk_widget_create_pango_layout(drawing
->drawing_area
, NULL
);
1403 context
= pango_layout_get_context(layout
);
1404 FontDesc
= pango_context_get_font_description(context
);
1406 pango_font_description_set_size(FontDesc
, 6*PANGO_SCALE
);
1407 pango_layout_context_changed(layout
);
1409 pango_layout_set_text(layout
, text
, -1);
1410 pango_layout_get_pixel_extents(layout
, &ink_rect
, NULL
);
1411 global_width
+= ink_rect
.width
;
1413 gdk_draw_layout_with_colors(drawing
->ruler
->window
,
1414 drawing
->ruler_gc_butt
,
1417 layout
, &foreground
, &background
);
1419 gdk_draw_line (drawing
->ruler
->window
,
1420 drawing
->ruler_gc_round
,
1425 snprintf(text
, 255, "%lus\n%luns", window_end
.tv_sec
,
1426 window_end
.tv_nsec
);
1428 pango_layout_set_text(layout
, text
, -1);
1429 pango_layout_get_pixel_extents(layout
, &ink_rect
, NULL
);
1430 global_width
+= ink_rect
.width
;
1432 if(global_width
<= drawing
->ruler
->allocation
.width
)
1434 gdk_draw_layout_with_colors(drawing
->ruler
->window
,
1435 drawing
->ruler_gc_butt
,
1436 drawing
->ruler
->allocation
.width
- ink_rect
.width
,
1438 layout
, &foreground
, &background
);
1440 gdk_draw_line (drawing
->ruler
->window
,
1441 drawing
->ruler_gc_butt
,
1442 drawing
->ruler
->allocation
.width
-1, 1,
1443 drawing
->ruler
->allocation
.width
-1, 7);
1447 snprintf(text
, 255, "%lus\n%luns", window_middle
.tv_sec
,
1448 window_middle
.tv_nsec
);
1450 pango_layout_set_text(layout
, text
, -1);
1451 pango_layout_get_pixel_extents(layout
, &ink_rect
, NULL
);
1452 global_width
+= ink_rect
.width
;
1454 if(global_width
<= drawing
->ruler
->allocation
.width
)
1456 gdk_draw_layout_with_colors(drawing
->ruler
->window
,
1457 drawing
->ruler_gc_butt
,
1458 (drawing
->ruler
->allocation
.width
- ink_rect
.width
)/2,
1460 layout
, &foreground
, &background
);
1462 gdk_draw_line (drawing
->ruler
->window
,
1463 drawing
->ruler_gc_butt
,
1464 drawing
->ruler
->allocation
.width
/2, 1,
1465 drawing
->ruler
->allocation
.width
/2, 7);
1472 g_object_unref(layout
);
1478 /* notify mouse on ruler */
1480 motion_notify_ruler(GtkWidget
*widget
, GdkEventMotion
*event
, gpointer user_data
)
1482 //g_debug("motion");
1483 //eventually follow mouse and show time here