From: Jean-Philippe Orsini Date: Fri, 11 Nov 2011 10:52:53 +0000 (+0000) Subject: delay the window show after the status is attempted to be draw X-Git-Tag: v0.8.0.5~566 X-Git-Url: https://git.wpitchoune.net/gitweb/?p=psensor.git;a=commitdiff_plain;h=7455357fec8cb68e67eca0632dc17d8fea5a145a delay the window show after the status is attempted to be draw --- diff --git a/src/main.c b/src/main.c index d2d7e8b..8c27902 100644 --- a/src/main.c +++ b/src/main.c @@ -327,6 +327,24 @@ static struct option long_options[] = { {0, 0, 0, 0} }; +static gboolean initial_window_show(gpointer data) +{ + struct ui_psensor *ui; + + ui = (struct ui_psensor *)data; + + log_printf(LOG_DEBUG, + "is_status_supported: %d\n", is_status_supported()); + + if (!ui->config->hide_on_startup + || (!is_appindicator_supported() && !is_status_supported())) + ui_window_show(ui); + + ui_window_update(ui); + + return FALSE; +} + int main(int argc, char **argv) { struct ui_psensor ui; @@ -432,7 +450,13 @@ int main(int argc, char **argv) /* sensor list */ ui_sensorlist_create(&ui); - ui_window_update(&ui); + /* + * show the window as soon as all gtk event has been processed + * in order to ensure that the status icon is attempted to be + * drawn before. If not, there is no way to detect that it is + * visible. + */ + g_idle_add((GSourceFunc)initial_window_show, &ui); thread = g_thread_create((GThreadFunc) update_psensor_measures, &ui, TRUE, &error); diff --git a/src/ui.c b/src/ui.c index f13cdf6..2ecc18c 100644 --- a/src/ui.c +++ b/src/ui.c @@ -274,14 +274,7 @@ void ui_window_create(struct ui_psensor *ui) ui->main_window = window; ui->menu_bar = menubar; - log_printf(LOG_DEBUG, - "is_status_supported: %d\n", is_status_supported()); - - if (cfg->hide_on_startup - && (is_appindicator_supported() || is_status_supported())) - gtk_widget_show_all(ui->main_box); - else - ui_window_show(ui); + gtk_widget_show_all(ui->main_box); } static void menu_bar_show(unsigned int show, struct ui_psensor *ui)