From 5cb9392775e84ae4ef0d32e42b9c1f71fb86544c Mon Sep 17 00:00:00 2001 From: Soeren Sandmann Date: Thu, 26 May 2005 05:11:35 +0000 Subject: [PATCH] Grab focus on the callers view, not the descendants view. Thu May 26 01:10:45 2005 Soeren Sandmann * sysprof.c (on_callers_row_activated): Grab focus on the callers view, not the descendants view. * sysprof.c (on_read): Add a short "dead" period after a reset, so that 'samples' will actually be 0 for a while. --- ChangeLog | 12 ++++++++++++ sysprof.c | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index cd99625..7a26bee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,21 @@ +Thu May 26 01:10:45 2005 Soeren Sandmann + + * sysprof.c (on_callers_row_activated): Grab focus on the callers + view, not the descendants view. + + * sysprof.c (on_read): Add a short "dead" period after a reset, + so that 'samples' will actually be 0 for a while. + Mon May 23 01:37:26 2005 Soeren Sandmann * README: Remove comment about auto* stuff, link to http://www.daimi.au.dk/~sandmann/sysprof/ +Sun May 23 16:10:00 2005 Soeren Sandmann + + -=-=-=-=-=- Release v. 0.9 -=-=-=-=-=- + Sun May 22 21:06:36 2005 Soeren Sandmann * TODO: Updates diff --git a/sysprof.c b/sysprof.c index 85a5828..852760d 100644 --- a/sysprof.c +++ b/sysprof.c @@ -104,6 +104,7 @@ struct Application * * Model/View/Controller is a possibility. */ + GTimeVal latest_reset; }; static gboolean @@ -319,11 +320,30 @@ on_timeout (gpointer data) } #endif +static double +timeval_to_ms (const GTimeVal *timeval) +{ + return (timeval->tv_sec * G_USEC_PER_SEC + timeval->tv_usec) / 1000.0; +} + +static double +time_diff (const GTimeVal *first, + const GTimeVal *second) +{ + double first_ms = timeval_to_ms (first); + double second_ms = timeval_to_ms (second); + + return first_ms - second_ms; +} + +#define RESET_DEAD_PERIOD 25 + static void on_read (gpointer data) { Application *app = data; SysprofStackTrace trace; + GTimeVal now; int rd; rd = read (app->input_fd, &trace, sizeof (trace)); @@ -334,6 +354,14 @@ on_read (gpointer data) if (rd == -1 && errno == EWOULDBLOCK) return; + g_get_current_time (&now); + + /* After a reset we ignore samples for a short period so that + * a reset will actually cause 'samples' to become 0 + */ + if (time_diff (&now, &app->latest_reset) < RESET_DEAD_PERIOD) + return; + #if 0 int i; g_print ("pid: %d\n", trace.pid); @@ -416,6 +444,7 @@ delete_data (Application *app) queue_show_samples (app); app->profile_from_file = FALSE; set_application_title (app, NULL); + g_get_current_time (&app->latest_reset); } static void @@ -1194,7 +1223,7 @@ on_callers_row_activated (GtkTreeView *tree_view, goto_object (app, tree_view, path, CALLERS_OBJECT); - gtk_widget_grab_focus (GTK_WIDGET (app->object_view)); + gtk_widget_grab_focus (GTK_WIDGET (app->callers_view)); } static void @@ -1370,6 +1399,8 @@ application_new (void) app->stash = stack_stash_new (); app->input_fd = -1; app->state = INITIAL; + + g_get_current_time (&app->latest_reset); return app; } -- 2.7.4