[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master ccf3f8d21e3 4/6: Reapply "Fix mouse position handling for nested
From: |
Gerd Moellmann |
Subject: |
master ccf3f8d21e3 4/6: Reapply "Fix mouse position handling for nested tty child frames" |
Date: |
Sat, 25 Jan 2025 08:46:23 -0500 (EST) |
branch: master
commit ccf3f8d21e346ac1fdb092079227c37f987f253d
Author: Gerd Möllmann <gerd@gnu.org>
Commit: Gerd Möllmann <gerd@gnu.org>
Reapply "Fix mouse position handling for nested tty child frames"
This reverts commit e2cc52dbcd196f95cc79c6c6d899b9e86e696fe5.
---
lisp/xt-mouse.el | 13 ++++---------
src/dispextern.h | 1 +
src/dispnew.c | 11 +++++++++++
src/term.c | 31 +++++++++++++++++++------------
4 files changed, 35 insertions(+), 21 deletions(-)
diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el
index 19d688e4d1e..e395723d05c 100644
--- a/lisp/xt-mouse.el
+++ b/lisp/xt-mouse.el
@@ -298,16 +298,11 @@ which is the \"1006\" extension implemented in Xterm >=
277."
;; FIXME: The test for running in batch mode is here solely
;; for the sake of xt-mouse-tests where the only frame is
;; the initial frame.
- (frame (unless noninteractive (tty-frame-at x y)))
- ;;(_ (message (format "*** %S" frame)))
- (frame-pos (frame-position frame))
- ;;(_ (message (format "*** %S" frame-pos)))
- (x (- x (car frame-pos)))
- (y (- y (cdr frame-pos)))
- ;;(_ (message (format "*** %S %S" x y)))
+ (frame-and-xy (unless noninteractive (tty-frame-at x y)))
+ (frame (nth 0 frame-and-xy))
+ (x (nth 1 frame-and-xy))
+ (y (nth 2 frame-and-xy))
(w (window-at x y frame))
- ;;(_ (message (format "*** %S" w)))
-
(ltrb (window-edges w))
(left (nth 0 ltrb))
(top (nth 1 ltrb))
diff --git a/src/dispextern.h b/src/dispextern.h
index 9c193e79fd1..e1214128e35 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -3959,6 +3959,7 @@ 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 root_xy (struct frame *f, int x, int y, int *rx, int *ry);
+void child_xy (struct frame *f, int x, int y, int *cx, int *cy);
bool is_frame_ancestor (struct frame *f1, struct frame *f2);
INLINE_HEADER_END
diff --git a/src/dispnew.c b/src/dispnew.c
index 00e59c767e8..5a8064a1a02 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -3328,6 +3328,17 @@ root_xy (struct frame *f, int x, int y, int *rx, int *ry)
}
}
+/* Translate absolute coordinates (X, Y) to coordinates relative to F's
origin. */
+
+void
+child_xy (struct frame *f, int x, int y, int *cx, int *cy)
+{
+ int rx, ry;
+ root_xy (f, 0, 0, &rx, &ry);
+ *cx = x - rx;
+ *cy = y - ry;
+}
+
/* Return the rectangle frame F occupies. X and Y are in absolute
coordinates. */
diff --git a/src/term.c b/src/term.c
index 7397ee68347..e13089af2bb 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2595,7 +2595,7 @@ tty_draw_row_with_mouse_face (struct window *w, struct
glyph_row *row,
#endif
static Lisp_Object
-tty_frame_at (int x, int y)
+tty_frame_at (int x, int y, int *cx, int *cy)
{
for (Lisp_Object frames = Ftty_frame_list_z_order (Qnil);
!NILP (frames);
@@ -2606,24 +2606,33 @@ tty_frame_at (int x, int y)
int fx, fy;
root_xy (f, 0, 0, &fx, &fy);
- if (fx <= x && x < fx + f->pixel_width
- && fy <= y && y < fy + f->pixel_height)
- return frame;
+ if ((fx <= x && x < fx + f->pixel_width)
+ && (fy <= y && y < fy + f->pixel_height))
+ {
+ child_xy (XFRAME (frame), x, y, cx, cy);
+ return frame;
+ }
}
return Qnil;
}
-DEFUN ("tty-frame-at", Ftty_frame_at, Stty_frame_at,
- 2, 2, 0,
- doc: /* Return tty frame containing pixel position X, Y. */)
+DEFUN ("tty-frame-at", Ftty_frame_at, Stty_frame_at, 2, 2, 0,
+ doc : /* Return tty frame containing absolute pixel position (X, Y).
+Value is nil if no frame found. Otherwise it is a list (FRAME CX CY),
+where FRAME is the frame containing (X, Y) and CX and CY are X and Y
+relative to FRAME. */)
(Lisp_Object x, Lisp_Object y)
{
if (! FIXNUMP (x) || ! FIXNUMP (y))
/* Coordinates this big can not correspond to any frame. */
return Qnil;
- return tty_frame_at (XFIXNUM (x), XFIXNUM (y));
+ int cx, cy;
+ Lisp_Object frame = tty_frame_at (XFIXNUM (x), XFIXNUM (y), &cx, &cy);
+ if (NILP (frame))
+ return Qnil;
+ return list3 (frame, make_fixnum (cx), make_fixnum (cy));
}
#ifdef HAVE_GPM
@@ -2756,11 +2765,9 @@ term_mouse_click (struct input_event *result, Gpm_Event
*event,
int
handle_one_term_event (struct tty_display_info *tty, const Gpm_Event *event_in)
{
- Lisp_Object frame = tty_frame_at (event_in->x, event_in->y);
- struct frame *f = decode_live_frame (frame);
Gpm_Event event = *event_in;
- event.x -= f->left_pos;
- event.y -= f->top_pos;
+ Lisp_Object frame = tty_frame_at (event_in->x, event_in->y, &event.x,
&event.y);
+ struct frame *f = decode_live_frame (frame);
struct input_event ie;
int count = 0;
- master updated (d4220a17c4e -> 1d086441166), Gerd Moellmann, 2025/01/25
- master e839b83c828 3/6: Reapply "Fix tty-frame-at for nested tty child frames", Gerd Moellmann, 2025/01/25
- master ccf3f8d21e3 4/6: Reapply "Fix mouse position handling for nested tty child frames",
Gerd Moellmann <=
- master 26b144f241c 2/6: Reapply "Fix cursor positioning of nested tty child frames", Gerd Moellmann, 2025/01/25
- master 1d086441166 6/6: Fix the mistake that led to the reverts, Gerd Moellmann, 2025/01/25
- master 945ed044cd8 1/6: Reapply "Simplify absolute (x, y) computation on ttys", Gerd Moellmann, 2025/01/25
- master 20f26723774 5/6: Reapply "Multi-tty: selected frame can be a GUI frame", Gerd Moellmann, 2025/01/25