Implemented new "Autoplay" parameter to start the player in the
playback mode. Positioning during playback is now allowed. The desktop
contents is now being updated correctly on startup and after
positioning in the paused mode. Also a number of minor cleanups.


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2520 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/java/src/com/tightvnc/rfbplayer/VncCanvas.java b/java/src/com/tightvnc/rfbplayer/VncCanvas.java
index 953e61d..8272016 100644
--- a/java/src/com/tightvnc/rfbplayer/VncCanvas.java
+++ b/java/src/com/tightvnc/rfbplayer/VncCanvas.java
@@ -25,6 +25,7 @@
 import java.awt.image.*;
 import java.io.*;
 import java.lang.*;
+import java.util.*;
 import java.util.zip.*;
 
 
@@ -32,7 +33,7 @@
 // VncCanvas is a subclass of Canvas which draws a VNC desktop on it.
 //
 
-class VncCanvas extends Canvas {
+class VncCanvas extends Canvas implements Observer {
 
   RfbPlayer player;
   RfbProto rfb;
@@ -214,8 +215,13 @@
     zlibInflater = new Inflater();
     tightInflaters = new Inflater[4];
 
+    // Show current time position in the control panel.
     player.updatePos();
 
+    // Tell our FbsInputStream object to notify us when it goes to the
+    // `paused' mode.
+    rfb.fbs.addObserver(this);
+
     // Main dispatch loop.
 
     while (true) {
@@ -820,14 +826,27 @@
       seekMode = true;
     } else {
       if (seekMode) {
-	// Full-screen immediate repaint after seeking.
+	// Immediate repaint of the whole desktop after seeking.
 	repaint();
       } else {
-	// Usual incremental repaint in playback mode.
+	// Usual incremental repaint.
 	repaint(player.deferScreenUpdates, x, y, w, h);
       }
       seekMode = false;
     }
   }
 
+  //
+  // We are observing our FbsInputStream object to get notified on
+  // switching to the `paused' mode. In such cases we want to repaint
+  // our desktop if we were seeking.
+  //
+
+  public void update(Observable o, Object arg) {
+    // Immediate repaint of the whole desktop after seeking.
+    repaint();
+    // Let next scheduleRepaint() call invoke incremental drawing.
+    seekMode = false;
+  }
+
 }