From 79fd672dfc1a66a5bce58f7de330785c0b09ade0 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sun, 13 Feb 2022 11:29:44 +0800 Subject: [PATCH] Work around tooltip bug on new versions of WebKitGTK * src/xwidget.c (dummy_tooltip_string): New variable. (xw_maybe_synthesize_crossing): Call `xg_prepare_tooltip' to disable tooltips on WebKitGTK 2.34 or later. (syms_of_xwidget): Make dummy string. --- src/xwidget.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/xwidget.c b/src/xwidget.c index fc6ba2c6335..bfee80ef3ed 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -62,6 +62,9 @@ static uint32_t xwidget_counter = 0; #ifdef USE_GTK #ifdef HAVE_X_WINDOWS static Lisp_Object x_window_to_xwv_map; +#if WEBKIT_CHECK_VERSION (2, 34, 0) +static Lisp_Object dummy_tooltip_string; +#endif #endif static gboolean offscreen_damage_event (GtkWidget *, GdkEvent *, gpointer); static void synthesize_focus_in_event (GtkWidget *); @@ -1731,6 +1734,17 @@ xw_maybe_synthesize_crossing (struct xwidget_view *view, bool nonlinear_p; bool retention_flag; +#if WEBKIT_CHECK_VERSION (2, 34, 0) + /* Work around a silly bug in WebKitGTK+ that tries to make tooltip + windows transient for our offscreen window. */ + int tooltip_width, tooltip_height; + struct x_output *output = FRAME_X_OUTPUT (view->frame); + + if (!output->ttip_widget) + xg_prepare_tooltip (view->frame, dummy_tooltip_string, + &tooltip_width, &tooltip_height); +#endif + toplevel = gtk_widget_get_window (XXWIDGET (view->model)->widgetwindow_osr); retention_flag = false; @@ -3931,6 +3945,11 @@ syms_of_xwidget (void) x_window_to_xwv_map = CALLN (Fmake_hash_table, QCtest, Qeq); staticpro (&x_window_to_xwv_map); + +#if WEBKIT_CHECK_VERSION (2, 34, 0) + dummy_tooltip_string = build_string (""); + staticpro (&dummy_tooltip_string); +#endif #endif } -- 2.39.5