1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-03-02 11:50:48 -08:00

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.
This commit is contained in:
Yuuki Harano 2021-05-09 17:53:20 +09:00
parent 647e4a92bb
commit ca0b1b9fe5

View file

@ -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);
}