From 9a3adbb061a3fd947936362d7c33f1fd4913fbcc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gerd=20M=C3=B6llmann?= Date: Mon, 17 Feb 2025 10:42:02 +0100 Subject: [PATCH] Fix child coordinate calculation (bug#76321) * src/dispnew.c (rect_intersect): Simplify. (copy_child_glyphs): Compute child coordinates using child_xy. (cherry picked from commit d80ac0fbaa09826342a9818014ae950acc7c0c03) --- src/dispnew.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/dispnew.c b/src/dispnew.c index fd326469f4d..49957e98c4f 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -3285,15 +3285,15 @@ struct rect static bool rect_intersect (struct rect *r, struct rect r1, struct rect r2) { - int x1 = max (r1.x, r2.x); - int x2 = min (r1.x + r1.w, r2.x + r2.w); - if (x2 < x1) - return false; - int y1 = max (r1.y, r2.y); - int y2 = min (r1.y + r1.h, r2.y + r2.h); - if (y2 < y1) + int x = max (r1.x, r2.x); + int y = max (r1.y, r2.y); + int w = min (r1.x + r1.w, r2.x + r2.w) - x; + int h = min (r1.y + r1.h, r2.y + r2.h) - y; + + if (w == 0 || h == 0) return false; - *r = (struct rect) { .x = x1, .y = y1, .w = x2 - x1, .h = y2 - y1 }; + + *r = (struct rect) { .x = x, .y = y, .w = w, .h = h }; return true; } @@ -3717,8 +3717,8 @@ copy_child_glyphs (struct frame *root, struct frame *child) } /* First visible row/col, relative to the child frame. */ - int child_x = child->left_pos < 0 ? - child->left_pos : 0; - int child_y = child->top_pos < 0 ? - child->top_pos : 0; + int child_x, child_y; + child_xy (child, r.x, r.y, &child_x, &child_y); /* For all rows in the intersection, copy glyphs from the child's current matrix to the root's desired matrix, enabling those rows -- 2.39.5