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, 0xBBBB, 0xBBBB, 0xBBBB }, /* COL_IDLE */
90 { 0, 0xFFFF, 0xFFFF, 0xFFFF }, /* COL_BUSY */
91 { 0, 0xFFFF, 0x0000, 0x0000 }, /* COL_UNKNOWN */
95 /*****************************************************************************
97 *****************************************************************************/
100 expose_ruler( GtkWidget
*widget
, GdkEventExpose
*event
, gpointer user_data
);
103 motion_notify_ruler(GtkWidget
*widget
, GdkEventMotion
*event
, gpointer user_data
);
106 /* Function responsible for updating the exposed area.
107 * It must do an events request to the lttvwindow API to ask for this update.
108 * Note : this function cannot clear the background, because it may
109 * erase drawing already present (SAFETY).
111 void drawing_data_request(Drawing_t
*drawing
,
116 if(width
< 0) return ;
117 if(height
< 0) return ;
120 Tab
*tab
= drawing
->control_flow_data
->tab
;
121 TimeWindow time_window
=
122 lttvwindow_get_time_window(tab
);
124 ControlFlowData
*control_flow_data
= drawing
->control_flow_data
;
125 // (ControlFlowData*)g_object_get_data(
126 // G_OBJECT(drawing->drawing_area), "control_flow_data");
128 LttTime start
, time_end
;
129 LttTime window_end
= time_window
.end_time
;
131 g_debug("req : window start_time : %lu, %lu", time_window
.start_time
.tv_sec
,
132 time_window
.start_time
.tv_nsec
);
134 g_debug("req : window time width : %lu, %lu", time_window
.time_width
.tv_sec
,
135 time_window
.time_width
.tv_nsec
);
137 g_debug("req : window_end : %lu, %lu", window_end
.tv_sec
,
140 g_debug("x is : %i, x+width is : %i", x
, x
+width
);
142 convert_pixels_to_time(drawing
->width
, x
,
146 convert_pixels_to_time(drawing
->width
, x
+width
,
149 time_end
= ltt_time_add(time_end
, ltt_time_one
); // because main window
150 // doesn't deliver end time.
152 lttvwindow_events_request_remove_all(tab
,
156 /* find the tracehooks */
157 LttvTracesetContext
*tsc
= lttvwindow_get_traceset_context(tab
);
159 LttvTraceset
*traceset
= tsc
->ts
;
161 guint i
, k
, l
, nb_trace
;
165 LttvTracefileState
*tfs
;
171 LttvTraceHookByFacility
*thf
;
174 gint before_hn
, after_hn
;
176 nb_trace
= lttv_traceset_number(traceset
);
177 // FIXME (fixed) : eventually request for more traces
178 for(i
= 0 ; i
< nb_trace
; i
++) {
179 //for(i = 0; i<MIN(TRACE_NUMBER+1, nb_trace);i++) {
180 EventsRequest
*events_request
= g_new(EventsRequest
, 1);
182 //LttvHooks *event = lttv_hooks_new();
183 LttvHooksById
*event_by_id
= lttv_hooks_by_id_new();
184 LttvHooks
*before_chunk_traceset
= lttv_hooks_new();
185 LttvHooks
*after_chunk_traceset
= lttv_hooks_new();
186 LttvHooks
*before_request_hook
= lttv_hooks_new();
187 LttvHooks
*after_request_hook
= lttv_hooks_new();
189 lttv_hooks_add(before_chunk_traceset
,
194 lttv_hooks_add(after_chunk_traceset
,
199 lttv_hooks_add(before_request_hook
,
204 lttv_hooks_add(after_request_hook
,
210 ts
= (LttvTraceState
*)tsc
->traces
[i
];
212 /* Find the eventtype id for the following events and register the
213 associated by id hooks. */
215 hooks
= g_array_new(FALSE
, FALSE
, sizeof(LttvTraceHook
));
216 hooks
= g_array_set_size(hooks
, 18);
217 before_hn
= after_hn
= 0;
221 // ret = lttv_trace_find_hook(ts->parent.t,
222 // LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_ENTRY,
223 // LTT_FIELD_SYSCALL_ID, 0, 0,
224 // before_execmode_hook,
226 // &g_array_index(hooks, LttvTraceHook, before_hn++));
227 // if(ret) before_hn--;
229 // ret = lttv_trace_find_hook(ts->parent.t,
230 // LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_EXIT,
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_TRAP_ENTRY,
239 // LTT_FIELD_TRAP_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_TRAP_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, LTT_EVENT_IRQ_ENTRY,
255 // LTT_FIELD_IRQ_ID, 0, 0,
256 // before_execmode_hook,
258 // &g_array_index(hooks, LttvTraceHook, before_hn++));
259 // if(ret) before_hn--;
261 // ret = lttv_trace_find_hook(ts->parent.t,
262 // LTT_FACILITY_KERNEL, LTT_EVENT_IRQ_EXIT,
264 // before_execmode_hook,
266 // &g_array_index(hooks, LttvTraceHook, before_hn++));
267 // if(ret) before_hn--;
269 // ret = lttv_trace_find_hook(ts->parent.t,
270 // LTT_FACILITY_KERNEL, LTT_EVENT_SOFT_IRQ_ENTRY,
271 // LTT_FIELD_SOFT_IRQ_ID, 0, 0,
272 // before_execmode_hook,
274 // &g_array_index(hooks, LttvTraceHook, before_hn++));
275 // if(ret) before_hn--;
277 // ret = lttv_trace_find_hook(ts->parent.t,
278 // LTT_FACILITY_KERNEL, LTT_EVENT_SOFT_IRQ_EXIT,
280 // before_execmode_hook,
282 // &g_array_index(hooks, LttvTraceHook, before_hn++));
283 // if(ret) before_hn--;
286 ret
= lttv_trace_find_hook(ts
->parent
.t
,
287 LTT_FACILITY_KERNEL
, LTT_EVENT_SCHED_SCHEDULE
,
288 LTT_FIELD_PREV_PID
, LTT_FIELD_NEXT_PID
, LTT_FIELD_PREV_STATE
,
289 before_schedchange_hook
,
291 &g_array_index(hooks
, LttvTraceHook
, before_hn
++));
294 // ret = lttv_trace_find_hook(ts->parent.t,
295 // LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_EXIT,
296 // LTT_FIELD_PID, 0, 0,
297 // before_process_exit_hook,
299 // &g_array_index(hooks, LttvTraceHook, before_hn++));
300 // if(ret) before_hn--;
302 // ret = lttv_trace_find_hook(ts->parent.t,
303 // LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_FREE,
304 // LTT_FIELD_PID, 0, 0,
305 // before_process_release_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_LIST, LTT_EVENT_STATEDUMP_END,
313 // before_statedump_end,
315 // &g_array_index(hooks, LttvTraceHook, before_hn++));
316 // if(ret) before_hn--;
319 lttv_trace_find_hook(ts
->parent
.t
,
320 "core", "process", "event_sub_id",
321 "event_data1", "event_data2", before_process_hook
,
322 &g_array_index(hooks
, LttvTraceHook
, hn
++));
325 lttv_trace_find_hook(ts
->parent
.t
, "core", "process_fork", "child_pid",
326 NULL
, NULL
, process_fork
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
328 lttv_trace_find_hook(ts
->parent
.t
, "core", "process_exit", NULL
, NULL
,
329 NULL
, process_exit
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
335 /**** DESACTIVATED ****/
336 lttv_trace_find_hook(ts
->parent
.t
, "core","syscall_entry","syscall_id",
337 NULL
, NULL
, after_execmode_hook
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
338 /**** DESACTIVATED ****/
339 lttv_trace_find_hook(ts
->parent
.t
, "core", "syscall_exit", NULL
, NULL
,
340 NULL
, after_execmode_hook
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
342 /**** DESACTIVATED ****/
343 lttv_trace_find_hook(ts
->parent
.t
, "core", "trap_entry", "trap_id",
344 NULL
, NULL
, after_execmode_hook
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
346 /**** DESACTIVATED ****/
347 lttv_trace_find_hook(ts
->parent
.t
, "core", "trap_exit", NULL
, NULL
, NULL
,
348 after_execmode_hook
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
350 /**** DESACTIVATED ****/
351 lttv_trace_find_hook(ts
->parent
.t
, "core", "irq_entry", "irq_id", NULL
,
352 NULL
, after_execmode_hook
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
354 /**** DESACTIVATED ****/
355 lttv_trace_find_hook(ts
->parent
.t
, "core", "irq_exit", NULL
, NULL
, NULL
,
356 after_execmode_hook
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
359 lttv_trace_find_hook(ts
->parent
.t
, "core", "schedchange", "in", "out",
360 "out_state", after_schedchange_hook
,
361 &g_array_index(hooks
, LttvTraceHook
, hn
++));
363 lttv_trace_find_hook(ts
->parent
.t
, "core", "process", "event_sub_id",
364 "event_data1", "event_data2", after_process_hook
,
365 &g_array_index(hooks
, LttvTraceHook
, hn
++));
367 after_hn
= before_hn
;
369 ret
= lttv_trace_find_hook(ts
->parent
.t
,
370 LTT_FACILITY_KERNEL
, LTT_EVENT_SCHED_SCHEDULE
,
371 LTT_FIELD_PREV_PID
, LTT_FIELD_NEXT_PID
, LTT_FIELD_PREV_STATE
,
372 after_schedchange_hook
,
374 &g_array_index(hooks
, LttvTraceHook
, after_hn
++));
377 // ret = lttv_trace_find_hook(ts->parent.t,
378 // LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_FORK,
379 // LTT_FIELD_PARENT_PID, LTT_FIELD_CHILD_PID, 0,
380 // after_process_fork_hook,
382 // &g_array_index(hooks, LttvTraceHook, after_hn++));
383 // if(ret) after_hn--;
385 // ret = lttv_trace_find_hook(ts->parent.t,
386 // LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_EXIT,
387 // LTT_FIELD_PID, 0, 0,
388 // after_process_exit_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_FS, LTT_EVENT_EXEC,
396 // after_fs_exec_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_USER_GENERIC, LTT_EVENT_THREAD_BRAND,
403 // LTT_FIELD_NAME, 0, 0,
404 // after_user_generic_thread_brand_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_LIST, LTT_EVENT_PROCESS_STATE,
411 // LTT_FIELD_PID, LTT_FIELD_PARENT_PID, LTT_FIELD_NAME,
412 // after_event_enum_process_hook,
414 // &g_array_index(hooks, LttvTraceHook, after_hn++));
415 // if(ret) after_hn--;
417 hooks
= g_array_set_size(hooks
, after_hn
);
420 lttv_trace_find_hook(ts
->parent
.t
, "core", "process_fork", "child_pid",
421 NULL
, NULL
, process_fork
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
423 lttv_trace_find_hook(ts
->parent
.t
, "core", "process_exit", NULL
, NULL
,
424 NULL
, process_exit
, &g_array_index(hooks
, LttvTraceHook
, hn
++));
429 /* Add these hooks to each event_by_id hooks list */
431 for(k
= 0 ; k
< before_hn
; k
++) {
432 hook
= &g_array_index(hooks
, LttvTraceHook
, k
);
433 for(l
=0;l
<hook
->fac_list
->len
;l
++) {
434 thf
= g_array_index(hook
->fac_list
, LttvTraceHookByFacility
*, l
);
435 lttv_hooks_add(lttv_hooks_by_id_find(event_by_id
, thf
->id
),
443 for(k
= before_hn
; k
< after_hn
; k
++) {
444 hook
= &g_array_index(hooks
, LttvTraceHook
, k
);
445 for(l
=0;l
<hook
->fac_list
->len
;l
++) {
446 thf
= g_array_index(hook
->fac_list
, LttvTraceHookByFacility
*, l
);
447 lttv_hooks_add(lttv_hooks_by_id_find(event_by_id
, thf
->id
),
454 events_request
->hooks
= hooks
;
456 // Fill the events request
457 events_request
->owner
= control_flow_data
;
458 events_request
->viewer_data
= control_flow_data
;
459 events_request
->servicing
= FALSE
;
460 events_request
->start_time
= start
;
461 events_request
->start_position
= NULL
;
462 events_request
->stop_flag
= FALSE
;
463 events_request
->end_time
= time_end
;
464 events_request
->num_events
= G_MAXUINT
;
465 events_request
->end_position
= NULL
;
466 events_request
->trace
= i
; //fixed /* FIXME */
467 events_request
->before_chunk_traceset
= before_chunk_traceset
;
468 events_request
->before_chunk_trace
= NULL
;
469 events_request
->before_chunk_tracefile
= NULL
;
470 events_request
->event
= NULL
;
471 events_request
->event_by_id
= event_by_id
;
472 events_request
->after_chunk_tracefile
= NULL
;
473 events_request
->after_chunk_trace
= NULL
;
474 events_request
->after_chunk_traceset
= after_chunk_traceset
;
475 events_request
->before_request
= before_request_hook
;
476 events_request
->after_request
= after_request_hook
;
478 g_debug("req : start : %lu, %lu", start
.tv_sec
,
481 g_debug("req : end : %lu, %lu", time_end
.tv_sec
,
484 lttvwindow_events_request(tab
, events_request
);
491 lttv_hooks_add(event
,
492 before_schedchange_hook
,
495 lttv_hooks_add(event
,
496 after_schedchange_hook
,
499 lttv_hooks_add(event
,
500 before_execmode_hook
,
503 lttv_hooks_add(event
,
507 lttv_hooks_add(event
,
511 lttv_hooks_add(event
,
520 static void set_last_start(gpointer key
, gpointer value
, gpointer user_data
)
522 ResourceInfo
*process_info
= (ResourceInfo
*)key
;
523 HashedResourceData
*hashed_process_data
= (HashedResourceData
*)value
;
524 guint x
= (guint
)user_data
;
526 hashed_process_data
->x
.over
= x
;
527 hashed_process_data
->x
.over_used
= FALSE
;
528 hashed_process_data
->x
.over_marked
= FALSE
;
529 hashed_process_data
->x
.middle
= x
;
530 hashed_process_data
->x
.middle_used
= FALSE
;
531 hashed_process_data
->x
.middle_marked
= FALSE
;
532 hashed_process_data
->x
.under
= x
;
533 hashed_process_data
->x
.under_used
= FALSE
;
534 hashed_process_data
->x
.under_marked
= FALSE
;
535 hashed_process_data
->next_good_time
= ltt_time_zero
;
540 void drawing_data_request_begin(EventsRequest
*events_request
, LttvTracesetState
*tss
)
542 g_debug("Begin of data request");
543 ControlFlowData
*cfd
= events_request
->viewer_data
;
544 LttvTracesetContext
*tsc
= LTTV_TRACESET_CONTEXT(tss
);
545 TimeWindow time_window
=
546 lttvwindow_get_time_window(cfd
->tab
);
548 guint width
= cfd
->drawing
->width
;
551 cfd
->drawing
->last_start
= events_request
->start_time
;
553 convert_time_to_pixels(
555 events_request
->start_time
,
559 g_hash_table_foreach(cfd
->process_list
->process_hash
, set_last_start
,
564 void drawing_chunk_begin(EventsRequest
*events_request
, LttvTracesetState
*tss
)
566 g_debug("Begin of chunk");
567 ControlFlowData
*cfd
= events_request
->viewer_data
;
568 LttvTracesetContext
*tsc
= &tss
->parent
.parent
;
569 //LttTime current_time = lttv_traceset_context_get_current_tfc(tsc)->timestamp;
571 LttvTraceset
*traceset
= tsc
->ts
;
572 guint nb_trace
= lttv_traceset_number(traceset
);
574 if(!cfd
->process_list
->current_hash_data
) {
575 cfd
->process_list
->current_hash_data
= g_new(HashedResourceData
**,nb_trace
);
576 for(i
= 0 ; i
< nb_trace
; i
++) {
577 guint num_cpu
= ltt_trace_get_num_cpu(tss
->parent
.traces
[i
]->t
);
578 cfd
->process_list
->current_hash_data
[i
] = g_new(HashedResourceData
*,num_cpu
);
579 memset(cfd
->process_list
->current_hash_data
[i
], 0,
580 sizeof(HashedResourceData
*)*num_cpu
);
583 //cfd->drawing->last_start = LTT_TIME_MIN(current_time,
584 // events_request->end_time);
588 void drawing_request_expose(EventsRequest
*events_request
,
589 LttvTracesetState
*tss
,
595 ControlFlowData
*cfd
= events_request
->viewer_data
;
596 LttvTracesetContext
*tsc
= (LttvTracesetContext
*)tss
;
597 Drawing_t
*drawing
= cfd
->drawing
;
599 TimeWindow time_window
=
600 lttvwindow_get_time_window(cfd
->tab
);
602 g_debug("request expose");
604 convert_time_to_pixels(
609 x
= drawing
->damage_begin
;
613 drawing
->damage_begin
= x
+width
;
616 gtk_widget_queue_draw_area ( drawing
->drawing_area
,
618 width
, drawing
->drawing_area
->allocation
.height
);
620 /* Update directly when scrolling */
621 gdk_window_process_updates(drawing
->drawing_area
->window
,
629 /* Create a new backing pixmap of the appropriate size */
630 /* As the scaling will always change, it's of no use to copy old
633 * Only change the size if width changes. The height is specified and changed
634 * when process ID are added or removed from the process list.
637 configure_event( GtkWidget
*widget
, GdkEventConfigure
*event
,
640 Drawing_t
*drawing
= (Drawing_t
*)user_data
;
643 /* First, get the new time interval of the main window */
644 /* we assume (see documentation) that the main window
645 * has updated the time interval before this configure gets
648 //lttvwindow_get_time_window(drawing->control_flow_data->mw,
649 // &drawing->control_flow_data->time_window);
651 /* New pixmap, size of the configure event */
652 //GdkPixmap *pixmap = gdk_pixmap_new(widget->window,
653 // widget->allocation.width + SAFETY,
654 // widget->allocation.height + SAFETY,
657 if(widget
->allocation
.width
!= drawing
->width
) {
658 g_debug("drawing configure event");
659 g_debug("New alloc draw size : %i by %i",widget
->allocation
.width
,
660 widget
->allocation
.height
);
662 drawing
->width
= widget
->allocation
.width
;
664 if(drawing
->alloc_width
< widget
->allocation
.width
) {
665 //if(drawing->pixmap)
666 // gdk_pixmap_unref(drawing->pixmap);
668 //drawing->pixmap = gdk_pixmap_new(widget->window,
669 // drawing->width + SAFETY + EXTRA_ALLOC,
670 // drawing->height + EXTRA_ALLOC,
672 drawing
->alloc_width
= drawing
->width
+ SAFETY
+ EXTRA_ALLOC
;
673 drawing
->alloc_height
= drawing
->height
+ EXTRA_ALLOC
;
674 update_pixmap_size(drawing
->control_flow_data
->process_list
,
675 drawing
->alloc_width
);
676 update_index_to_pixmap(drawing
->control_flow_data
->process_list
);
678 //drawing->height = widget->allocation.height;
680 //ProcessList_get_height
681 // (GuiControlFlow_get_process_list(drawing->control_flow_data)),
685 //gdk_draw_rectangle (drawing->pixmap,
686 // widget->style->black_gc,
689 // drawing->width+SAFETY,
692 //g_info("init data request");
695 /* Initial data request */
696 /* no, do initial data request in the expose event */
697 // Do not need to ask for data of 1 pixel : not synchronized with
698 // main window time at this moment.
699 //drawing_data_request(drawing, &drawing->pixmap, 0, 0,
700 // widget->allocation.width,
701 // widget->allocation.height);
703 //drawing->width = widget->allocation.width;
704 //drawing->height = widget->allocation.height;
706 drawing
->damage_begin
= 0;
707 drawing
->damage_end
= widget
->allocation
.width
;
709 if((widget
->allocation
.width
!= 1 &&
710 widget
->allocation
.height
!= 1)
711 && drawing
->damage_begin
< drawing
->damage_end
)
714 rectangle_pixmap (drawing
->control_flow_data
->process_list
,
715 drawing
->drawing_area
->style
->black_gc
,
718 drawing
->alloc_width
, // do not overlap
722 drawing_data_request(drawing
,
723 drawing
->damage_begin
,
725 drawing
->damage_end
- drawing
->damage_begin
,
733 /* Redraw the screen from the backing pixmap */
735 expose_event( GtkWidget
*widget
, GdkEventExpose
*event
, gpointer user_data
)
737 Drawing_t
*drawing
= (Drawing_t
*)user_data
;
739 ControlFlowData
*control_flow_data
=
740 (ControlFlowData
*)g_object_get_data(
742 "control_flow_data");
744 if(unlikely(drawing
->gc
== NULL
)) {
745 drawing
->gc
= gdk_gc_new(drawing
->drawing_area
->window
);
746 gdk_gc_copy(drawing
->gc
, drawing
->drawing_area
->style
->black_gc
);
749 TimeWindow time_window
=
750 lttvwindow_get_time_window(control_flow_data
->tab
);
751 LttTime current_time
=
752 lttvwindow_get_current_time(control_flow_data
->tab
);
756 LttTime window_end
= time_window
.end_time
;
758 /* update the screen from the pixmap buffer */
760 gdk_draw_pixmap(widget
->window
,
761 widget
->style
->fg_gc
[GTK_WIDGET_STATE (widget
)],
763 event
->area
.x
, event
->area
.y
,
764 event
->area
.x
, event
->area
.y
,
765 event
->area
.width
, event
->area
.height
);
767 drawing
->height
= processlist_get_height(control_flow_data
->process_list
);
769 copy_pixmap_to_screen(control_flow_data
->process_list
,
771 widget
->style
->fg_gc
[GTK_WIDGET_STATE (widget
)],
772 event
->area
.x
, event
->area
.y
,
773 event
->area
.width
, event
->area
.height
);
775 copy_pixmap_to_screen(control_flow_data
->process_list
,
778 event
->area
.x
, event
->area
.y
,
779 event
->area
.width
, event
->area
.height
);
782 /* Erase the dotted lines left.. */
783 if(widget
->allocation
.height
> drawing
->height
)
785 gdk_draw_rectangle (widget
->window
,
786 drawing
->drawing_area
->style
->black_gc
,
788 event
->area
.x
, drawing
->height
,
789 event
->area
.width
, // do not overlap
790 widget
->allocation
.height
- drawing
->height
);
792 if(ltt_time_compare(time_window
.start_time
, current_time
) <= 0 &&
793 ltt_time_compare(window_end
, current_time
) >= 0)
795 /* Draw the dotted lines */
796 convert_time_to_pixels(
803 if(drawing
->dotted_gc
== NULL
) {
805 drawing
->dotted_gc
= gdk_gc_new(drawing
->drawing_area
->window
);
806 gdk_gc_copy(drawing
->dotted_gc
, widget
->style
->white_gc
);
808 gint8 dash_list
[] = { 1, 2 };
809 gdk_gc_set_line_attributes(drawing
->dotted_gc
,
811 GDK_LINE_ON_OFF_DASH
,
814 gdk_gc_set_dashes(drawing
->dotted_gc
,
820 gint height_tot
= MAX(widget
->allocation
.height
, drawing
->height
);
821 gdk_draw_line(widget
->window
,
824 cursor_x
, height_tot
);
830 after_expose_event( GtkWidget
*widget
, GdkEventExpose
*event
, gpointer user_data
)
833 g_debug("AFTER EXPOSE");
842 tree_row_activated(GtkTreeModel
*treemodel
,
844 GtkTreeViewColumn
*arg2
,
847 ControlFlowData
*cfd
= (ControlFlowData
*)user_data
;
848 Drawing_t
*drawing
= cfd
->drawing
;
849 GtkTreeView
*treeview
= cfd
->process_list
->process_list_widget
;
853 path_indices
= gtk_tree_path_get_indices (arg1
);
855 height
= get_cell_height(cfd
->process_list
,
856 GTK_TREE_VIEW(treeview
));
857 drawing
->horizontal_sel
= height
* path_indices
[0];
858 g_critical("new hor sel : %i", drawing
->horizontal_sel
);
864 button_press_event( GtkWidget
*widget
, GdkEventButton
*event
, gpointer user_data
)
866 ControlFlowData
*control_flow_data
=
867 (ControlFlowData
*)g_object_get_data(
869 "control_flow_data");
870 Drawing_t
*drawing
= control_flow_data
->drawing
;
871 TimeWindow time_window
=
872 lttvwindow_get_time_window(control_flow_data
->tab
);
875 if(event
->button
== 1)
879 /* left mouse button click */
880 g_debug("x click is : %f", event
->x
);
882 convert_pixels_to_time(drawing
->width
, (guint
)event
->x
,
886 lttvwindow_report_current_time(control_flow_data
->tab
, time
);
894 scrollbar_size_allocate(GtkWidget
*widget
,
895 GtkAllocation
*allocation
,
898 Drawing_t
*drawing
= (Drawing_t
*)user_data
;
900 gtk_widget_set_size_request(drawing
->padding
, allocation
->width
, -1);
901 //gtk_widget_queue_resize(drawing->padding);
902 //gtk_widget_queue_resize(drawing->ruler);
903 gtk_container_check_resize(GTK_CONTAINER(drawing
->ruler_hbox
));
909 Drawing_t
*drawing_construct(ControlFlowData
*control_flow_data
)
911 Drawing_t
*drawing
= g_new(Drawing_t
, 1);
913 drawing
->control_flow_data
= control_flow_data
;
915 drawing
->vbox
= gtk_vbox_new(FALSE
, 1);
918 drawing
->ruler_hbox
= gtk_hbox_new(FALSE
, 1);
919 drawing
->ruler
= gtk_drawing_area_new ();
920 //gtk_widget_set_size_request(drawing->ruler, -1, 27);
922 drawing
->padding
= gtk_drawing_area_new ();
923 //gtk_widget_set_size_request(drawing->padding, -1, 27);
924 gtk_box_pack_start(GTK_BOX(drawing
->ruler_hbox
), drawing
->ruler
,
926 gtk_box_pack_end(GTK_BOX(drawing
->ruler_hbox
), drawing
->padding
,
931 drawing
->drawing_area
= gtk_drawing_area_new ();
935 drawing
->hbox
= gtk_hbox_new(FALSE
, 1);
936 drawing
->viewport
= gtk_viewport_new(NULL
, control_flow_data
->v_adjust
);
937 drawing
->scrollbar
= gtk_vscrollbar_new(control_flow_data
->v_adjust
);
938 gtk_box_pack_start(GTK_BOX(drawing
->hbox
), drawing
->viewport
,
940 gtk_box_pack_end(GTK_BOX(drawing
->hbox
), drawing
->scrollbar
,
943 //drawing->scrolled_window =
944 // gtk_scrolled_window_new (NULL,
945 // control_flow_data->v_adjust);
947 //gtk_scrolled_window_set_policy(
948 // GTK_SCROLLED_WINDOW(drawing->scrolled_window),
950 // GTK_POLICY_AUTOMATIC);
952 gtk_container_add(GTK_CONTAINER(drawing
->viewport
),
953 drawing
->drawing_area
);
954 //gtk_scrolled_window_add_with_viewport(
955 // GTK_SCROLLED_WINDOW(drawing->scrolled_window),
956 // drawing->drawing_area);
958 gtk_box_pack_start(GTK_BOX(drawing
->vbox
), drawing
->ruler_hbox
,
960 gtk_box_pack_end(GTK_BOX(drawing
->vbox
), drawing
->hbox
,
963 drawing
->pango_layout
=
964 gtk_widget_create_pango_layout(drawing
->drawing_area
, NULL
);
969 drawing
->alloc_height
= 1;
970 drawing
->alloc_width
= 1;
972 drawing
->damage_begin
= 0;
973 drawing
->damage_end
= 0;
974 drawing
->horizontal_sel
= -1;
976 //gtk_widget_set_size_request(drawing->drawing_area->window, 50, 50);
977 g_object_set_data_full(
978 G_OBJECT(drawing
->drawing_area
),
981 (GDestroyNotify
)drawing_destroy
);
984 G_OBJECT(drawing
->ruler
),
989 //gtk_widget_modify_bg( drawing->drawing_area,
991 // &CF_Colors[BLACK]);
993 //gdk_window_get_geometry(drawing->drawing_area->window,
995 // &(drawing->width),
996 // &(drawing->height),
999 //drawing->pixmap = gdk_pixmap_new(
1000 // drawing->drawing_area->window,
1005 //drawing->pixmap = NULL;
1007 // drawing->pixmap = gdk_pixmap_new(drawing->drawing_area->window,
1008 // drawing->drawing_area->allocation.width,
1009 // drawing->drawing_area->allocation.height,
1012 g_signal_connect (G_OBJECT(drawing
->drawing_area
),
1014 G_CALLBACK (configure_event
),
1017 g_signal_connect (G_OBJECT(drawing
->ruler
),
1019 G_CALLBACK(expose_ruler
),
1022 gtk_widget_add_events(drawing
->ruler
, GDK_POINTER_MOTION_MASK
);
1024 g_signal_connect (G_OBJECT(drawing
->ruler
),
1025 "motion-notify-event",
1026 G_CALLBACK(motion_notify_ruler
),
1030 g_signal_connect (G_OBJECT(drawing
->scrollbar
),
1032 G_CALLBACK(scrollbar_size_allocate
),
1037 g_signal_connect (G_OBJECT(drawing
->drawing_area
),
1039 G_CALLBACK (expose_event
),
1042 g_signal_connect_after (G_OBJECT(drawing
->drawing_area
),
1044 G_CALLBACK (after_expose_event
),
1047 g_signal_connect (G_OBJECT(drawing
->drawing_area
),
1048 "button-press-event",
1049 G_CALLBACK (button_press_event
),
1053 gtk_widget_show(drawing
->ruler
);
1054 gtk_widget_show(drawing
->padding
);
1055 gtk_widget_show(drawing
->ruler_hbox
);
1057 gtk_widget_show(drawing
->drawing_area
);
1058 //gtk_widget_show(drawing->scrolled_window);
1059 gtk_widget_show(drawing
->viewport
);
1060 gtk_widget_show(drawing
->scrollbar
);
1061 gtk_widget_show(drawing
->hbox
);
1063 /* Allocate the colors */
1064 GdkColormap
* colormap
= gdk_colormap_get_system();
1065 gboolean success
[NUM_COLORS
];
1066 //gdk_colormap_alloc_colors(colormap, drawing_colors, NUM_COLORS, FALSE,
1068 gdk_colormap_alloc_colors(colormap
, drawing_colors_cpu
, NUM_COLORS_CPU
, FALSE
,
1072 gdk_gc_new(GDK_DRAWABLE(main_window_get_widget(control_flow_data
->tab
)->window
));
1073 drawing
->dotted_gc
=
1074 gdk_gc_new(GDK_DRAWABLE(main_window_get_widget(control_flow_data
->tab
)->window
));
1076 gdk_gc_copy(drawing
->gc
,
1077 main_window_get_widget(control_flow_data
->tab
)->style
->black_gc
);
1078 gdk_gc_copy(drawing
->dotted_gc
,
1079 main_window_get_widget(control_flow_data
->tab
)->style
->white_gc
);
1081 gint8 dash_list
[] = { 1, 2 };
1082 gdk_gc_set_line_attributes(drawing
->dotted_gc
,
1084 GDK_LINE_ON_OFF_DASH
,
1087 gdk_gc_set_dashes(drawing
->dotted_gc
,
1092 drawing
->ruler_gc_butt
=
1093 gdk_gc_new(GDK_DRAWABLE(main_window_get_widget(control_flow_data
->tab
)->window
));
1094 gdk_gc_copy(drawing
->ruler_gc_butt
,
1095 main_window_get_widget(control_flow_data
->tab
)->style
->black_gc
);
1096 drawing
->ruler_gc_round
=
1097 gdk_gc_new(GDK_DRAWABLE(main_window_get_widget(control_flow_data
->tab
)->window
));
1098 gdk_gc_copy(drawing
->ruler_gc_round
,
1099 main_window_get_widget(control_flow_data
->tab
)->style
->black_gc
);
1102 gdk_gc_set_line_attributes(drawing
->ruler_gc_butt
,
1108 gdk_gc_set_line_attributes(drawing
->ruler_gc_round
,
1118 void drawing_destroy(Drawing_t
*drawing
)
1120 g_info("drawing_destroy %p", drawing
);
1122 /* Free the colors */
1123 GdkColormap
* colormap
= gdk_colormap_get_system();
1125 //gdk_colormap_free_colors(colormap, drawing_colors, NUM_COLORS);
1126 gdk_colormap_free_colors(colormap
, drawing_colors_cpu
, NUM_COLORS_CPU
);
1130 // Do not unref here, Drawing_t destroyed by it's widget.
1131 //g_object_unref( G_OBJECT(drawing->drawing_area));
1132 if(drawing
->gc
!= NULL
)
1133 gdk_gc_unref(drawing
->gc
);
1135 g_object_unref(drawing
->pango_layout
);
1136 if(drawing
->dotted_gc
!= NULL
) gdk_gc_unref(drawing
->dotted_gc
);
1137 if(drawing
->ruler_gc_butt
!= NULL
) gdk_gc_unref(drawing
->ruler_gc_butt
);
1138 if(drawing
->ruler_gc_round
!= NULL
) gdk_gc_unref(drawing
->ruler_gc_round
);
1141 g_info("drawing_destroy end");
1144 GtkWidget
*drawing_get_drawing_area(Drawing_t
*drawing
)
1146 return drawing
->drawing_area
;
1149 GtkWidget
*drawing_get_widget(Drawing_t
*drawing
)
1151 return drawing
->vbox
;
1154 void drawing_draw_line( Drawing_t
*drawing
,
1160 gdk_draw_line (pixmap
,
1165 void drawing_clear(Drawing_t
*drawing
)
1167 //if (drawing->pixmap)
1168 // gdk_pixmap_unref(drawing->pixmap);
1169 ControlFlowData
*cfd
= drawing
->control_flow_data
;
1172 rectangle_pixmap(cfd
->process_list
,
1173 drawing
->drawing_area
->style
->black_gc
,
1176 drawing
->alloc_width
, // do not overlap
1179 //drawing->height = 1;
1180 /* Allocate a new pixmap with new height */
1181 //drawing->pixmap = gdk_pixmap_new(drawing->drawing_area->window,
1182 // drawing->width + SAFETY + EXTRA_ALLOC,
1183 // drawing->height + EXTRA_ALLOC,
1185 //drawing->alloc_width = drawing->width + SAFETY + EXTRA_ALLOC;
1186 //drawing->alloc_height = drawing->height + EXTRA_ALLOC;
1188 //gtk_widget_set_size_request(drawing->drawing_area,
1190 // drawing->height);
1191 //gtk_widget_queue_resize_no_redraw(drawing->drawing_area);
1193 /* ask for the buffer to be redrawn */
1194 gtk_widget_queue_draw ( drawing
->drawing_area
);
1198 /* Insert a square corresponding to a new process in the list */
1199 /* Applies to whole drawing->width */
1200 void drawing_insert_square(Drawing_t
*drawing
,
1204 //GdkRectangle update_rect;
1205 gboolean reallocate
= FALSE
;
1206 GdkPixmap
*new_pixmap
;
1208 /* Allocate a new pixmap with new height */
1209 if(drawing
->alloc_height
< drawing
->height
+ height
) {
1211 new_pixmap
= gdk_pixmap_new(drawing
->drawing_area
->window
,
1212 drawing
->width
+ SAFETY
+ EXTRA_ALLOC
,
1213 drawing
->height
+ height
+ EXTRA_ALLOC
,
1215 drawing
->alloc_width
= drawing
->width
+ SAFETY
+ EXTRA_ALLOC
;
1216 drawing
->alloc_height
= drawing
->height
+ height
+ EXTRA_ALLOC
;
1219 /* Copy the high region */
1220 gdk_draw_pixmap (new_pixmap
,
1221 drawing
->drawing_area
->style
->black_gc
,
1225 drawing
->width
+ SAFETY
, y
);
1228 new_pixmap
= drawing
->pixmap
;
1231 //GdkPixmap *pixmap = gdk_pixmap_new(drawing->drawing_area->window,
1232 // drawing->width + SAFETY,
1233 // drawing->height + height,
1236 /* add an empty square */
1237 gdk_draw_rectangle (new_pixmap
,
1238 drawing
->drawing_area
->style
->black_gc
,
1241 drawing
->width
+ SAFETY
, // do not overlap
1244 /* copy the bottom of the region */
1245 gdk_draw_pixmap (new_pixmap
,
1246 drawing
->drawing_area
->style
->black_gc
,
1250 drawing
->width
+SAFETY
, drawing
->height
- y
);
1253 if(reallocate
&& likely(drawing
->pixmap
)) {
1254 gdk_pixmap_unref(drawing
->pixmap
);
1255 drawing
->pixmap
= new_pixmap
;
1258 if(unlikely(drawing
->height
==1)) drawing
->height
= height
;
1259 else drawing
->height
+= height
;
1261 gtk_widget_set_size_request(drawing
->drawing_area
,
1264 gtk_widget_queue_resize_no_redraw(drawing
->drawing_area
);
1266 /* ask for the buffer to be redrawn */
1267 gtk_widget_queue_draw_area ( drawing
->drawing_area
,
1269 drawing
->width
, drawing
->height
-y
);
1273 /* Remove a square corresponding to a removed process in the list */
1274 void drawing_remove_square(Drawing_t
*drawing
,
1280 if(unlikely((guint
)drawing
->height
== height
)) {
1281 //pixmap = gdk_pixmap_new(
1282 // drawing->drawing_area->window,
1283 // drawing->width + SAFETY,
1286 pixmap
= drawing
->pixmap
;
1289 /* Allocate a new pixmap with new height */
1290 //pixmap = gdk_pixmap_new(
1291 // drawing->drawing_area->window,
1292 // drawing->width + SAFETY,
1293 // drawing->height - height,
1295 /* Keep the same preallocated pixmap */
1296 pixmap
= drawing
->pixmap
;
1298 /* Copy the high region */
1299 gdk_draw_pixmap (pixmap
,
1300 drawing
->drawing_area
->style
->black_gc
,
1304 drawing
->width
+ SAFETY
, y
);
1306 /* Copy up the bottom of the region */
1307 gdk_draw_pixmap (pixmap
,
1308 drawing
->drawing_area
->style
->black_gc
,
1312 drawing
->width
, drawing
->height
- y
- height
);
1314 drawing
->height
-=height
;
1317 //if(likely(drawing->pixmap))
1318 // gdk_pixmap_unref(drawing->pixmap);
1320 //drawing->pixmap = pixmap;
1322 gtk_widget_set_size_request(drawing
->drawing_area
,
1325 gtk_widget_queue_resize_no_redraw(drawing
->drawing_area
);
1326 /* ask for the buffer to be redrawn */
1327 gtk_widget_queue_draw_area ( drawing
->drawing_area
,
1329 drawing
->width
, MAX(drawing
->height
-y
, 1));
1333 void drawing_update_ruler(Drawing_t
*drawing
, TimeWindow
*time_window
)
1338 req
.width
= drawing
->ruler
->allocation
.width
;
1339 req
.height
= drawing
->ruler
->allocation
.height
;
1344 rect
.width
= req
.width
;
1345 rect
.height
= req
.height
;
1347 gtk_widget_queue_draw(drawing
->ruler
);
1348 //gtk_widget_draw( drawing->ruler, &rect);
1351 /* Redraw the ruler */
1353 expose_ruler( GtkWidget
*widget
, GdkEventExpose
*event
, gpointer user_data
)
1355 Drawing_t
*drawing
= (Drawing_t
*)user_data
;
1356 TimeWindow time_window
= lttvwindow_get_time_window(drawing
->control_flow_data
->tab
);
1359 PangoContext
*context
;
1360 PangoLayout
*layout
;
1361 PangoFontDescription
*FontDesc
;
1362 PangoRectangle ink_rect
;
1363 gint global_width
=0;
1364 GdkColor foreground
= { 0, 0, 0, 0 };
1365 GdkColor background
= { 0, 0xffff, 0xffff, 0xffff };
1367 LttTime window_end
= time_window
.end_time
;
1368 LttTime half_width
=
1369 ltt_time_div(time_window
.time_width
,2.0);
1370 LttTime window_middle
=
1371 ltt_time_add(half_width
,
1372 time_window
.start_time
);
1373 g_debug("ruler expose event");
1375 gdk_draw_rectangle (drawing
->ruler
->window
,
1376 drawing
->ruler
->style
->white_gc
,
1378 event
->area
.x
, event
->area
.y
,
1380 event
->area
.height
);
1382 gdk_draw_line (drawing
->ruler
->window
,
1383 drawing
->ruler_gc_butt
,
1385 event
->area
.x
+ event
->area
.width
, 1);
1388 snprintf(text
, 255, "%lus\n%luns",
1389 time_window
.start_time
.tv_sec
,
1390 time_window
.start_time
.tv_nsec
);
1392 layout
= gtk_widget_create_pango_layout(drawing
->drawing_area
, NULL
);
1394 context
= pango_layout_get_context(layout
);
1395 FontDesc
= pango_context_get_font_description(context
);
1397 pango_font_description_set_size(FontDesc
, 6*PANGO_SCALE
);
1398 pango_layout_context_changed(layout
);
1400 pango_layout_set_text(layout
, text
, -1);
1401 pango_layout_get_pixel_extents(layout
, &ink_rect
, NULL
);
1402 global_width
+= ink_rect
.width
;
1404 gdk_draw_layout_with_colors(drawing
->ruler
->window
,
1405 drawing
->ruler_gc_butt
,
1408 layout
, &foreground
, &background
);
1410 gdk_draw_line (drawing
->ruler
->window
,
1411 drawing
->ruler_gc_round
,
1416 snprintf(text
, 255, "%lus\n%luns", window_end
.tv_sec
,
1417 window_end
.tv_nsec
);
1419 pango_layout_set_text(layout
, text
, -1);
1420 pango_layout_get_pixel_extents(layout
, &ink_rect
, NULL
);
1421 global_width
+= ink_rect
.width
;
1423 if(global_width
<= drawing
->ruler
->allocation
.width
)
1425 gdk_draw_layout_with_colors(drawing
->ruler
->window
,
1426 drawing
->ruler_gc_butt
,
1427 drawing
->ruler
->allocation
.width
- ink_rect
.width
,
1429 layout
, &foreground
, &background
);
1431 gdk_draw_line (drawing
->ruler
->window
,
1432 drawing
->ruler_gc_butt
,
1433 drawing
->ruler
->allocation
.width
-1, 1,
1434 drawing
->ruler
->allocation
.width
-1, 7);
1438 snprintf(text
, 255, "%lus\n%luns", window_middle
.tv_sec
,
1439 window_middle
.tv_nsec
);
1441 pango_layout_set_text(layout
, text
, -1);
1442 pango_layout_get_pixel_extents(layout
, &ink_rect
, NULL
);
1443 global_width
+= ink_rect
.width
;
1445 if(global_width
<= drawing
->ruler
->allocation
.width
)
1447 gdk_draw_layout_with_colors(drawing
->ruler
->window
,
1448 drawing
->ruler_gc_butt
,
1449 (drawing
->ruler
->allocation
.width
- ink_rect
.width
)/2,
1451 layout
, &foreground
, &background
);
1453 gdk_draw_line (drawing
->ruler
->window
,
1454 drawing
->ruler_gc_butt
,
1455 drawing
->ruler
->allocation
.width
/2, 1,
1456 drawing
->ruler
->allocation
.width
/2, 7);
1463 g_object_unref(layout
);
1469 /* notify mouse on ruler */
1471 motion_notify_ruler(GtkWidget
*widget
, GdkEventMotion
*event
, gpointer user_data
)
1473 //g_debug("motion");
1474 //eventually follow mouse and show time here