From: Po Lu Date: Sun, 7 Aug 2022 02:18:14 +0000 (+0800) Subject: Correctly set user time on GTK+ for key press events X-Git-Tag: emacs-29.0.90~1447^2~354 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=02ee0254873d4c102728c942dc9659f942c5cfa6;p=emacs.git Correctly set user time on GTK+ for key press events * src/xterm.c (x_set_gtk_user_time): New function. (handle_one_xevent): Call that after key press event on GTK+. --- diff --git a/src/xterm.c b/src/xterm.c index 8f84edc63ee..97985c8d9e7 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -7586,6 +7586,26 @@ x_display_set_last_user_time (struct x_display_info *dpyinfo, Time time, #endif } +#ifdef USE_GTK + +static void +x_set_gtk_user_time (struct frame *f, Time time) +{ + GtkWidget *widget; + GdkWindow *window; + + widget = FRAME_GTK_OUTER_WIDGET (f); + window = gtk_widget_get_window (widget); + + /* This widget isn't realized yet. */ + if (!window) + return; + + gdk_x11_window_set_user_time (window, time); +} + +#endif + /* Not needed on GTK because GTK handles reporting the user time itself. */ @@ -18211,6 +18231,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, x_display_set_last_user_time (dpyinfo, event->xkey.time, event->xkey.send_event); ignore_next_mouse_click_timeout = 0; + coding = Qlatin_1; #if defined (USE_X_TOOLKIT) || defined (USE_GTK) @@ -18221,6 +18242,11 @@ handle_one_xevent (struct x_display_info *dpyinfo, f = any; +#ifdef USE_GTK + if (f) + x_set_gtk_user_time (f, event->xkey.time); +#endif + /* If mouse-highlight is an integer, input clears out mouse highlighting. */ if (!hlinfo->mouse_face_hidden && FIXNUMP (Vmouse_highlight) @@ -21593,6 +21619,15 @@ handle_one_xevent (struct x_display_info *dpyinfo, f = x_any_window_to_frame (dpyinfo, xev->event); + /* GTK handles TAB events in an undesirable manner, so + keyboard events are always dropped. But as a side + effect, the user time will no longer be set by GDK, + so do that manually. */ +#ifdef USE_GTK + if (f) + x_set_gtk_user_time (f, xev->time); +#endif + if (f) { /* If the user interacts with a frame that's focused