From: Gerd Möllmann Date: Thu, 23 Jan 2025 14:30:30 +0000 (+0100) Subject: Handle tty menus overlapping child frames X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7b6b217c8e092292ca9084310556a8fa7ccee5b7;p=emacs.git Handle tty menus overlapping child frames * src/dispnew.c (frame_pos_abs, is_frame_ancestor): Make externally visible. * src/dispextern.h: Declare above functions. * src/term.c (mouse_get_xy): Handle mouse movement over child frames. (cherry picked from commit d83d090de1127d6e88e4ff33a617d8621a85a8cd) --- diff --git a/src/dispextern.h b/src/dispextern.h index ccf0aebd7c6..1060895d0f4 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -3958,6 +3958,8 @@ 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); +bool is_frame_ancestor (struct frame *f1, struct frame *f2); INLINE_HEADER_END diff --git a/src/dispnew.c b/src/dispnew.c index b65f0c1c62a..cf3f7e2acb8 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -3312,7 +3312,7 @@ rect_intersect (struct rect *r, struct rect r1, struct rect r2) /* Return the absolute position of frame F in *X and *Y. */ -static void +void frame_pos_abs (struct frame *f, int *x, int *y) { *x = *y = 0; @@ -3352,7 +3352,7 @@ max_child_z_order (struct frame *parent) /* Return true if F1 is an ancestor of F2. */ -static bool +bool is_frame_ancestor (struct frame *f1, struct frame *f2) { for (struct frame *f = FRAME_PARENT_FRAME (f2); f; f = FRAME_PARENT_FRAME (f)) diff --git a/src/term.c b/src/term.c index f7d3e58a465..4ae9c373888 100644 --- a/src/term.c +++ b/src/term.c @@ -2990,19 +2990,16 @@ tty_menu_calc_size (tty_menu *menu, int *width, int *height) static void mouse_get_xy (int *x, int *y) { - Lisp_Object lmx = Qnil, lmy = Qnil; Lisp_Object mouse = mouse_position (tty_menu_calls_mouse_position_function); - if (EQ (selected_frame, XCAR (mouse))) - { - lmx = XCAR (XCDR (mouse)); - lmy = XCDR (XCDR (mouse)); - } - - if (!NILP (lmx)) + struct frame *f = XFRAME (XCAR (mouse)); + struct frame *sf = SELECTED_FRAME (); + if (f == sf || is_frame_ancestor (sf, f)) { - *x = XFIXNUM (lmx); - *y = XFIXNUM (lmy); + int fx, fy; + frame_pos_abs (f, &fx, &fy); + *x = fx + XFIXNUM (XCAR (XCDR (mouse))); + *y = fy + XFIXNUM (XCDR (XCDR (mouse))); } }