Avoid races between the tooltip and compositor on X and Android

* java/org/gnu/emacs/EmacsView.java (onLayout): Don't send
exposure events when the window is still to be attached.

* src/androidfns.c (Fx_show_tip):

* src/xfns.c (Fx_show_tip): Block async input around initial
frame update.
This commit is contained in:
Po Lu 2024-06-19 10:57:07 +08:00
parent 94be2b2682
commit 5fceb53856
3 changed files with 18 additions and 1 deletions

View file

@ -425,7 +425,7 @@ else if (child.getVisibility () != GONE)
window.viewLayout (left, top, right, bottom);
}
if (needExpose)
if (needExpose && isAttachedToWindow)
EmacsNative.sendExpose (this.window.handle, 0, 0,
right - left, bottom - top);
}

View file

@ -2564,9 +2564,16 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
/* Garbage the tip frame too. */
SET_FRAME_GARBAGED (tip_f);
/* Block input around `update_single_window' and `flush_frame', lest a
ConfigureNotify and Expose event arrive during the update, and set
flags, e.g. garbaged_p, that are cleared once the update completes,
leaving the requested exposure or configuration outstanding. */
block_input ();
w->must_be_updated_p = true;
update_single_window (w);
flush_frame (tip_f);
unblock_input ();
set_buffer_internal_1 (old_buffer);
unbind_to (count_1, Qnil);
windows_or_buffers_changed = old_windows_or_buffers_changed;

View file

@ -9299,9 +9299,19 @@ Text larger than the specified size is clipped. */)
x_cr_update_surface_desired_size (tip_f, width, height);
#endif /* USE_CAIRO */
/* Garbage the tip frame too. */
SET_FRAME_GARBAGED (tip_f);
/* Block input around `update_single_window' and `flush_frame', lest a
ConfigureNotify and Expose event arrive during the update, and set
flags, e.g. garbaged_p, that are cleared once the update completes,
leaving the requested exposure or configuration outstanding. */
block_input ();
w->must_be_updated_p = true;
update_single_window (w);
flush_frame (tip_f);
unblock_input ();
set_buffer_internal_1 (old_buffer);
unbind_to (count_1, Qnil);
windows_or_buffers_changed = old_windows_or_buffers_changed;