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.
This commit is contained in:
Po Lu 2021-11-17 20:31:41 +08:00
parent b6ea007f9d
commit 9ae741750c
2 changed files with 30 additions and 15 deletions

View file

@ -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,6 +1976,28 @@ DEFUN ("xwidget-resize", Fxwidget_resize, Sxwidget_resize, 3, 3, 0,
xw->width = w;
xw->height = h;
block_input ();
for (Lisp_Object tail = internal_xwidget_view_list; CONSP (tail);
tail = XCDR (tail))
{
if (XWIDGET_VIEW_P (XCAR (tail)))
{
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)
@ -1984,21 +2012,7 @@ DEFUN ("xwidget-resize", Fxwidget_resize, Sxwidget_resize, 3, 3, 0,
#elif defined NS_IMPL_COCOA
nsxwidget_resize (xw);
#endif
for (Lisp_Object tail = internal_xwidget_view_list; CONSP (tail);
tail = XCDR (tail))
{
if (XWIDGET_VIEW_P (XCAR (tail)))
{
struct xwidget_view *xv = XXWIDGET_VIEW (XCAR (tail));
if (XXWIDGET (xv->model) == xw)
{
wset_redisplay (XWINDOW (xv->w));
}
}
}
redisplay ();
unblock_input ();
return Qnil;
}

View file

@ -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;