From 90dda33108dc505f66d79c6422cf69456c5b7fa0 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Wed, 19 Jan 2022 02:08:52 +0000 Subject: [PATCH] Use more reliable timestamps for some kinds of events on Haiku * src/haiku_support.cc (DispatchMessage): (MouseMoved): (MouseDown): (MouseUp): Set `time' field of event structures to input server time. * src/haiku_support.h (struct haiku_key_event): (struct haiku_mouse_motion_event): (struct haiku_button_event): New field `time'. * src/haikuterm.c (haiku_read_socket): Use input server time if provided. --- src/haiku_support.cc | 5 ++++- src/haiku_support.h | 8 +++++++- src/haikuterm.c | 9 +++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 53716ff1612..cd4e6e46cd2 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -720,6 +720,7 @@ public: int ret; msg->FindInt32 ("raw_char", &raw); msg->FindInt32 ("key", &key); + msg->FindInt64 ("when", &rq.time); rq.modifiers = 0; uint32_t mods = modifiers (); @@ -1382,8 +1383,8 @@ public: rq.just_exited_p = transit == B_EXITED_VIEW; rq.x = point.x; rq.y = point.y; - rq.be_code = transit; rq.window = this->Window (); + rq.time = system_time (); if (ToolTip ()) ToolTip ()->SetMouseRelativeLocation (BPoint (-(point.x - tt_absl_pos.x), @@ -1438,6 +1439,7 @@ public: SetMouseEventMask (B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS); + rq.time = system_time (); haiku_write (BUTTON_DOWN, &rq); } @@ -1484,6 +1486,7 @@ public: if (!buttons) SetMouseEventMask (0, 0); + rq.time = system_time (); haiku_write (BUTTON_UP, &rq); } }; diff --git a/src/haiku_support.h b/src/haiku_support.h index 83f22972ce2..6ddc28759b5 100644 --- a/src/haiku_support.h +++ b/src/haiku_support.h @@ -34,6 +34,8 @@ along with GNU Emacs. If not, see . */ #include +#include + enum haiku_cursor { CURSOR_ID_NO_CURSOR = 12, @@ -132,6 +134,9 @@ struct haiku_key_event int modifiers; unsigned keysym; uint32_t multibyte_char; + + /* Time the keypress occurred, in microseconds. */ + bigtime_t time; }; struct haiku_activation_event @@ -146,7 +151,7 @@ struct haiku_mouse_motion_event bool just_exited_p; int x; int y; - uint32_t be_code; + bigtime_t time; }; struct haiku_button_event @@ -156,6 +161,7 @@ struct haiku_button_event int modifiers; int x; int y; + bigtime_t time; }; struct haiku_iconification_event diff --git a/src/haikuterm.c b/src/haikuterm.c index 0fa6050b478..93ba088f5b1 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -2725,6 +2725,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit) inev.kind = inev.code > 127 ? MULTIBYTE_CHAR_KEYSTROKE_EVENT : ASCII_KEYSTROKE_EVENT; + inev.timestamp = b->time / 1000; inev.modifiers = haiku_modifiers_to_emacs (b->modifiers); XSETFRAME (inev.frame_or_window, f); break; @@ -2763,7 +2764,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit) Lisp_Object frame; XSETFRAME (frame, f); - x_display_list->last_mouse_movement_time = system_time () / 1000; + x_display_list->last_mouse_movement_time = b->time / 1000; button_or_motion_p = 1; if (hlinfo->mouse_face_hidden) @@ -2889,7 +2890,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit) inev.modifiers = haiku_modifiers_to_emacs (b->modifiers); x_display_list->last_mouse_glyph_frame = 0; - x_display_list->last_mouse_movement_time = system_time () / 1000; + x_display_list->last_mouse_movement_time = b->time / 1000; button_or_motion_p = 1; /* Is this in the tab-bar? */ @@ -3294,7 +3295,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit) if (inev.kind != NO_EVENT) { - if (inev.kind != HELP_EVENT) + if (inev.kind != HELP_EVENT && !inev.timestamp) inev.timestamp = (button_or_motion_p ? x_display_list->last_mouse_movement_time : system_time () / 1000); @@ -3304,7 +3305,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit) if (inev2.kind != NO_EVENT) { - if (inev2.kind != HELP_EVENT) + if (inev2.kind != HELP_EVENT && !inev.timestamp) inev2.timestamp = (button_or_motion_p ? x_display_list->last_mouse_movement_time : system_time () / 1000); -- 2.39.2