Don't draw xwidgets that have just been resized
authorPo Lu <luangruo@yahoo.com>
Wed, 17 Nov 2021 12:31:41 +0000 (20:31 +0800)
committerPo Lu <luangruo@yahoo.com>
Wed, 17 Nov 2021 12:34:30 +0000 (20:34 +0800)
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
src/xwidget.h

index 650572a889682d1e3758cbc9dc2f2b6ea0af4b93..e1d54d43b74c1109044049ef7923275c939d04b5 100644 (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,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;
 }
 
index 2f6d0442e204cb3ea55ab8c3fffe80a8267c34d3..78fe865dd843dc13916e5ce9e863ce2adeb6b528 100644 (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;