emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/pgtk ca0b1b9: Fix pgtk_make_frame_visible doesn't work


From: Yuuki Harano
Subject: feature/pgtk ca0b1b9: Fix pgtk_make_frame_visible doesn't work
Date: Sun, 9 May 2021 05:17:19 -0400 (EDT)

branch: feature/pgtk
commit ca0b1b9fe5a9eb225d4cfd1fd52f9e6e56d5fa5f
Author: Yuuki Harano <masm+github@masm11.me>
Commit: Yuuki Harano <masm+github@masm11.me>

    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.
---
 src/pgtkterm.c | 65 +++++++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 44 insertions(+), 21 deletions(-)

diff --git a/src/pgtkterm.c b/src/pgtkterm.c
index 3839b2b..5331b67 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);
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]