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.
This commit is contained in:
Po Lu 2022-01-19 02:08:52 +00:00
parent d5723560d5
commit 90dda33108
3 changed files with 16 additions and 6 deletions

View file

@ -720,6 +720,7 @@ class EmacsWindow : public BWindow
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 @@ class EmacsView : public BView
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 @@ class EmacsView : public BView
SetMouseEventMask (B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
rq.time = system_time ();
haiku_write (BUTTON_DOWN, &rq);
}
@ -1484,6 +1486,7 @@ class EmacsView : public BView
if (!buttons)
SetMouseEventMask (0, 0);
rq.time = system_time ();
haiku_write (BUTTON_UP, &rq);
}
};

View file

@ -34,6 +34,8 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include <math.h>
#include <kernel/OS.h>
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

View file

@ -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);