Subject: Re: bug#51697: 29.0.50; [PATCH] Fix flicker when setting hscroll of xwidget

From: Po Lu <[email-masked]>
Date: Tue, 09 Nov 2021 11:05:10 +0800

Po Lu <[email-masked]> writes:

> Thanks.

Please ignore that and use this instead, which also fixes disappearing
text.

>From 7142d3186afeabdfeaf64fd0b180a0057bde8f4f Mon Sep 17 00:00:00 2001
From: Po Lu <[email-masked]>
Date: Tue, 9 Nov 2021 09:40:09 +0800
Subject: [PATCH] Fix flicker when setting hscroll of xwidget

* src/xterm.c (x_scroll_run): Use original height of xwidget instead
of window height and set cairo surface size.
---
 src/xterm.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/xterm.c b/src/xterm.c
index 1fb3d8d7c0..172abe919d 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -4408,7 +4408,7 @@ x_scroll_run (struct window *w, struct run *run)
 	  Window child = children[i];
 	  struct xwidget_view *view = xwidget_view_from_window (child);
 
-	  if (view)
+	  if (view && !view->hidden)
 	    {
 	      int window_y = view->y + view->clip_top;
 	      int window_height = view->clip_bottom - view->clip_top;
@@ -4445,16 +4445,14 @@ x_scroll_run (struct window *w, struct run *run)
 		  view->y = y;
 
 		  clip_top = 0;
-		  clip_bottom = window_height;
+		  clip_bottom = XXWIDGET (view->model)->height;
 
 		  if (y < text_area_y)
 		    clip_top = text_area_y - y;
 
-		  if ((y + clip_top + window_height)
-		      > (text_area_y + text_area_height))
+		  if ((y + clip_bottom) > (text_area_y + text_area_height))
 		    {
-		      clip_bottom -= (y + clip_top + window_height)
-			- (text_area_y + text_area_height);
+		      clip_bottom -= (y + clip_bottom) - (text_area_y + text_area_height);
 		    }
 
 		  view->clip_top = clip_top;
@@ -4468,10 +4466,16 @@ x_scroll_run (struct window *w, struct run *run)
 		      XUnmapWindow (dpy, child);
 		    }
 		  else
-		    XMoveResizeWindow (dpy, child, view->x + view->clip_left,
-				       view->y + view->clip_top,
-				       view->clip_right - view->clip_left,
-				       view->clip_bottom - view->clip_top);
+		    {
+		      XMoveResizeWindow (dpy, child, view->x + view->clip_left,
+					 view->y + view->clip_top,
+					 view->clip_right - view->clip_left,
+					 view->clip_bottom - view->clip_top);
+		      cairo_xlib_surface_set_size (view->cr_surface,
+						   view->clip_right - view->clip_left,
+						   view->clip_bottom - view->clip_top);
+		    }
+		  xwidget_expose (view);
 		  XFlush (dpy);
 		}
             }
-- 
2.31.1

Thanks.