]> source.dussan.org Git - tigervnc.git/commitdiff
Do not poll screen area near the pointer if the pointer did not move
authorConstantin Kaplinsky <const@tightvnc.com>
Fri, 10 Feb 2006 12:19:11 +0000 (12:19 +0000)
committerConstantin Kaplinsky <const@tightvnc.com>
Fri, 10 Feb 2006 12:19:11 +0000 (12:19 +0000)
for about 5 seconds.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@481 3789f03b-4d11-0410-bbf8-ca57d06f2519

x0vncserver/PollingManager.cxx
x0vncserver/PollingManager.h

index 2d8b87af4c0e5cb7e1bd597cc5ebd6647e8645a2..0c972dd348cc1254a443f55af23f8763fbcaae55 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <time.h>
 #include <sys/time.h>
 #include <X11/Xlib.h>
 #include <rfb/VNCServer.h>
@@ -126,14 +127,13 @@ void PollingManager::setVNCServer(VNCServer *s)
 
 void PollingManager::setPointerPos(const Point &pos)
 {
+  m_pointerPosTime = time(NULL);
   m_pointerPos = pos;
   m_pointerPosKnown = true;
 }
 
 //
 // Indicate that current pointer position is unknown.
-// FIXME: Perhaps this should be done automatically after a number of
-//        polling cycles if the cursor position have not been changed?
 //
 
 void PollingManager::unsetPointerPos()
@@ -190,8 +190,17 @@ void PollingManager::poll()
   }
 
   // Second step: optional thorough polling of the area around the pointer.
+  // We do that only if the pointer position is known and was set recently.
 
-  bool changes2 = pollPointer && m_pointerPosKnown && pollPointerArea();
+  bool changes2 = false;
+  if (pollPointer) {
+    if (m_pointerPosKnown && time(NULL) - m_pointerPosTime >= 5) {
+      unsetPointerPos();
+    }
+    if (m_pointerPosKnown) {
+      changes2 = pollPointerArea();
+    }
+  }
 
   // Update if needed.
 
index a35fafee8ba61d2c94118cd717510c92f05ae259..04cc767d6f0974a0389ba1b8aa9f85c80baa6102 100644 (file)
@@ -76,6 +76,7 @@ protected:
   // Tracking pointer position for polling improvements.
   bool m_pointerPosKnown;
   Point m_pointerPos;
+  time_t m_pointerPosTime;
 
 private: