1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-31 18:41:20 +00:00

Merge pull request #113537 from Chestnut45/x11-input-fix

X11: Fix input delay regression
This commit is contained in:
Rémi Verschelde
2025-12-19 11:53:10 +01:00
2 changed files with 6 additions and 5 deletions

View File

@@ -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.
{

View File

@@ -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);