aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Möllmann2025-01-25 14:28:13 +0100
committerGerd Möllmann2025-01-25 14:46:05 +0100
commitccf3f8d21e346ac1fdb092079227c37f987f253d (patch)
tree7f5ab2e00764fd44d88e114398d170225256093a /src
parente839b83c828fe09546edcc46dcfc5e09dd39b9fe (diff)
downloademacs-ccf3f8d21e346ac1fdb092079227c37f987f253d.tar.gz
emacs-ccf3f8d21e346ac1fdb092079227c37f987f253d.zip
Reapply "Fix mouse position handling for nested tty child frames"
This reverts commit e2cc52dbcd196f95cc79c6c6d899b9e86e696fe5.
Diffstat (limited to 'src')
-rw-r--r--src/dispextern.h1
-rw-r--r--src/dispnew.c11
-rw-r--r--src/term.c31
3 files changed, 31 insertions, 12 deletions
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);
3959void tty_raise_lower_frame (struct frame *f, bool raise); 3959void tty_raise_lower_frame (struct frame *f, bool raise);
3960int max_child_z_order (struct frame *parent); 3960int max_child_z_order (struct frame *parent);
3961void root_xy (struct frame *f, int x, int y, int *rx, int *ry); 3961void root_xy (struct frame *f, int x, int y, int *rx, int *ry);
3962void child_xy (struct frame *f, int x, int y, int *cx, int *cy);
3962bool is_frame_ancestor (struct frame *f1, struct frame *f2); 3963bool is_frame_ancestor (struct frame *f1, struct frame *f2);
3963 3964
3964INLINE_HEADER_END 3965INLINE_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)
3328 } 3328 }
3329} 3329}
3330 3330
3331/* Translate absolute coordinates (X, Y) to coordinates relative to F's origin. */
3332
3333void
3334child_xy (struct frame *f, int x, int y, int *cx, int *cy)
3335{
3336 int rx, ry;
3337 root_xy (f, 0, 0, &rx, &ry);
3338 *cx = x - rx;
3339 *cy = y - ry;
3340}
3341
3331/* Return the rectangle frame F occupies. X and Y are in absolute 3342/* Return the rectangle frame F occupies. X and Y are in absolute
3332 coordinates. */ 3343 coordinates. */
3333 3344
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,
2595#endif 2595#endif
2596 2596
2597static Lisp_Object 2597static Lisp_Object
2598tty_frame_at (int x, int y) 2598tty_frame_at (int x, int y, int *cx, int *cy)
2599{ 2599{
2600 for (Lisp_Object frames = Ftty_frame_list_z_order (Qnil); 2600 for (Lisp_Object frames = Ftty_frame_list_z_order (Qnil);
2601 !NILP (frames); 2601 !NILP (frames);
@@ -2606,24 +2606,33 @@ tty_frame_at (int x, int y)
2606 int fx, fy; 2606 int fx, fy;
2607 root_xy (f, 0, 0, &fx, &fy); 2607 root_xy (f, 0, 0, &fx, &fy);
2608 2608
2609 if (fx <= x && x < fx + f->pixel_width 2609 if ((fx <= x && x < fx + f->pixel_width)
2610 && fy <= y && y < fy + f->pixel_height) 2610 && (fy <= y && y < fy + f->pixel_height))
2611 return frame; 2611 {
2612 child_xy (XFRAME (frame), x, y, cx, cy);
2613 return frame;
2614 }
2612 } 2615 }
2613 2616
2614 return Qnil; 2617 return Qnil;
2615} 2618}
2616 2619
2617DEFUN ("tty-frame-at", Ftty_frame_at, Stty_frame_at, 2620DEFUN ("tty-frame-at", Ftty_frame_at, Stty_frame_at, 2, 2, 0,
2618 2, 2, 0, 2621 doc : /* Return tty frame containing absolute pixel position (X, Y).
2619 doc: /* Return tty frame containing pixel position X, Y. */) 2622Value is nil if no frame found. Otherwise it is a list (FRAME CX CY),
2623where FRAME is the frame containing (X, Y) and CX and CY are X and Y
2624relative to FRAME. */)
2620 (Lisp_Object x, Lisp_Object y) 2625 (Lisp_Object x, Lisp_Object y)
2621{ 2626{
2622 if (! FIXNUMP (x) || ! FIXNUMP (y)) 2627 if (! FIXNUMP (x) || ! FIXNUMP (y))
2623 /* Coordinates this big can not correspond to any frame. */ 2628 /* Coordinates this big can not correspond to any frame. */
2624 return Qnil; 2629 return Qnil;
2625 2630
2626 return tty_frame_at (XFIXNUM (x), XFIXNUM (y)); 2631 int cx, cy;
2632 Lisp_Object frame = tty_frame_at (XFIXNUM (x), XFIXNUM (y), &cx, &cy);
2633 if (NILP (frame))
2634 return Qnil;
2635 return list3 (frame, make_fixnum (cx), make_fixnum (cy));
2627} 2636}
2628 2637
2629#ifdef HAVE_GPM 2638#ifdef HAVE_GPM
@@ -2756,11 +2765,9 @@ term_mouse_click (struct input_event *result, Gpm_Event *event,
2756int 2765int
2757handle_one_term_event (struct tty_display_info *tty, const Gpm_Event *event_in) 2766handle_one_term_event (struct tty_display_info *tty, const Gpm_Event *event_in)
2758{ 2767{
2759 Lisp_Object frame = tty_frame_at (event_in->x, event_in->y);
2760 struct frame *f = decode_live_frame (frame);
2761 Gpm_Event event = *event_in; 2768 Gpm_Event event = *event_in;
2762 event.x -= f->left_pos; 2769 Lisp_Object frame = tty_frame_at (event_in->x, event_in->y, &event.x, &event.y);
2763 event.y -= f->top_pos; 2770 struct frame *f = decode_live_frame (frame);
2764 2771
2765 struct input_event ie; 2772 struct input_event ie;
2766 int count = 0; 2773 int count = 0;