Update last event time during DND operations

* lisp/x-dnd.el (x-dnd-handle-xdnd, x-dnd-handle-motif): Set
last user time to provided timestamp.
* src/xfns.c (Fx_display_last_user_time): New function.
(syms_of_xfns): New defsubr.

* src/xterm.c (x_set_last_user_time_from_lisp): New function.
* src/xterm.h: Update prototypes.
This commit is contained in:
Po Lu 2022-06-17 10:24:05 +08:00
parent e75ce9ca38
commit 61a312ba0c
4 changed files with 39 additions and 6 deletions

View file

@ -137,6 +137,7 @@ any protocol specific data.")
(declare-function x-get-selection-internal "xselect.c"
(selection-symbol target-type &optional time-stamp terminal))
(declare-function x-display-set-last-user-time "xfns.c")
(defconst x-dnd-xdnd-to-action
'(("XdndActionPrivate" . private)
@ -621,7 +622,7 @@ FORMAT is 32 (not used). MESSAGE is the data part of an XClientMessageEvent."
(intern (x-dnd-current-type window))
timestamp)))
success action)
(x-display-set-last-user-time timestamp)
(setq action (if value
(condition-case info
(x-dnd-drop-data event frame window value
@ -861,6 +862,7 @@ Return a vector of atoms containing the selection targets."
timestamp
x
y)))
(x-display-set-last-user-time timestamp)
(x-send-client-message frame
dnd-source
frame
@ -898,6 +900,7 @@ Return a vector of atoms containing the selection targets."
my-byteorder)
reply-flags
timestamp)))
(x-display-set-last-user-time timestamp)
(x-send-client-message frame
dnd-source
frame
@ -956,7 +959,7 @@ Return a vector of atoms containing the selection targets."
(timestamp (x-dnd-get-motif-value
data 4 4 source-byteorder))
action)
(x-display-set-last-user-time timestamp)
(x-send-client-message frame
dnd-source
frame

View file

@ -9472,6 +9472,25 @@ DEFUN ("x-gtk-debug", Fx_gtk_debug, Sx_gtk_debug, 1, 1, 0,
#endif /* HAVE_GTK3 */
#endif /* USE_GTK */
DEFUN ("x-display-set-last-user-time", Fx_display_last_user_time,
Sx_display_set_last_user_time, 1, 2, 0,
doc: /* Set the last user time of TERMINAL to TIME-OBJECT.
TIME-OBJECT is the X server time, in milliseconds, of the last user
interaction. This is the timestamp that `x-get-selection-internal'
will use by default to fetch selection data.
TERMINAL is the terminal on which the user interaction occurred. */)
(Lisp_Object time_object, Lisp_Object terminal)
{
struct x_display_info *dpyinfo;
Time time;
dpyinfo = check_x_display_info (terminal);
CONS_TO_INTEGER (time_object, Time, time);
x_set_last_user_time_from_lisp (dpyinfo, time);
return Qnil;
}
DEFUN ("x-internal-focus-input-context", Fx_internal_focus_input_context,
Sx_internal_focus_input_context, 1, 1, 0,
doc: /* Focus and set the client window of all focused frames' GTK input context.
@ -9937,6 +9956,7 @@ eliminated in future versions of Emacs. */);
defsubr (&Sx_hide_tip);
defsubr (&Sx_double_buffered_p);
defsubr (&Sx_begin_drag);
defsubr (&Sx_display_set_last_user_time);
tip_timer = Qnil;
staticpro (&tip_timer);
tip_frame = Qnil;

View file

@ -6921,6 +6921,7 @@ x_display_set_last_user_time (struct x_display_info *dpyinfo, Time time)
#ifdef ENABLE_CHECKING
eassert (time <= X_ULONG_MAX);
#endif
dpyinfo->last_user_time = time;
#ifndef USE_GTK
@ -6989,6 +6990,14 @@ x_display_set_last_user_time (struct x_display_info *dpyinfo, Time time)
#endif
}
void
x_set_last_user_time_from_lisp (struct x_display_info *dpyinfo,
Time time)
{
if (dpyinfo->last_user_time > time)
x_display_set_last_user_time (dpyinfo, time);
}
/* Set S->gc to a suitable GC for drawing glyph string S in cursor
face. */

View file

@ -1427,10 +1427,11 @@ extern void x_unwind_errors_to (int);
extern void x_uncatch_errors (void);
extern void x_uncatch_errors_after_check (void);
extern void x_clear_errors (Display *);
extern void x_set_window_size (struct frame *f, bool, int, int);
extern void x_make_frame_visible (struct frame *f);
extern void x_make_frame_invisible (struct frame *f);
extern void x_iconify_frame (struct frame *f);
extern void x_set_window_size (struct frame *, bool, int, int);
extern void x_set_last_user_time_from_lisp (struct x_display_info *, Time);
extern void x_make_frame_visible (struct frame *);
extern void x_make_frame_invisible (struct frame *);
extern void x_iconify_frame (struct frame *);
extern void x_free_frame_resources (struct frame *);
extern void x_wm_set_size_hint (struct frame *, long, bool);