From: Yuuki Harano Date: Sun, 9 May 2021 08:53:20 +0000 (+0900) Subject: Fix pgtk_make_frame_visible doesn't work X-Git-Tag: emacs-29.0.90~3705 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ca0b1b9fe5a9eb225d4cfd1fd52f9e6e56d5fa5f;p=emacs.git Fix pgtk_make_frame_visible doesn't work * src/pgtkterm.c (pgtk_wait_for_map_event): New function to wait for map events. The content is moved from pgtk_make_frame_visible. (pgtk_make_frame_visible): Call pgtk_wait_for_map_event, instead of process here directly. (pgtk_make_frame_invisible): Call pgtk_wait_for_map_event to wait for multiple map events. --- diff --git a/src/pgtkterm.c b/src/pgtkterm.c index 3839b2b3fc4..5331b67e331 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c @@ -591,6 +591,42 @@ pgtk_make_frame_visible_wait_for_map_event_timeout (gpointer user_data) 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) /* -------------------------------------------------------------------------- @@ -607,27 +643,7 @@ 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); } } @@ -642,6 +658,13 @@ pgtk_make_frame_invisible (struct frame *f) 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); }