The new viewer stores the framebuffer in a native format, instead of
converting it on each render like the old one. That means we have to change
how we deal with colour maps and make sure it is updated before any changes
to the framebuffer.


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4589 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/vncviewer/Viewport.h b/vncviewer/Viewport.h
index 9eb3b73..c9a3cf3 100644
--- a/vncviewer/Viewport.h
+++ b/vncviewer/Viewport.h
@@ -70,6 +70,8 @@
   void fillRect(const rfb::Rect& r, rfb::Pixel pix) {
     if (pixelTrans) {
       rfb::Pixel pix2;
+      if (colourMapChange)
+        commitColourMap();
       pixelTrans->translatePixels(&pix, &pix2, 1);
       pix = pix2;
     }
@@ -78,13 +80,16 @@
     damageRect(r);
   }
   void imageRect(const rfb::Rect& r, void* pixels) {
-    if (pixelTrans)
+    if (pixelTrans) {
+      if (colourMapChange)
+        commitColourMap();
       pixelTrans->translateRect(pixels, r.width(),
                                 rfb::Rect(0, 0, r.width(), r.height()),
                                 frameBuffer->data, frameBuffer->getStride(),
                                 r.tl);
-    else
+    } else {
       frameBuffer->imageRect(r, pixels);
+    }
     damageRect(r);
   }
   void copyRect(const rfb::Rect& r, int srcX, int srcY) {
@@ -112,7 +117,8 @@
   };
 
   static void handleUpdateTimeout(void *data);
-  static void handleColourMap(void *data);
+
+  void commitColourMap();
 
   static void handleClipboardChange(int source, void *data);
 
@@ -136,6 +142,7 @@
 
   rfb::PixelTransformer *pixelTrans;
   rfb::SimpleColourMap colourMap;
+  bool colourMapChange;
 
   rfb::Region damage;