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.
This commit is contained in:
Gerd Möllmann 2025-01-23 15:30:30 +01:00
parent da3b93ff96
commit d83d090de1
3 changed files with 11 additions and 12 deletions

View file

@ -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

View file

@ -3315,7 +3315,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;
@ -3355,7 +3355,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))

View file

@ -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)))
struct frame *f = XFRAME (XCAR (mouse));
struct frame *sf = SELECTED_FRAME ();
if (f == sf || is_frame_ancestor (sf, f))
{
lmx = XCAR (XCDR (mouse));
lmy = XCDR (XCDR (mouse));
}
if (!NILP (lmx))
{
*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)));
}
}