Subject: Re: bug#52705: 29.0.50; Flashing popups when x-gtk-use-system-tooltips is nil in pgtk

From: martin rudalics <[email-masked]>
Date: Fri, 24 Dec 2021 17:03:13 +0100

> Thanks, I'm beginning to understand the problem.
 >
 > Try removing this part of `x_create_tip_frame' in pgtkfns.c:
 >
 >    gtk_widget_show_all (FRAME_GTK_OUTER_WIDGET (f));
 >
 >
 > And adding `gtk_widget_show_all (FRAME_GTK_OUTER_WIDGET (tip_f))' to
 > this part of x-show-tip in that file:
 >
 >    /* Show tooltip frame.  */
 >    block_input ();
 >    gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (tip_f)), width, height);
 >    gtk_window_move (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (tip_f)), root_x, root_y);
 >    unblock_input ();

I did

diff --git a/src/pgtkfns.c b/src/pgtkfns.c
index 8cea9a9270..93f460a606 100644
--- a/src/pgtkfns.c
+++ b/src/pgtkfns.c
@@ -2989,7 +2989,6 @@ x_create_tip_frame (struct pgtk_display_info *dpyinfo, Lisp_Object parms, struct
    gtk_window_set_decorated (GTK_WINDOW (tip_window), FALSE);
    gtk_window_set_type_hint (GTK_WINDOW (tip_window), GDK_WINDOW_TYPE_HINT_TOOLTIP);
    f->output_data.pgtk->current_cursor = f->output_data.pgtk->text_cursor;
-  gtk_widget_show_all (FRAME_GTK_OUTER_WIDGET (f));
    gdk_window_set_cursor (gtk_widget_get_window (FRAME_GTK_OUTER_WIDGET (f)),
  			 f->output_data.pgtk->current_cursor);

@@ -3527,6 +3526,8 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
    block_input ();
    gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (tip_f)), width, height);
    gtk_window_move (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (tip_f)), root_x, root_y);
+  gtk_widget_show_all (FRAME_GTK_OUTER_WIDGET (tip_f));
+  SET_FRAME_VISIBLE (tip_f, 1);
    unblock_input ();

    pgtk_cr_update_surface_desired_size (tip_f, width, height, false);

and it seems to work flawlessly - the SET_FRAME_VISIBLE is utterly
needed here to make the check on line 3203 of pgtkfns.c succeed (or
better, fail).

More importantly, the initial phantom frame with a simple

(setq x-gtk-use-system-tooltips nil)

disappears so you can make Aleksandr happy ...

Unfortunately, I'm now getting

(emacs:2257): Gdk-CRITICAL **: 16:19:41.208: gdk_window_set_cursor: assertion 'GDK_IS_WINDOW (window)' failed

(emacs:2257): Gdk-CRITICAL **: 16:19:41.231: gdk_window_create_similar_surface: assertion 'GDK_IS_WINDOW (window)' failed

which I do not get without the patch.  Any ideas?

martin