Hi folks,

The enclosed patch to VNCHooks.cpp is an attempt to make apps like
CorelDRAW a bit more usable with VNC.

With a stock VNC, CorelDRAW V9 on NT 4 fails to redraw the canvas
unless the 'update on timer' option is enabled. This, of course, tends
to make the whole system rather sluggish. Enabling polling is another
possibility but, again, soaks up lots of CPU time. What I want is a
mechanism that doesn't use up lots of CPU but still provides an update
strategy suitable for use with an interactive program.

So instead of triggering an update on every timer message, the patch
detects mouse movement and will trigger an update after a
(configurable) period of time has elapsed between
movements. Furthermore, if the mouse movements stop, and a timer
message is received after the timeout period has elapsed, the update
will get triggered. The parameter 'MouseMoveTimeout' should be set to
the number of milliseconds delay required. For me, (100 - 250) works
OK. Setting it to 0 (the default value) disables the mechanism.

It's rather a hack, and sometimes you have to waggle the mouse again
to get an update but I prefer the behaviour to the alternatives.

If anyone has any better ideas or improvements to this code, please
post them to the list.

Cheers,

Mark

PS. perhaps this or something similar could be integrated into the
standard VNC release, I'm sure there must be quite a few apps that
would benefit from such a mechanism.

PPS. If anyone wants to try this and cannot produce binaries I can
make the modified VNCHooks.dll available.
--- VNCHooks.cpp~       Mon Mar  5 17:32:17 2001
+++ VNCHooks.cpp        Sun May 20 15:17:25 2001
@@ -70,6 +70,9 @@
 BOOL prf_use_MButtonUp = FALSE;                                                // Use 
middle mouse button up events
 BOOL prf_use_RButtonUp = FALSE;                                                // Use 
right mouse button up events
 BOOL prf_use_Deferral = FALSE;                                         // Use 
deferred updates
+UINT prf_MouseMoveTimeout = 0;                                         // Delay 
+period between last mouse move and update
+
+DWORD lastMouseMoveAt = 0;     // time when mouse was last moved
 
 HKEY hModuleKey = NULL;                                                               
 // Key used to save settings
 HINSTANCE hInstance = NULL;                                                    // 
This instance of the DLL
@@ -577,7 +580,15 @@
                break;
 
        case WM_TIMER:
-               if (prf_use_Timer)
+               if(lastMouseMoveAt != 0)
+               {
+                       if((GetCurrentTime() - lastMouseMoveAt) > prf_MouseMoveTimeout)
+                       {
+                               SendDeferredWindowRect(hWnd);
+                               lastMouseMoveAt = 0;
+                       }
+               }
+               if (prf_use_Timer)
                        SendDeferredWindowRect(hWnd);
                break;
 
@@ -692,6 +703,16 @@
                // WinRFB also wants to know about mouse movement
        case WM_NCMOUSEMOVE:
        case WM_MOUSEMOVE:
+               if (prf_MouseMoveTimeout != 0)
+               {
+                       DWORD currentTime = GetCurrentTime();
+                       if(lastMouseMoveAt == 0 ||
+                          (currentTime - lastMouseMoveAt) > prf_MouseMoveTimeout)
+                       {
+                               SendDeferredWindowRect(hWnd);
+                       }
+                       lastMouseMoveAt = currentTime;
+               }
                // Inform WinRFB that the mouse has moved and pass it the current 
cursor handle
                PostMessage(
                        hVeneto,
@@ -1034,6 +1055,10 @@
                "use_Deferral",
                TRUE
                );
+       prf_MouseMoveTimeout = GetProfileInt(
+               "MouseMoveTimeout",
+               0
+               );
 
        return TRUE;
 }
@@ -1088,6 +1113,11 @@
                WriteProfileInt(
                        "use_Deferral",
                        prf_use_Deferral
+                       );
+
+               WriteProfileInt(
+                       "MouseMoveTimeout",
+                       prf_MouseMoveTimeout
                        );
 
                free(sModulePrefs);
---------------------------------------------------------------------
To unsubscribe, send a message with the line: unsubscribe vnc-list
to [EMAIL PROTECTED]
See also: http://www.uk.research.att.com/vnc/intouch.html
---------------------------------------------------------------------

Reply via email to