delay the window show after the status is attempted to be draw
authorJean-Philippe Orsini <jeanfi@gmail.com>
Fri, 11 Nov 2011 10:52:53 +0000 (10:52 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Fri, 11 Nov 2011 10:52:53 +0000 (10:52 +0000)
src/main.c
src/ui.c

index d2d7e8b..8c27902 100644 (file)
@@ -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);
index f13cdf6..2ecc18c 100644 (file)
--- 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)