--- vnc_javasrc.orig/VncCanvas.java	2004-10-10 02:15:54.000000000 -0400
+++ vnc_javasrc/VncCanvas.java	2010-11-30 21:01:15.000000000 -0500
@@ -28,13 +28,14 @@
 import java.lang.*;
 import java.util.zip.*;
 
+import java.util.Collections;
 
 //
 // VncCanvas is a subclass of Canvas which draws a VNC desktop on it.
 //
 
 class VncCanvas extends Canvas
-  implements KeyListener, MouseListener, MouseMotionListener {
+  implements KeyListener, MouseListener, MouseMotionListener, MouseWheelListener {
 
   VncViewer viewer;
   RfbProto rfb;
@@ -81,6 +82,20 @@
     cm8 = new DirectColorModel(8, 7, (7 << 3), (3 << 6));
     cm24 = new DirectColorModel(24, 0xFF0000, 0x00FF00, 0x0000FF);
 
+    // kludge to not show any Java cursor in the canvas since we are
+    // showing the soft cursor (should be a user setting...)
+    Cursor dot = Toolkit.getDefaultToolkit().createCustomCursor(
+        Toolkit.getDefaultToolkit().createImage(new byte[4]), new Point(0,0),
+        "dot");
+    this.setCursor(dot);
+
+    // while we are at it... get rid of the keyboard traversals that
+    // make it so we can't type a Tab character:
+    this.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
+        Collections.EMPTY_SET);
+    this.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
+        Collections.EMPTY_SET);
+
     colors = new Color[256];
     for (int i = 0; i < 256; i++)
       colors[i] = new Color(cm8.getRGB(i));
@@ -169,6 +184,7 @@
       inputEnabled = true;
       addMouseListener(this);
       addMouseMotionListener(this);
+      addMouseWheelListener(this);
       if (viewer.showControls) {
 	viewer.buttonPanel.enableRemoteAccessControls(true);
       }
@@ -177,6 +193,7 @@
       inputEnabled = false;
       removeMouseListener(this);
       removeMouseMotionListener(this);
+      removeMouseWheelListener(this);
       if (viewer.showControls) {
 	viewer.buttonPanel.enableRemoteAccessControls(false);
       }
@@ -1190,6 +1207,9 @@
   public void mouseDragged(MouseEvent evt) {
     processLocalMouseEvent(evt, true);
   }
+  public void mouseWheelMoved(MouseWheelEvent evt) {
+    processLocalMouseWheelEvent(evt);
+  }
 
   public void processLocalKeyEvent(KeyEvent evt) {
     if (viewer.rfb != null && rfb.inNormalProtocol) {
@@ -1221,6 +1241,19 @@
     evt.consume();
   }
 
+  public void processLocalMouseWheelEvent(MouseWheelEvent evt) {
+    if (viewer.rfb != null && rfb.inNormalProtocol) {
+      synchronized(rfb) {
+	try {
+	  rfb.writeWheelEvent(evt);
+	} catch (Exception e) {
+	  e.printStackTrace();
+	}
+	rfb.notify();
+      }
+    }
+  }
+
   public void processLocalMouseEvent(MouseEvent evt, boolean moved) {
     if (viewer.rfb != null && rfb.inNormalProtocol) {
       if (moved) {
@@ -1387,9 +1420,9 @@
 		result = cm8.getRGB(pixBuf[i]);
 	      } else {
 		result = 0xFF000000 |
-		  (pixBuf[i * 4 + 1] & 0xFF) << 16 |
-		  (pixBuf[i * 4 + 2] & 0xFF) << 8 |
-		  (pixBuf[i * 4 + 3] & 0xFF);
+		  (pixBuf[i * 4 + 2] & 0xFF) << 16 |
+		  (pixBuf[i * 4 + 1] & 0xFF) << 8 |
+		  (pixBuf[i * 4 + 0] & 0xFF);
 	      }
 	    } else {
 	      result = 0;	// Transparent pixel
@@ -1403,9 +1436,9 @@
 	      result = cm8.getRGB(pixBuf[i]);
 	    } else {
 	      result = 0xFF000000 |
-		(pixBuf[i * 4 + 1] & 0xFF) << 16 |
-		(pixBuf[i * 4 + 2] & 0xFF) << 8 |
-		(pixBuf[i * 4 + 3] & 0xFF);
+		(pixBuf[i * 4 + 2] & 0xFF) << 16 |
+		(pixBuf[i * 4 + 1] & 0xFF) << 8 |
+		(pixBuf[i * 4 + 0] & 0xFF);
 	    }
 	  } else {
 	    result = 0;		// Transparent pixel
