From: Po Lu Date: Thu, 27 Feb 2025 01:53:41 +0000 (+0800) Subject: Fix drag-and-drop treatment of reused tooltip frames X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a9505fc2b89cb905ec8cbadd1b605dee7f84748f;p=emacs.git 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. (cherry picked from commit a4a458ffa4aaeb988ff4b6e6087c44dfdaf40a0b) --- diff --git a/src/androidfns.c b/src/androidfns.c index f8e3d397008..ec8651aafcb 100644 --- a/src/androidfns.c +++ b/src/androidfns.c @@ -2449,6 +2449,8 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0, /* Creating the tip frame failed. */ return unbind_to (count, Qnil); } + else + tip_window = FRAME_ANDROID_WINDOW (XFRAME (tip_frame)); tip_f = XFRAME (tip_frame); window = FRAME_ROOT_WINDOW (tip_f); diff --git a/src/haikufns.c b/src/haikufns.c index 6490a22bd01..298a27ccc02 100644 --- a/src/haikufns.c +++ b/src/haikufns.c @@ -53,10 +53,6 @@ Lisp_Object tip_frame; /* The X and Y deltas of the last call to `x-show-tip'. */ 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 fires. */ static Lisp_Object tip_timer; @@ -610,7 +606,7 @@ initial_setup_back_buffer (struct frame *f) unblock_input (); } -static void +static Lisp_Object unwind_create_frame (Lisp_Object 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 before x_create_frame removes the unwind protect. */ if (!FRAME_LIVE_P (f)) - return; + return Qnil; /* If frame is ``official'', nothing to do. */ if (NILP (Fmemq (frame, Vframe_list))) { haiku_free_frame_resources (f); free_glyphs (f); + return Qt; } + + return Qnil; } static void unwind_create_tip_frame (Lisp_Object frame) { - unwind_create_frame (frame); - tip_window = NULL; - tip_frame = Qnil; + Lisp_Object deleted; + + deleted = unwind_create_frame (frame); + if (deleted) + tip_frame = Qnil; } 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 haiku_create_frame (Lisp_Object parms) { @@ -759,7 +766,7 @@ haiku_create_frame (Lisp_Object parms) FRAME_DISPLAY_INFO (f) = dpyinfo; /* 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 be set. */ @@ -2504,12 +2511,12 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0, break; } else - tip_last_parms = - calln (Qassq_delete_all, parm, tip_last_parms); + tip_last_parms + = calln (Qassq_delete_all, parm, tip_last_parms); } else - tip_last_parms = - calln (Qassq_delete_all, parm, tip_last_parms); + tip_last_parms + = calln (Qassq_delete_all, parm, tip_last_parms); } /* Now check if every parameter in what is left of diff --git a/src/nsfns.m b/src/nsfns.m index a2c50468cd1..9f52777879c 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -66,10 +66,6 @@ static Lisp_Object tip_frame; /* The X and Y deltas of the last call to `x-show-tip'. */ 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 fires. */ static Lisp_Object tip_timer; @@ -2959,10 +2955,7 @@ unwind_create_tip_frame (Lisp_Object frame) deleted = unwind_create_frame (frame); if (EQ (deleted, Qt)) - { - tip_window = NULL; - tip_frame = Qnil; - } + tip_frame = Qnil; } /* Create a frame for a tooltip on the display described by DPYINFO. diff --git a/src/pgtkfns.c b/src/pgtkfns.c index 73cd6e5695d..6231ef1cb48 100644 --- a/src/pgtkfns.c +++ b/src/pgtkfns.c @@ -2646,7 +2646,7 @@ unwind_create_tip_frame (Lisp_Object frame) when this happens. */ 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; 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 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. */ return unbind_to (count, Qnil); } + else + tip_window = FRAME_X_WINDOW (XFRAME (tip_frame)); tip_f = XFRAME (tip_frame); window = FRAME_ROOT_WINDOW (tip_f); diff --git a/src/w32fns.c b/src/w32fns.c index 89a4d46240a..17221b73470 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -7931,6 +7931,11 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0, 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); window = FRAME_ROOT_WINDOW (tip_f); diff --git a/src/xfns.c b/src/xfns.c index ec7d54180e4..d8a3ce0b3b1 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -9109,12 +9109,12 @@ Text larger than the specified size is clipped. */) break; } else - tip_last_parms = - calln (Qassq_delete_all, parm, tip_last_parms); + tip_last_parms + = calln (Qassq_delete_all, parm, tip_last_parms); } else - tip_last_parms = - calln (Qassq_delete_all, parm, tip_last_parms); + tip_last_parms + = calln (Qassq_delete_all, parm, tip_last_parms); } /* 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. */ 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); window = FRAME_ROOT_WINDOW (tip_f);