From 9ae741750cc3e96cacb3c496f7c941e5fc3f1052 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Wed, 17 Nov 2021 20:31:41 +0800 Subject: [PATCH] Don't draw xwidgets that have just been resized This serves to eliminate the huge black bar displayed when the offscreen widget has been resized (and as such the damage event signal is sent), but the X window hasn't. * src/xwidget.c (xv_do_draw): Don't draw xwidgets that have just been resized. (x_draw_xwidget_glyph_string) (xwidget_init_view): Clear just_resized. (Fxwidget_resize): Set just_resized first, then queue allocate. --- src/xwidget.c | 42 ++++++++++++++++++++++++++++-------------- src/xwidget.h | 1 + 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/xwidget.c b/src/xwidget.c index 650572a8896..e1d54d43b74 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -1062,6 +1062,9 @@ xv_do_draw (struct xwidget_view *xw, struct xwidget *w) GtkOffscreenWindow *wnd; cairo_surface_t *surface; + if (xw->just_resized) + return; + if (NILP (w->buffer)) { XClearWindow (xw->dpy, xw->wdesc); @@ -1578,6 +1581,7 @@ xwidget_init_view (struct xwidget *xww, xv->wdesc = None; xv->frame = s->f; xv->cursor = cursor_for_hit (xww->hit_result, s->f); + xv->just_resized = false; #elif defined NS_IMPL_COCOA nsxwidget_init_view (xv, xww, s, x, y); nsxwidget_resize_view(xv, xww->width, xww->height); @@ -1609,6 +1613,8 @@ x_draw_xwidget_glyph_string (struct glyph_string *s) #ifdef USE_GTK if (!xv) xv = xwidget_init_view (xww, s, x, y); + + xv->just_resized = false; #elif defined NS_IMPL_COCOA if (!xv) { @@ -1970,20 +1976,7 @@ DEFUN ("xwidget-resize", Fxwidget_resize, Sxwidget_resize, 3, 3, 0, xw->width = w; xw->height = h; - /* If there is an offscreen widget resize it first. */ -#ifdef USE_GTK - if (xw->widget_osr) - { - gtk_window_resize (GTK_WINDOW (xw->widgetwindow_osr), xw->width, - xw->height); - gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr), xw->width, - xw->height); - - gtk_widget_queue_allocate (GTK_WIDGET (xw->widget_osr)); - } -#elif defined NS_IMPL_COCOA - nsxwidget_resize (xw); -#endif + block_input (); for (Lisp_Object tail = internal_xwidget_view_list; CONSP (tail); tail = XCDR (tail)) @@ -1993,13 +1986,34 @@ DEFUN ("xwidget-resize", Fxwidget_resize, Sxwidget_resize, 3, 3, 0, struct xwidget_view *xv = XXWIDGET_VIEW (XCAR (tail)); if (XXWIDGET (xv->model) == xw) { +#ifdef USE_GTK + xv->just_resized = true; + SET_FRAME_GARBAGED (xv->frame); +#else wset_redisplay (XWINDOW (xv->w)); +#endif } } } redisplay (); + /* If there is an offscreen widget resize it first. */ +#ifdef USE_GTK + if (xw->widget_osr) + { + gtk_window_resize (GTK_WINDOW (xw->widgetwindow_osr), xw->width, + xw->height); + gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr), xw->width, + xw->height); + + gtk_widget_queue_allocate (GTK_WIDGET (xw->widget_osr)); + } +#elif defined NS_IMPL_COCOA + nsxwidget_resize (xw); +#endif + unblock_input (); + return Qnil; } diff --git a/src/xwidget.h b/src/xwidget.h index 2f6d0442e20..78fe865dd84 100644 --- a/src/xwidget.h +++ b/src/xwidget.h @@ -114,6 +114,7 @@ struct xwidget_view cairo_surface_t *cr_surface; cairo_t *cr_context; + int just_resized; #elif defined (NS_IMPL_COCOA) # ifdef __OBJC__ XvWindow *xvWindow; -- 2.39.5