#6487 XWindowsEventQueueBuffer: Fix delays when waiting for new events
QLength() may return 0 even if there are events pending because they need to be read from the display socket in order to become visible. We must use XPending() which will poll the socket if QLength() == 0.
This commit is contained in:
parent
bf3796aea7
commit
4308b42915
2 changed files with 9 additions and 1 deletions
|
|
@ -81,6 +81,12 @@ XWindowsEventQueueBuffer::~XWindowsEventQueueBuffer()
|
|||
close(m_pipefd[1]);
|
||||
}
|
||||
|
||||
int XWindowsEventQueueBuffer::getPendingCountLocked()
|
||||
{
|
||||
Lock lock(&m_mutex);
|
||||
return XPending(m_display);
|
||||
}
|
||||
|
||||
void
|
||||
XWindowsEventQueueBuffer::waitForEvent(double dtimeout)
|
||||
{
|
||||
|
|
@ -162,7 +168,7 @@ XWindowsEventQueueBuffer::waitForEvent(double dtimeout)
|
|||
// we want to give the cpu a chance s owe up this to 25ms
|
||||
#define TIMEOUT_DELAY 25
|
||||
|
||||
while (((dtimeout < 0.0) || (remaining > 0)) && QLength(m_display)==0 && retval==0){
|
||||
while (((dtimeout < 0.0) || (remaining > 0)) && getPendingCountLocked() == 0 && retval == 0) {
|
||||
#if HAVE_POLL
|
||||
retval = poll(pfds, 2, TIMEOUT_DELAY); //16ms = 60hz, but we make it > to play nicely with the cpu
|
||||
if (pfds[1].revents & POLLIN) {
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ public:
|
|||
private:
|
||||
void flush();
|
||||
|
||||
int getPendingCountLocked();
|
||||
|
||||
private:
|
||||
typedef std::vector<XEvent> EventList;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue