return FALSE;
}
+static void
+pgtk_wait_for_map_event (struct frame *f, bool multiple_times)
+{
+ if (FLOATP (Vpgtk_wait_for_event_timeout))
+ {
+ guint msec =
+ (guint) (XFLOAT_DATA (Vpgtk_wait_for_event_timeout) * 1000);
+ int found = 0;
+ int timed_out = 0;
+ gulong id =
+ g_signal_connect (FRAME_WIDGET (f), "map-event",
+ G_CALLBACK
+ (pgtk_make_frame_visible_wait_for_map_event_cb),
+ &found);
+ guint src =
+ g_timeout_add (msec,
+ pgtk_make_frame_visible_wait_for_map_event_timeout,
+ &timed_out);
+
+ if (!multiple_times)
+ {
+ while (!found && !timed_out)
+ gtk_main_iteration ();
+ }
+ else
+ {
+ while (!timed_out)
+ gtk_main_iteration ();
+ }
+
+ g_signal_handler_disconnect (FRAME_WIDGET (f), id);
+ if (!timed_out)
+ g_source_remove (src);
+ }
+}
+
void
pgtk_make_frame_visible (struct frame *f)
/* --------------------------------------------------------------------------
if (win)
gtk_window_deiconify (GTK_WINDOW (win));
- if (FLOATP (Vpgtk_wait_for_event_timeout))
- {
- guint msec =
- (guint) (XFLOAT_DATA (Vpgtk_wait_for_event_timeout) * 1000);
- int found = 0;
- int timed_out = 0;
- gulong id =
- g_signal_connect (FRAME_WIDGET (f), "map-event",
- G_CALLBACK
- (pgtk_make_frame_visible_wait_for_map_event_cb),
- &found);
- guint src =
- g_timeout_add (msec,
- pgtk_make_frame_visible_wait_for_map_event_timeout,
- &timed_out);
- while (!found && !timed_out)
- gtk_main_iteration ();
- g_signal_handler_disconnect (FRAME_WIDGET (f), id);
- if (!timed_out)
- g_source_remove (src);
- }
+ pgtk_wait_for_map_event (f, false);
}
}
gtk_widget_hide (FRAME_WIDGET (f));
+ /* Map events are emitted many times, and
+ * map_event() do SET_FRAME_VISIBLE(f, 1).
+ * I expect visible = 0, so process those map events here and
+ * SET_FRAME_VISIBLE(f, 0) after that.
+ */
+ pgtk_wait_for_map_event (f, true);
+
SET_FRAME_VISIBLE (f, 0);
SET_FRAME_ICONIFIED (f, false);
}