Merge pull request #6694 from symless/issue-6487-mouse-freeze-2

Updated fix for cusor freezes
This commit is contained in:
Jnewbon 2020-06-01 11:46:24 +01:00 committed by GitHub
commit 189b0be445
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View file

@ -81,6 +81,12 @@ XWindowsEventQueueBuffer::~XWindowsEventQueueBuffer()
close(m_pipefd[1]); close(m_pipefd[1]);
} }
int XWindowsEventQueueBuffer::getPendingCountLocked()
{
Lock lock(&m_mutex);
return XPending(m_display);
}
void void
XWindowsEventQueueBuffer::waitForEvent(double dtimeout) XWindowsEventQueueBuffer::waitForEvent(double dtimeout)
{ {
@ -120,7 +126,7 @@ XWindowsEventQueueBuffer::waitForEvent(double dtimeout)
pfds[1].fd = m_pipefd[0]; pfds[1].fd = m_pipefd[0];
pfds[1].events = POLLIN; pfds[1].events = POLLIN;
int timeout = (dtimeout < 0.0) ? -1 : int timeout = (dtimeout < 0.0) ? -1 :
static_cast<int>(dtimeout); static_cast<int>(1000.0 * dtimeout);
int remaining = timeout; int remaining = timeout;
int retval = 0; int retval = 0;
#else #else
@ -162,7 +168,7 @@ XWindowsEventQueueBuffer::waitForEvent(double dtimeout)
// we want to give the cpu a chance s owe up this to 25ms // we want to give the cpu a chance s owe up this to 25ms
#define TIMEOUT_DELAY 25 #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 #if HAVE_POLL
retval = poll(pfds, 2, TIMEOUT_DELAY); //16ms = 60hz, but we make it > to play nicely with the cpu retval = poll(pfds, 2, TIMEOUT_DELAY); //16ms = 60hz, but we make it > to play nicely with the cpu
if (pfds[1].revents & POLLIN) { if (pfds[1].revents & POLLIN) {

View file

@ -49,6 +49,8 @@ public:
private: private:
void flush(); void flush();
int getPendingCountLocked();
private: private:
typedef std::vector<XEvent> EventList; typedef std::vector<XEvent> EventList;