From: Po Lu Date: Wed, 17 Nov 2021 12:31:41 +0000 (+0800) Subject: Don't draw xwidgets that have just been resized X-Git-Tag: emacs-29.0.90~2852^2~231 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9ae741750cc3e96cacb3c496f7c941e5fc3f1052;p=emacs.git 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. --- 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;