aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-07-22 09:38:32 +0800
committerPo Lu2022-07-22 09:38:32 +0800
commit83c2c36d35f55d012e5dcb2cc566697b225dcf86 (patch)
treec20b17fedc0fa8fdaa4babbeb300434194e37554 /src
parent46e07d0a4bdb19b0aed26917227d7846bdb0f43c (diff)
downloademacs-83c2c36d35f55d012e5dcb2cc566697b225dcf86.tar.gz
emacs-83c2c36d35f55d012e5dcb2cc566697b225dcf86.zip
Fix posn-timestamp of scroll bar events on GTK
* src/xterm.c (x_get_last_toolkit_time): New function. (x_scroll_bar_to_input_event) (x_horizontal_scroll_bar_to_input_event): Use it to retrieve toolkit time. (xg_scroll_callback, xg_end_scroll_callback): Set last user time if possible.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c68
1 files changed, 43 insertions, 25 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 1e9161c7ab0..8b12d92f187 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -13054,15 +13054,26 @@ static void x_send_scroll_bar_event (Lisp_Object, enum scroll_bar_part,
13054 13054
13055static Lisp_Object window_being_scrolled; 13055static Lisp_Object window_being_scrolled;
13056 13056
13057/* Whether this is an Xaw with arrow-scrollbars. This should imply 13057static Time
13058 that movements of 1/20 of the screen size are mapped to up/down. */ 13058x_get_last_toolkit_time (struct x_display_info *dpyinfo)
13059{
13060#ifdef USE_X_TOOLKIT
13061 return XtLastTimestampProcessed (dpyinfo->display);
13062#else
13063 return dpyinfo->last_user_time;
13064#endif
13065}
13059 13066
13060#ifndef USE_GTK 13067#ifndef USE_GTK
13061/* Id of action hook installed for scroll bars. */ 13068/* Id of action hook installed for scroll bars and horizontal scroll
13069 bars. */
13062 13070
13063static XtActionHookId action_hook_id; 13071static XtActionHookId action_hook_id;
13064static XtActionHookId horizontal_action_hook_id; 13072static XtActionHookId horizontal_action_hook_id;
13065 13073
13074/* Whether this is an Xaw with arrow-scrollbars. This should imply
13075 that movements of 1/20 of the screen size are mapped to up/down. */
13076
13066static Boolean xaw3d_arrow_scroll; 13077static Boolean xaw3d_arrow_scroll;
13067 13078
13068/* Whether the drag scrolling maintains the mouse at the top of the 13079/* Whether the drag scrolling maintains the mouse at the top of the
@@ -13273,12 +13284,8 @@ x_scroll_bar_to_input_event (const XEvent *event,
13273 ievent->kind = SCROLL_BAR_CLICK_EVENT; 13284 ievent->kind = SCROLL_BAR_CLICK_EVENT;
13274 ievent->frame_or_window = window; 13285 ievent->frame_or_window = window;
13275 ievent->arg = Qnil; 13286 ievent->arg = Qnil;
13276#ifdef USE_GTK 13287 ievent->timestamp
13277 ievent->timestamp = CurrentTime; 13288 = x_get_last_toolkit_time (FRAME_DISPLAY_INFO (XFRAME (w->frame)));
13278#else
13279 ievent->timestamp =
13280 XtLastTimestampProcessed (FRAME_X_DISPLAY (XFRAME (w->frame)));
13281#endif
13282 ievent->code = 0; 13289 ievent->code = 0;
13283 ievent->part = ev->data.l[2]; 13290 ievent->part = ev->data.l[2];
13284 ievent->x = make_fixnum (ev->data.l[3]); 13291 ievent->x = make_fixnum (ev->data.l[3]);
@@ -13308,12 +13315,8 @@ x_horizontal_scroll_bar_to_input_event (const XEvent *event,
13308 ievent->kind = HORIZONTAL_SCROLL_BAR_CLICK_EVENT; 13315 ievent->kind = HORIZONTAL_SCROLL_BAR_CLICK_EVENT;
13309 ievent->frame_or_window = window; 13316 ievent->frame_or_window = window;
13310 ievent->arg = Qnil; 13317 ievent->arg = Qnil;
13311#ifdef USE_GTK 13318 ievent->timestamp
13312 ievent->timestamp = CurrentTime; 13319 = x_get_last_toolkit_time (FRAME_DISPLAY_INFO (XFRAME (w->frame)));
13313#else
13314 ievent->timestamp =
13315 XtLastTimestampProcessed (FRAME_X_DISPLAY (XFRAME (w->frame)));
13316#endif
13317 ievent->code = 0; 13320 ievent->code = 0;
13318 ievent->part = ev->data.l[2]; 13321 ievent->part = ev->data.l[2];
13319 ievent->x = make_fixnum (ev->data.l[3]); 13322 ievent->x = make_fixnum (ev->data.l[3]);
@@ -13417,19 +13420,31 @@ xm_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data)
13417 bar widget. DATA is a pointer to the scroll_bar structure. */ 13420 bar widget. DATA is a pointer to the scroll_bar structure. */
13418 13421
13419static gboolean 13422static gboolean
13420xg_scroll_callback (GtkRange *range, 13423xg_scroll_callback (GtkRange *range, GtkScrollType scroll,
13421 GtkScrollType scroll, 13424 gdouble value, gpointer user_data)
13422 gdouble value,
13423 gpointer user_data)
13424{ 13425{
13425 int whole = 0, portion = 0; 13426 int whole, portion;
13426 struct scroll_bar *bar = user_data; 13427 struct scroll_bar *bar;
13427 enum scroll_bar_part part = scroll_bar_nowhere; 13428 enum scroll_bar_part part;
13428 GtkAdjustment *adj = GTK_ADJUSTMENT (gtk_range_get_adjustment (range)); 13429 GtkAdjustment *adj;
13429 struct frame *f = g_object_get_data (G_OBJECT (range), XG_FRAME_DATA); 13430 struct frame *f;
13431 guint32 time;
13432 struct x_display_info *dpyinfo;
13430 13433
13431 if (xg_ignore_gtk_scrollbar) return false; 13434 if (xg_ignore_gtk_scrollbar) return false;
13432 13435
13436 whole = 0;
13437 portion = 0;
13438 bar = user_data;
13439 part = scroll_bar_nowhere;
13440 adj = GTK_ADJUSTMENT (gtk_range_get_adjustment (range));
13441 f = g_object_get_data (G_OBJECT (range), XG_FRAME_DATA);
13442 time = gtk_get_current_event_time ();
13443 dpyinfo = FRAME_DISPLAY_INFO (f);
13444
13445 if (time != GDK_CURRENT_TIME)
13446 x_display_set_last_user_time (dpyinfo, time, true);
13447
13433 switch (scroll) 13448 switch (scroll)
13434 { 13449 {
13435 case GTK_SCROLL_JUMP: 13450 case GTK_SCROLL_JUMP:
@@ -13496,8 +13511,11 @@ xg_end_scroll_callback (GtkWidget *widget,
13496 GdkEventButton *event, 13511 GdkEventButton *event,
13497 gpointer user_data) 13512 gpointer user_data)
13498{ 13513{
13499 struct scroll_bar *bar = user_data; 13514 struct scroll_bar *bar;
13515
13516 bar = user_data;
13500 bar->dragging = -1; 13517 bar->dragging = -1;
13518
13501 if (WINDOWP (window_being_scrolled)) 13519 if (WINDOWP (window_being_scrolled))
13502 { 13520 {
13503 x_send_scroll_bar_event (window_being_scrolled, 13521 x_send_scroll_bar_event (window_being_scrolled,