]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix pgtk_make_frame_visible doesn't work
authorYuuki Harano <masm+github@masm11.me>
Sun, 9 May 2021 08:53:20 +0000 (17:53 +0900)
committerYuuki Harano <masm+github@masm11.me>
Sun, 9 May 2021 08:53:20 +0000 (17:53 +0900)
* 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.

src/pgtkterm.c

index 3839b2b3fc421ff6cf259c58a43311db5d1b6e22..5331b67e331bb4d950a68428242772eeb40f0657 100644 (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);
 }