]> git.eshelyaron.com Git - emacs.git/commitdiff
Handle tty menus overlapping child frames
authorGerd Möllmann <gerd@gnu.org>
Thu, 23 Jan 2025 14:30:30 +0000 (15:30 +0100)
committerEshel Yaron <me@eshelyaron.com>
Sat, 25 Jan 2025 17:43:09 +0000 (18:43 +0100)
* 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)

src/dispextern.h
src/dispnew.c
src/term.c

index ccf0aebd7c665b4ba3a0ca54e6e24209cd383cd2..1060895d0f4ac6fdb337ea46e9b55bd16f65142f 100644 (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
 
index b65f0c1c62a00d73b9b418e2111e9899747d0105..cf3f7e2acb8c3c552337f1f0161da8c36caf84b9 100644 (file)
@@ -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))
index f7d3e58a465403e48ce02a3be4950fda857678f5..4ae9c3738887c66fff49197b22634322ce001627 100644 (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)))
-    {
-      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)));
     }
 }