1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

Fix drag-and-drop treatment of reused tooltip frames

* src/androidfns.c (Fx_show_tip): Set `tip_window' to that of
any reused tooltip frame.

* src/haikufns.c (unwind_create_frame): Return whether the frame
was destroyed, as on X.
(unwind_create_tip_frame, haiku_create_frame, Fx_show_tip):
Synchronize with X.
(do_unwind_create_frame): New function.
(tip_window): Remove unused variable.

* src/nsfns.m (tip_window, unwind_create_tip_frame): Remove
unused variable `tip_window'.

* src/pgtkfns.c (pgtk_create_tip_frame): Rename to
pgtk_create_tip_frame.
(Fx_show_tip): Adjust accordingly.  Set `tip_window' to that of
any reused tooltip frame.

* src/w32fns.c (Fx_show_tip):

* src/xfns.c (Fx_show_tip): Set `tip_window' to that of any
reused tooltip frame.
This commit is contained in:
Po Lu 2025-02-27 09:53:41 +08:00
parent 85a9b916db
commit a4a458ffa4
6 changed files with 41 additions and 28 deletions

View file

@ -2449,6 +2449,8 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
/* Creating the tip frame failed. */ /* Creating the tip frame failed. */
return unbind_to (count, Qnil); return unbind_to (count, Qnil);
} }
else
tip_window = FRAME_ANDROID_WINDOW (XFRAME (tip_frame));
tip_f = XFRAME (tip_frame); tip_f = XFRAME (tip_frame);
window = FRAME_ROOT_WINDOW (tip_f); window = FRAME_ROOT_WINDOW (tip_f);

View file

@ -53,10 +53,6 @@ Lisp_Object tip_frame;
/* The X and Y deltas of the last call to `x-show-tip'. */ /* The X and Y deltas of the last call to `x-show-tip'. */
Lisp_Object tip_dx, tip_dy; Lisp_Object tip_dx, tip_dy;
/* The window-system window corresponding to the frame of the
currently visible tooltip. */
static Window tip_window;
/* A timer that hides or deletes the currently visible tooltip when it /* A timer that hides or deletes the currently visible tooltip when it
fires. */ fires. */
static Lisp_Object tip_timer; static Lisp_Object tip_timer;
@ -610,7 +606,7 @@ initial_setup_back_buffer (struct frame *f)
unblock_input (); unblock_input ();
} }
static void static Lisp_Object
unwind_create_frame (Lisp_Object frame) unwind_create_frame (Lisp_Object frame)
{ {
struct frame *f = XFRAME (frame); struct frame *f = XFRAME (frame);
@ -619,22 +615,27 @@ unwind_create_frame (Lisp_Object frame)
display is disconnected after the frame has become official, but display is disconnected after the frame has become official, but
before x_create_frame removes the unwind protect. */ before x_create_frame removes the unwind protect. */
if (!FRAME_LIVE_P (f)) if (!FRAME_LIVE_P (f))
return; return Qnil;
/* If frame is ``official'', nothing to do. */ /* If frame is ``official'', nothing to do. */
if (NILP (Fmemq (frame, Vframe_list))) if (NILP (Fmemq (frame, Vframe_list)))
{ {
haiku_free_frame_resources (f); haiku_free_frame_resources (f);
free_glyphs (f); free_glyphs (f);
return Qt;
} }
return Qnil;
} }
static void static void
unwind_create_tip_frame (Lisp_Object frame) unwind_create_tip_frame (Lisp_Object frame)
{ {
unwind_create_frame (frame); Lisp_Object deleted;
tip_window = NULL;
tip_frame = Qnil; deleted = unwind_create_frame (frame);
if (deleted)
tip_frame = Qnil;
} }
static unsigned long static unsigned long
@ -673,6 +674,12 @@ haiku_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval
} }
} }
static void
do_unwind_create_frame (Lisp_Object frame)
{
unwind_create_frame (frame);
}
static Lisp_Object static Lisp_Object
haiku_create_frame (Lisp_Object parms) haiku_create_frame (Lisp_Object parms)
{ {
@ -759,7 +766,7 @@ haiku_create_frame (Lisp_Object parms)
FRAME_DISPLAY_INFO (f) = dpyinfo; FRAME_DISPLAY_INFO (f) = dpyinfo;
/* With FRAME_DISPLAY_INFO set up, this unwind-protect is safe. */ /* With FRAME_DISPLAY_INFO set up, this unwind-protect is safe. */
record_unwind_protect (unwind_create_frame, frame); record_unwind_protect (do_unwind_create_frame, frame);
/* Set the name; the functions to which we pass f expect the name to /* Set the name; the functions to which we pass f expect the name to
be set. */ be set. */
@ -2504,12 +2511,12 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
break; break;
} }
else else
tip_last_parms = tip_last_parms
calln (Qassq_delete_all, parm, tip_last_parms); = calln (Qassq_delete_all, parm, tip_last_parms);
} }
else else
tip_last_parms = tip_last_parms
calln (Qassq_delete_all, parm, tip_last_parms); = calln (Qassq_delete_all, parm, tip_last_parms);
} }
/* Now check if every parameter in what is left of /* Now check if every parameter in what is left of

View file

@ -66,10 +66,6 @@ static Lisp_Object tip_frame;
/* The X and Y deltas of the last call to `x-show-tip'. */ /* The X and Y deltas of the last call to `x-show-tip'. */
static Lisp_Object tip_dx, tip_dy; static Lisp_Object tip_dx, tip_dy;
/* The window-system window corresponding to the frame of the
currently visible tooltip. */
static NSWindow *tip_window;
/* A timer that hides or deletes the currently visible tooltip when it /* A timer that hides or deletes the currently visible tooltip when it
fires. */ fires. */
static Lisp_Object tip_timer; static Lisp_Object tip_timer;
@ -2959,10 +2955,7 @@ unwind_create_tip_frame (Lisp_Object frame)
deleted = unwind_create_frame (frame); deleted = unwind_create_frame (frame);
if (EQ (deleted, Qt)) if (EQ (deleted, Qt))
{ tip_frame = Qnil;
tip_window = NULL;
tip_frame = Qnil;
}
} }
/* Create a frame for a tooltip on the display described by DPYINFO. /* Create a frame for a tooltip on the display described by DPYINFO.

View file

@ -2646,7 +2646,7 @@ unwind_create_tip_frame (Lisp_Object frame)
when this happens. */ when this happens. */
static Lisp_Object static Lisp_Object
x_create_tip_frame (struct pgtk_display_info *dpyinfo, Lisp_Object parms, struct frame *p) pgtk_create_tip_frame (struct pgtk_display_info *dpyinfo, Lisp_Object parms, struct frame *p)
{ {
struct frame *f; struct frame *f;
Lisp_Object frame; Lisp_Object frame;
@ -3264,10 +3264,13 @@ Text larger than the specified size is clipped. */)
/* Create a frame for the tooltip, and record it in the global /* Create a frame for the tooltip, and record it in the global
variable tip_frame. */ variable tip_frame. */
if (NILP (tip_frame = x_create_tip_frame (FRAME_DISPLAY_INFO (f), parms, f))) if (NILP ((tip_frame = pgtk_create_tip_frame (FRAME_DISPLAY_INFO (f),
parms, f))))
/* Creating the tip frame failed. */ /* Creating the tip frame failed. */
return unbind_to (count, Qnil); return unbind_to (count, Qnil);
} }
else
tip_window = FRAME_X_WINDOW (XFRAME (tip_frame));
tip_f = XFRAME (tip_frame); tip_f = XFRAME (tip_frame);
window = FRAME_ROOT_WINDOW (tip_f); window = FRAME_ROOT_WINDOW (tip_f);

View file

@ -7931,6 +7931,11 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
return unbind_to (count, Qnil); return unbind_to (count, Qnil);
} }
} }
else
/* Required by X11 drag and drop, and left here in the interests of
consistency and in the event drag and drop should be implemented
on W32. */
tip_window = FRAME_W32_WINDOW (XFRAME (tip_frame));
tip_f = XFRAME (tip_frame); tip_f = XFRAME (tip_frame);
window = FRAME_ROOT_WINDOW (tip_f); window = FRAME_ROOT_WINDOW (tip_f);

View file

@ -9109,12 +9109,12 @@ Text larger than the specified size is clipped. */)
break; break;
} }
else else
tip_last_parms = tip_last_parms
calln (Qassq_delete_all, parm, tip_last_parms); = calln (Qassq_delete_all, parm, tip_last_parms);
} }
else else
tip_last_parms = tip_last_parms
calln (Qassq_delete_all, parm, tip_last_parms); = calln (Qassq_delete_all, parm, tip_last_parms);
} }
/* Now check if every parameter in what is left of /* Now check if every parameter in what is left of
@ -9166,6 +9166,9 @@ Text larger than the specified size is clipped. */)
/* Creating the tip frame failed. */ /* Creating the tip frame failed. */
return unbind_to (count, Qnil); return unbind_to (count, Qnil);
} }
else
/* Required by X11 drag and drop. */
tip_window = FRAME_X_WINDOW (XFRAME (tip_frame));
tip_f = XFRAME (tip_frame); tip_f = XFRAME (tip_frame);
window = FRAME_ROOT_WINDOW (tip_f); window = FRAME_ROOT_WINDOW (tip_f);