Merge pull request #54313 from nekomatata/x11-fix-input-delay-3.x
This commit is contained in:
commit
2c47e33905
2 changed files with 31 additions and 20 deletions
|
@ -2310,6 +2310,15 @@ void OS_X11::_poll_events() {
|
||||||
{
|
{
|
||||||
MutexLock mutex_lock(events_mutex);
|
MutexLock mutex_lock(events_mutex);
|
||||||
|
|
||||||
|
_check_pending_events(polled_events);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OS_X11::_check_pending_events(LocalVector<XEvent> &r_events) {
|
||||||
|
// Flush to make sure to gather all pending events.
|
||||||
|
XFlush(x11_display);
|
||||||
|
|
||||||
// Non-blocking wait for next event and remove it from the queue.
|
// Non-blocking wait for next event and remove it from the queue.
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
while (XCheckIfEvent(x11_display, &ev, _predicate_all_events, nullptr)) {
|
while (XCheckIfEvent(x11_display, &ev, _predicate_all_events, nullptr)) {
|
||||||
|
@ -2328,9 +2337,7 @@ void OS_X11::_poll_events() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
polled_events.push_back(ev);
|
r_events.push_back(ev);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2352,6 +2359,9 @@ void OS_X11::process_xevents() {
|
||||||
MutexLock mutex_lock(events_mutex);
|
MutexLock mutex_lock(events_mutex);
|
||||||
events = polled_events;
|
events = polled_events;
|
||||||
polled_events.clear();
|
polled_events.clear();
|
||||||
|
|
||||||
|
// Check for more pending events to avoid an extra frame delay.
|
||||||
|
_check_pending_events(events);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t event_index = 0; event_index < events.size(); ++event_index) {
|
for (uint32_t event_index = 0; event_index < events.size(); ++event_index) {
|
||||||
|
|
|
@ -171,6 +171,7 @@ class OS_X11 : public OS_Unix {
|
||||||
static void _poll_events_thread(void *ud);
|
static void _poll_events_thread(void *ud);
|
||||||
bool _wait_for_events() const;
|
bool _wait_for_events() const;
|
||||||
void _poll_events();
|
void _poll_events();
|
||||||
|
void _check_pending_events(LocalVector<XEvent> &r_events);
|
||||||
|
|
||||||
static Bool _predicate_all_events(Display *display, XEvent *event, XPointer arg);
|
static Bool _predicate_all_events(Display *display, XEvent *event, XPointer arg);
|
||||||
static Bool _predicate_clipboard_selection(Display *display, XEvent *event, XPointer arg);
|
static Bool _predicate_clipboard_selection(Display *display, XEvent *event, XPointer arg);
|
||||||
|
|
Loading…
Add table
Reference in a new issue