From d878c4537ddee150a5a369dc90c5823add006cca Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sat, 22 Jan 2022 10:25:06 +0800 Subject: [PATCH] Fix recent changes to visible bell code * src/gtkutil.c (xg_create_scroll_bar): (xg_create_horizontal_scroll_bar): Stop ensuring an X window before the widget is realized. (xg_update_scrollbar_pos): (xg_update_horizontal_scrollbar_pos): Ensure such a window here instead. --- src/gtkutil.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/gtkutil.c b/src/gtkutil.c index 0ac71af8080f..eb1485606205 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -4431,10 +4431,6 @@ xg_create_scroll_bar (struct frame *f, wscroll = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, GTK_ADJUSTMENT (vadj)); -#if !defined HAVE_PGTK && GTK_CHECK_VERSION (2, 18, 0) - eassert (gdk_window_ensure_native (gtk_widget_get_window (wscroll))); -#endif - xg_finish_scroll_bar_creation (f, wscroll, bar, scroll_callback, end_callback, scroll_bar_name); bar->horizontal = 0; @@ -4467,10 +4463,6 @@ xg_create_horizontal_scroll_bar (struct frame *f, wscroll = gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT (hadj)); -#if !defined HAVE_PGTK && GTK_CHECK_VERSION (2, 18, 0) - eassert (gdk_window_ensure_native (gtk_widget_get_window (wscroll))); -#endif - xg_finish_scroll_bar_creation (f, wscroll, bar, scroll_callback, end_callback, scroll_bar_name); bar->horizontal = 1; @@ -4542,6 +4534,12 @@ xg_update_scrollbar_pos (struct frame *f, gtk_widget_show_all (wparent); gtk_widget_set_size_request (wscroll, width, height); } + +#if !defined HAVE_PGTK && GTK_CHECK_VERSION (2, 18, 0) + if (!gdk_window_ensure_native (gtk_widget_get_window (wscroll))) + emacs_abort (); +#endif + if (oldx != -1 && oldw > 0 && oldh > 0) { /* Clear under old scroll bar position. */ @@ -4595,7 +4593,6 @@ xg_update_horizontal_scrollbar_pos (struct frame *f, int width, int height) { - GtkWidget *wscroll = xg_get_widget_from_map (scrollbar_id); if (wscroll) @@ -4642,6 +4639,11 @@ xg_update_horizontal_scrollbar_pos (struct frame *f, pgtk_clear_area (f, oldx, oldy, oldw, oldh); #endif +#if !defined HAVE_PGTK && GTK_CHECK_VERSION (2, 18, 0) + if (!gdk_window_ensure_native (gtk_widget_get_window (wscroll))) + emacs_abort (); +#endif + /* GTK does not redraw until the main loop is entered again, but if there are no X events pending we will not enter it. So we sync here to get some events. */