mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-11 11:20:12 +00:00
[broadway] Serialize event times
Event times come from the browser and may change weirdly when we reconnect with another browser, so we normalize these to be strictly increasing and with a 5 second gap for each reconnect.
This commit is contained in:
parent
9d974ca13a
commit
095ccf9c11
@ -263,7 +263,7 @@ gdk_broadway_device_grab (GdkDevice *device,
|
||||
return GDK_GRAB_ALREADY_GRABBED;
|
||||
|
||||
if (time_ == 0)
|
||||
time_ = broadway_display->last_event_time;
|
||||
time_ = broadway_display->last_seen_time;
|
||||
|
||||
broadway_display->pointer_grab_window = window;
|
||||
broadway_display->pointer_grab_owner_events = owner_events;
|
||||
|
@ -62,6 +62,7 @@ gdk_event_init (GdkDisplay *display)
|
||||
broadway_display = GDK_BROADWAY_DISPLAY (display);
|
||||
broadway_display->event_source = _gdk_broadway_event_source_new (display);
|
||||
broadway_display->saved_serial = 1;
|
||||
broadway_display->last_seen_time = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -137,6 +138,8 @@ struct BroadwayInput {
|
||||
GSocketConnection *connection;
|
||||
GByteArray *buffer;
|
||||
GSource *source;
|
||||
gboolean seen_time;
|
||||
gint64 time_base;
|
||||
};
|
||||
|
||||
static void
|
||||
@ -200,6 +203,7 @@ parse_input_message (BroadwayInput *input, const char *message)
|
||||
GdkBroadwayDisplay *broadway_display;
|
||||
BroadwayInputMsg msg;
|
||||
char *p;
|
||||
gint64 time_;
|
||||
|
||||
broadway_display = GDK_BROADWAY_DISPLAY (input->display);
|
||||
|
||||
@ -207,9 +211,26 @@ parse_input_message (BroadwayInput *input, const char *message)
|
||||
msg.base.type = *p++;
|
||||
msg.base.serial = (guint32)strtol (p, &p, 10);
|
||||
p++; /* Skip , */
|
||||
msg.base.time = strtol(p, &p, 10);
|
||||
time_ = strtol(p, &p, 10);
|
||||
p++; /* Skip , */
|
||||
|
||||
if (time_ == 0) {
|
||||
time_ = broadway_display->last_seen_time;
|
||||
} else {
|
||||
if (!input->seen_time) {
|
||||
input->seen_time = TRUE;
|
||||
/* Calculate time base so that any following times are normalized to start
|
||||
5 seconds after last_seen_time, to avoid issues that could appear when
|
||||
a long hiatus due to a reconnect seems to be instant */
|
||||
input->time_base = time_ - (broadway_display->last_seen_time + 5000);
|
||||
}
|
||||
time_ = time_ - input->time_base;
|
||||
}
|
||||
|
||||
broadway_display->last_seen_time = time_;
|
||||
|
||||
msg.base.time = time_;
|
||||
|
||||
switch (msg.base.type) {
|
||||
case 'e': /* Enter */
|
||||
case 'l': /* Leave */
|
||||
|
@ -150,21 +150,17 @@ struct _GdkBroadwayDisplay
|
||||
/* input GdkDevice list */
|
||||
GList *input_devices;
|
||||
|
||||
/* Time of most recent user interaction. */
|
||||
gulong user_time;
|
||||
|
||||
/* The offscreen window that has the pointer in it (if any) */
|
||||
GdkWindow *active_offscreen_window;
|
||||
|
||||
GSocketService *service;
|
||||
BroadwayOutput *output;
|
||||
guint32 saved_serial;
|
||||
guint64 last_seen_time;
|
||||
BroadwayInput *input;
|
||||
GList *input_messages;
|
||||
guint process_input_idle;
|
||||
|
||||
guint64 last_event_time;
|
||||
|
||||
/* Explicit pointer grabs: */
|
||||
GdkWindow *pointer_grab_window;
|
||||
guint32 pointer_grab_time;
|
||||
|
@ -98,8 +98,6 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
|
||||
GdkEvent *event = NULL;
|
||||
GList *node;
|
||||
|
||||
display_broadway->last_event_time = message->base.time;
|
||||
|
||||
switch (message->base.type) {
|
||||
case 'e': /* Enter */
|
||||
display_broadway->last_x = message->pointer.root_x;
|
||||
|
Loading…
Reference in New Issue
Block a user