summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGerd Möllmann <gerd@gnu.org>2025-01-25 14:28:03 +0100
committerGerd Möllmann <gerd@gnu.org>2025-01-25 14:46:05 +0100
commit945ed044cd8ab67ccbbc185c19f500f723cd9045 (patch)
tree9374742edc099b6e9cfa52d920e519317b21022a /src
parentd4220a17c4ecf4639a276352149218077c1d6315 (diff)
Reapply "Simplify absolute (x, y) computation on ttys"
This reverts commit 13fdcd730ff63bf79caace9a6e46aff5f944b1b7.
Diffstat (limited to 'src')
-rw-r--r--src/dispextern.h2
-rw-r--r--src/dispnew.c19
-rw-r--r--src/term.c7
3 files changed, 13 insertions, 15 deletions
diff --git a/src/dispextern.h b/src/dispextern.h
index 1060895d0f4..9c193e79fd1 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -3958,7 +3958,7 @@ void combine_updates (Lisp_Object root_frames);
void combine_updates_for_frame (struct frame *f, bool inhibit_id_p);
void tty_raise_lower_frame (struct frame *f, bool raise);
int max_child_z_order (struct frame *parent);
-void frame_pos_abs (struct frame *f, int *x, int *y);
+void root_xy (struct frame *f, int x, int y, int *rx, int *ry);
bool is_frame_ancestor (struct frame *f1, struct frame *f2);
INLINE_HEADER_END
diff --git a/src/dispnew.c b/src/dispnew.c
index 724ec6ece9a..00e59c767e8 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -3313,16 +3313,18 @@ rect_intersect (struct rect *r, struct rect r1, struct rect r2)
return true;
}
-/* Return the absolute position of frame F in *X and *Y. */
+/* Translate (X, Y) relative to frame F to absolute coordinates
+ in (*X, *Y). */
void
-frame_pos_abs (struct frame *f, int *x, int *y)
+root_xy (struct frame *f, int x, int y, int *rx, int *ry)
{
- *x = *y = 0;
+ *rx = x;
+ *ry = y;
for (; f; f = FRAME_PARENT_FRAME (f))
{
- *x += f->left_pos;
- *y += f->top_pos;
+ *rx += f->left_pos;
+ *ry += f->top_pos;
}
}
@@ -3333,7 +3335,7 @@ static struct rect
frame_rect_abs (struct frame *f)
{
int x, y;
- frame_pos_abs (f, &x, &y);
+ root_xy (f, 0, 0, &x, &y);
return (struct rect) { x, y, f->total_cols, f->total_lines };
}
@@ -3875,10 +3877,7 @@ abs_cursor_pos (struct frame *f, int *x, int *y)
wx += max (0, w->left_margin_cols);
- int fx, fy;
- frame_pos_abs (f, &fx, &fy);
- *x = fx + wx;
- *y = fy + wy;
+ root_xy (f, wx, wy, x, y);
return true;
}
diff --git a/src/term.c b/src/term.c
index 4ae9c373888..00bc94e6e31 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2996,10 +2996,9 @@ mouse_get_xy (int *x, int *y)
struct frame *sf = SELECTED_FRAME ();
if (f == sf || is_frame_ancestor (sf, f))
{
- int fx, fy;
- frame_pos_abs (f, &fx, &fy);
- *x = fx + XFIXNUM (XCAR (XCDR (mouse)));
- *y = fy + XFIXNUM (XCDR (XCDR (mouse)));
+ int mx = XFIXNUM (XCAR (XCDR (mouse)));
+ int my = XFIXNUM (XCDR (XCDR (mouse)));
+ root_xy (f, mx, my, x, y);
}
}