mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-03 09:01:42 -05:00
Switch protocol to using serial numbers for ordering events and requests
The wayland protocol, as X, uses timestamps to match up certain requests with input events. The problem is that sometimes we need to send out an event that doesn't have a corresponding timestamped input event. For example, the pointer focus surface goes away and new surface needs to receive a pointer enter event. These events are normally timestamped with the evdev event timestamp, but in this case, we don't have a evdev timestamp. So we have to go to gettimeofday (or clock_gettime()) and then we don't know if it's coming from the same time source etc. However for all these cases we don't need a real time timestamp, we just need a serial number that encodes the order of events inside the server. So we introduce a serial number mechanism that we can use to order events. We still need real-time timestamps for actual input device events (motion, buttons, keys, touch), to be able to reason about double-click speed and movement speed so events that correspond to user input carry both a serial number and a timestamp. The serial number also give us a mechanism to key together events that are "logically the same" such as a unicode event and a keycode event, or a motion event and a relative event from a raw device.
This commit is contained in:
parent
a13aab4e15
commit
5535f155d8
6 changed files with 130 additions and 93 deletions
|
|
@ -96,6 +96,9 @@ struct wl_global *wl_display_add_global(struct wl_display *display,
|
|||
void wl_display_remove_global(struct wl_display *display,
|
||||
struct wl_global *global);
|
||||
|
||||
uint32_t wl_display_get_serial(struct wl_display *display);
|
||||
uint32_t wl_display_next_serial(struct wl_display *display);
|
||||
|
||||
struct wl_client *wl_client_create(struct wl_display *display, int fd);
|
||||
void wl_client_destroy(struct wl_client *client);
|
||||
void wl_client_flush(struct wl_client *client);
|
||||
|
|
@ -129,7 +132,7 @@ struct wl_buffer {
|
|||
struct wl_listener {
|
||||
struct wl_list link;
|
||||
void (*func)(struct wl_listener *listener,
|
||||
struct wl_resource *resource, uint32_t time);
|
||||
struct wl_resource *resource);
|
||||
};
|
||||
|
||||
struct wl_surface {
|
||||
|
|
@ -138,7 +141,7 @@ struct wl_surface {
|
|||
|
||||
struct wl_pointer_grab;
|
||||
struct wl_pointer_grab_interface {
|
||||
void (*focus)(struct wl_pointer_grab *grab, uint32_t time,
|
||||
void (*focus)(struct wl_pointer_grab *grab,
|
||||
struct wl_surface *surface, int32_t x, int32_t y);
|
||||
void (*motion)(struct wl_pointer_grab *grab,
|
||||
uint32_t time, int32_t x, int32_t y);
|
||||
|
|
@ -155,8 +158,8 @@ struct wl_pointer_grab {
|
|||
|
||||
struct wl_keyboard_grab;
|
||||
struct wl_keyboard_grab_interface {
|
||||
void (*key)(struct wl_keyboard_grab *grab,
|
||||
uint32_t time, uint32_t key, int32_t state);
|
||||
void (*key)(struct wl_keyboard_grab *grab, uint32_t time,
|
||||
uint32_t key, int32_t state);
|
||||
};
|
||||
|
||||
struct wl_keyboard_grab {
|
||||
|
|
@ -193,8 +196,8 @@ struct wl_input_device {
|
|||
struct wl_resource *keyboard_focus_resource;
|
||||
struct wl_surface *keyboard_focus;
|
||||
struct wl_array keys;
|
||||
uint32_t pointer_focus_time;
|
||||
uint32_t keyboard_focus_time;
|
||||
uint32_t pointer_focus_serial;
|
||||
uint32_t keyboard_focus_serial;
|
||||
struct wl_listener pointer_focus_listener;
|
||||
struct wl_listener keyboard_focus_listener;
|
||||
|
||||
|
|
@ -208,6 +211,7 @@ struct wl_input_device {
|
|||
struct wl_keyboard_grab default_keyboard_grab;
|
||||
uint32_t button_count;
|
||||
uint32_t grab_time;
|
||||
uint32_t grab_serial;
|
||||
int32_t grab_x, grab_y;
|
||||
uint32_t grab_button;
|
||||
uint32_t grab_key;
|
||||
|
|
@ -266,7 +270,7 @@ struct wl_display *
|
|||
wl_client_get_display(struct wl_client *client);
|
||||
|
||||
void
|
||||
wl_resource_destroy(struct wl_resource *resource, uint32_t time);
|
||||
wl_resource_destroy(struct wl_resource *resource);
|
||||
|
||||
void
|
||||
wl_input_device_init(struct wl_input_device *device);
|
||||
|
|
@ -277,13 +281,11 @@ wl_input_device_release(struct wl_input_device *device);
|
|||
void
|
||||
wl_input_device_set_pointer_focus(struct wl_input_device *device,
|
||||
struct wl_surface *surface,
|
||||
uint32_t time,
|
||||
int32_t sx, int32_t sy);
|
||||
|
||||
void
|
||||
wl_input_device_set_keyboard_focus(struct wl_input_device *device,
|
||||
struct wl_surface *surface,
|
||||
uint32_t time);
|
||||
struct wl_surface *surface);
|
||||
void
|
||||
wl_data_device_set_keyboard_focus(struct wl_input_device *device);
|
||||
int
|
||||
|
|
@ -291,20 +293,19 @@ wl_data_device_manager_init(struct wl_display *display);
|
|||
|
||||
void
|
||||
wl_input_device_start_keyboard_grab(struct wl_input_device *device,
|
||||
struct wl_keyboard_grab *grab, uint32_t time);
|
||||
struct wl_keyboard_grab *grab);
|
||||
void
|
||||
wl_input_device_end_keyboard_grab(struct wl_input_device *device, uint32_t time);
|
||||
wl_input_device_end_keyboard_grab(struct wl_input_device *device);
|
||||
|
||||
void
|
||||
wl_input_device_start_pointer_grab(struct wl_input_device *device,
|
||||
struct wl_pointer_grab *grab, uint32_t time);
|
||||
struct wl_pointer_grab *grab);
|
||||
void
|
||||
wl_input_device_end_pointer_grab(struct wl_input_device *device, uint32_t time);
|
||||
wl_input_device_end_pointer_grab(struct wl_input_device *device);
|
||||
|
||||
void
|
||||
wl_input_device_set_selection(struct wl_input_device *device,
|
||||
struct wl_data_source *source,
|
||||
uint32_t time);
|
||||
struct wl_data_source *source);
|
||||
|
||||
|
||||
void *
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue