unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 51681@debbugs.gnu.org
Subject: bug#51681: 29.0.50; [PATCH] Really fix xwidget scroll optimization
Date: Mon, 08 Nov 2021 14:24:18 +0800	[thread overview]
Message-ID: <8735o7qi5p.fsf@yahoo.com> (raw)
In-Reply-To: 8735o7qi5p.fsf.ref@yahoo.com

[-- Attachment #1: Type: text/plain, Size: 189 bytes --]

Sorry for missing this, it was quite obvious in retrospect, but when I
first wrote the code for x_scroll_run it was with a mistaken
understanding of the meaning of `clip_bottom'.  Thanks.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Really-fix-xwidget-scroll-optimization-and-clip.patch --]
[-- Type: text/x-patch, Size: 3136 bytes --]

From 75c0f76a3f8f122151c20e3f2037a17e78ede970 Mon Sep 17 00:00:00 2001
From: Po Lu <luangruo@yahoo.com>
Date: Mon, 8 Nov 2021 14:17:48 +0800
Subject: [PATCH] Really fix xwidget scroll optimization and clip

* src/xterm.c (x_scroll_run): Improve clip detection.
* src/xwidget.c (xv_do_draw): Use cairo_translate.
(xwidget_motion_or_crossing): Use correct fields.
---
 src/xterm.c   | 23 ++++++++++++++++-------
 src/xwidget.c |  8 ++++----
 2 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/src/xterm.c b/src/xterm.c
index 24f12d6e24..1fb3d8d7c0 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -4442,18 +4442,27 @@ x_scroll_run (struct window *w, struct run *run)
 		  window_box (w, TEXT_AREA, &text_area_x, &text_area_y,
 			      &text_area_width, &text_area_height);
 
-		  clip_top = max (0, text_area_y - y);
-		  clip_bottom = max (clip_top,
-				     min (XXWIDGET (view->model)->height,
-					  text_area_y + text_area_height - y));
-
 		  view->y = y;
+
+		  clip_top = 0;
+		  clip_bottom = window_height;
+
+		  if (y < text_area_y)
+		    clip_top = text_area_y - y;
+
+		  if ((y + clip_top + window_height)
+		      > (text_area_y + text_area_height))
+		    {
+		      clip_bottom -= (y + clip_top + window_height)
+			- (text_area_y + text_area_height);
+		    }
+
 		  view->clip_top = clip_top;
 		  view->clip_bottom = clip_bottom;
 
 		  /* This means the view has moved offscreen.  Unmap
 		     it and hide it here.  */
-		  if ((view->clip_top - view->clip_bottom) <= 0)
+		  if ((view->clip_bottom - view->clip_top) <= 0)
 		    {
 		      view->hidden = true;
 		      XUnmapWindow (dpy, child);
@@ -4462,7 +4471,7 @@ x_scroll_run (struct window *w, struct run *run)
 		    XMoveResizeWindow (dpy, child, view->x + view->clip_left,
 				       view->y + view->clip_top,
 				       view->clip_right - view->clip_left,
-				       view->clip_top - view->clip_bottom);
+				       view->clip_bottom - view->clip_top);
 		  XFlush (dpy);
 		}
             }
diff --git a/src/xwidget.c b/src/xwidget.c
index 1815a39ab6..2d9351308e 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -753,9 +753,9 @@ xwidget_motion_or_crossing (struct xwidget_view *view, const XEvent *event)
   GtkWidget *target = find_widget_at_pos (model->widgetwindow_osr,
 					  (event->type == MotionNotify
 					   ? event->xmotion.x + view->clip_left
-					   : event->xmotion.y + view->clip_top),
+					   : event->xcrossing.x + view->clip_left),
 					  (event->type == MotionNotify
-					   ? event->xmotion.y + view->clip_left
+					   ? event->xmotion.y + view->clip_top
 					   : event->xcrossing.y + view->clip_top),
 					  &x, &y);
 
@@ -855,8 +855,8 @@ xv_do_draw (struct xwidget_view *xw, struct xwidget *w)
   cairo_save (xw->cr_context);
   if (surface)
     {
-      cairo_set_source_surface (xw->cr_context, surface, xw->clip_left,
-				xw->clip_top);
+      cairo_translate (xw->cr_context, -xw->clip_left, -xw->clip_top);
+      cairo_set_source_surface (xw->cr_context, surface, 0, 0);
       cairo_set_operator (xw->cr_context, CAIRO_OPERATOR_SOURCE);
       cairo_paint (xw->cr_context);
     }
-- 
2.31.1


       reply	other threads:[~2021-11-08  6:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <8735o7qi5p.fsf.ref@yahoo.com>
2021-11-08  6:24 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2021-11-09  4:02   ` bug#51681: 29.0.50; [PATCH] Really fix xwidget scroll optimization Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8735o7qi5p.fsf@yahoo.com \
    --to=bug-gnu-emacs@gnu.org \
    --cc=51681@debbugs.gnu.org \
    --cc=luangruo@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).