mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-01-11 01:40:25 +01:00
Always allocate an event queue
On the typical setup we have at least 3 events pending as soon as we hook it up (seat added, device added, capability). In the udev case we get up to > 64 events without even having input events on my laptop with only two extra devices connected. So always allocate an event buffer to avoid spurious resizing. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
faee8fe1a7
commit
c0ac1ef9f2
1 changed files with 8 additions and 4 deletions
|
|
@ -372,6 +372,13 @@ libinput_init(struct libinput *libinput,
|
|||
if (libinput->epoll_fd < 0)
|
||||
return -1;
|
||||
|
||||
libinput->events_len = 4;
|
||||
libinput->events = zalloc(libinput->events_len * sizeof(*libinput->events));
|
||||
if (!libinput->events) {
|
||||
close(libinput->epoll_fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
libinput->interface = interface;
|
||||
libinput->user_data = user_data;
|
||||
list_init(&libinput->source_destroy_list);
|
||||
|
|
@ -869,10 +876,7 @@ libinput_post_event(struct libinput *libinput,
|
|||
|
||||
events_count++;
|
||||
if (events_count > events_len) {
|
||||
if (events_len == 0)
|
||||
events_len = 4;
|
||||
else
|
||||
events_len *= 2;
|
||||
events_len *= 2;
|
||||
events = realloc(events, events_len * sizeof *events);
|
||||
if (!events) {
|
||||
fprintf(stderr, "Failed to reallocate event ring "
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue