You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-30 18:30:54 +00:00
Lower timeout in X11 event thread to fix input delay issue
This commit is contained in:
@@ -4519,7 +4519,7 @@ Bool DisplayServerX11::_predicate_all_events(Display *display, XEvent *event, XP
|
||||
return True;
|
||||
}
|
||||
|
||||
bool DisplayServerX11::_wait_for_events() const {
|
||||
bool DisplayServerX11::_wait_for_events(int timeout_seconds, int timeout_microseconds) const {
|
||||
int x11_fd = ConnectionNumber(x11_display);
|
||||
fd_set in_fds;
|
||||
|
||||
@@ -4529,8 +4529,8 @@ bool DisplayServerX11::_wait_for_events() const {
|
||||
FD_SET(x11_fd, &in_fds);
|
||||
|
||||
struct timeval tv;
|
||||
tv.tv_usec = 0;
|
||||
tv.tv_sec = 1;
|
||||
tv.tv_sec = timeout_seconds;
|
||||
tv.tv_usec = timeout_microseconds;
|
||||
|
||||
// Wait for next event or timeout.
|
||||
int num_ready_fds = select(x11_fd + 1, &in_fds, nullptr, nullptr, &tv);
|
||||
@@ -4549,7 +4549,8 @@ bool DisplayServerX11::_wait_for_events() const {
|
||||
|
||||
void DisplayServerX11::_poll_events() {
|
||||
while (!events_thread_done.is_set()) {
|
||||
_wait_for_events();
|
||||
// Wait with a shorter timeout from the events thread to avoid delayed inputs.
|
||||
_wait_for_events(0, 1000);
|
||||
|
||||
// Process events from the queue.
|
||||
{
|
||||
|
||||
@@ -379,7 +379,7 @@ class DisplayServerX11 : public DisplayServer {
|
||||
SafeFlag events_thread_done;
|
||||
LocalVector<XEvent> polled_events;
|
||||
static void _poll_events_thread(void *ud);
|
||||
bool _wait_for_events() const;
|
||||
bool _wait_for_events(int timeout_seconds = 1, int timeout_microseconds = 0) const;
|
||||
void _poll_events();
|
||||
void _check_pending_events(LocalVector<XEvent> &r_events);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user