Consolidate 'sync' and 'frame' events into just one 'key' event
This commit is contained in:
parent
ac93a3d3d7
commit
c1ad1f9c9b
@ -58,19 +58,12 @@
|
||||
<arg name="base" type="uint"/>
|
||||
</event>
|
||||
|
||||
<!-- A reply to the sync request. All requests made before the
|
||||
"sync" request that had the same key as the one present in
|
||||
this event have been processed by the server. -->
|
||||
<event name="sync">
|
||||
<arg name="key" type="uint"/>
|
||||
</event>
|
||||
|
||||
<!-- A reply to the frame request. The key is the one used in the
|
||||
request. time is in millisecond units, and denotes the time
|
||||
when the frame was posted on the display. time can be used to
|
||||
estimaate frame rate, determine how much to advance
|
||||
animatiosn and compoensate for jitter-->
|
||||
<event name="frame">
|
||||
<!-- A reply to the frame or sync request. The key is the one
|
||||
used in the request. time is in millisecond units, and
|
||||
denotes the time when the frame was posted on the
|
||||
display. time can be used to estimaate frame rate, determine
|
||||
how much to advance animations and compensate for jitter. -->
|
||||
<event name="key">
|
||||
<arg name="key" type="uint"/>
|
||||
<arg name="time" type="uint"/>
|
||||
</event>
|
||||
|
@ -292,38 +292,31 @@ display_handle_range(void *data,
|
||||
}
|
||||
|
||||
static void
|
||||
display_handle_sync(void *data, struct wl_display *display, uint32_t key)
|
||||
display_handle_key(void *data,
|
||||
struct wl_display *display, uint32_t key, uint32_t time)
|
||||
{
|
||||
struct wl_sync_handler *handler;
|
||||
struct wl_sync_handler *sync_handler;
|
||||
struct wl_frame_handler *frame_handler;
|
||||
|
||||
handler = container_of(display->sync_list.next,
|
||||
struct wl_sync_handler, link);
|
||||
if (handler->key != key) {
|
||||
fprintf(stderr, "unsolicited sync event, client gone?\n");
|
||||
sync_handler = container_of(display->sync_list.next,
|
||||
struct wl_sync_handler, link);
|
||||
if (sync_handler->key == key) {
|
||||
wl_list_remove(&sync_handler->link);
|
||||
sync_handler->func(sync_handler->data);
|
||||
free(sync_handler);
|
||||
return;
|
||||
}
|
||||
|
||||
wl_list_remove(&handler->link);
|
||||
handler->func(handler->data);
|
||||
free(handler);
|
||||
}
|
||||
|
||||
static void
|
||||
display_handle_frame(void *data,
|
||||
struct wl_display *display, uint32_t key, uint32_t time)
|
||||
{
|
||||
struct wl_frame_handler *handler;
|
||||
|
||||
handler = container_of(display->frame_list. next,
|
||||
struct wl_frame_handler, link);
|
||||
if (handler->key != key) {
|
||||
fprintf(stderr, "unsolicited frame event, client gone?\n");
|
||||
frame_handler = container_of(display->frame_list. next,
|
||||
struct wl_frame_handler, link);
|
||||
if (frame_handler->key == key) {
|
||||
wl_list_remove(&frame_handler->link);
|
||||
frame_handler->func(frame_handler->data, time);
|
||||
free(frame_handler);
|
||||
return;
|
||||
}
|
||||
|
||||
wl_list_remove(&handler->link);
|
||||
handler->func(handler->data, time);
|
||||
free(handler);
|
||||
fprintf(stderr, "unsolicited sync event, client gone?\n");
|
||||
}
|
||||
|
||||
static const struct wl_display_listener display_listener = {
|
||||
@ -332,8 +325,7 @@ static const struct wl_display_listener display_listener = {
|
||||
display_handle_no_memory,
|
||||
display_handle_global,
|
||||
display_handle_range,
|
||||
display_handle_sync,
|
||||
display_handle_frame
|
||||
display_handle_key
|
||||
};
|
||||
|
||||
WL_EXPORT struct wl_display *
|
||||
|
@ -305,7 +305,7 @@ static void
|
||||
display_sync(struct wl_client *client,
|
||||
struct wl_display *display, uint32_t key)
|
||||
{
|
||||
wl_client_post_event(client, &display->base, WL_DISPLAY_SYNC, key);
|
||||
wl_client_post_event(client, &display->base, WL_DISPLAY_KEY, key, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -421,7 +421,7 @@ wl_display_post_frame(struct wl_display *display, uint32_t time)
|
||||
|
||||
wl_list_for_each_safe(listener, next, &display->frame_list, link) {
|
||||
wl_client_post_event(listener->client, &display->base,
|
||||
WL_DISPLAY_FRAME, listener->key, time);
|
||||
WL_DISPLAY_KEY, listener->key, time);
|
||||
wl_resource_destroy(&listener->resource, listener->client);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user