]> git.eshelyaron.com Git - emacs.git/commitdiff
Really fix xwidget scroll optimization and clip
authorPo Lu <luangruo@yahoo.com>
Tue, 9 Nov 2021 04:02:25 +0000 (05:02 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 9 Nov 2021 04:02:25 +0000 (05:02 +0100)
* 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 (bug#51681).

src/xterm.c
src/xwidget.c

index 24f12d6e2497e0d93fe0087a0f989751d4297834..1fb3d8d7c09108bee099866ca835bce42b3196b5 100644 (file)
@@ -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);
                }
             }
index 769d491f278bd68177524b8d9eea4d308af0f0fb..294e9f8788ce1030834d0915cf1902cb1c3ef8ee 100644 (file)
@@ -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);
     }