[Bugfix] Selection grew incorrectly when it passed left or upper boundary of the framebuffer.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2747 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/java/src/com/tightvnc/vncviewer/VncCanvas.java b/java/src/com/tightvnc/vncviewer/VncCanvas.java
index 5422137..17bb6c8 100644
--- a/java/src/com/tightvnc/vncviewer/VncCanvas.java
+++ b/java/src/com/tightvnc/vncviewer/VncCanvas.java
@@ -2016,10 +2016,18 @@
       h = (h * 100 + scalingFactor/2) / scalingFactor;
     }
     // Clip the selection to framebuffer.
-    if (x < 0)
+    if (x < 0) {
+      if (horizSwap) {
+        w += x;
+      }
       x = 0;
-    if (y < 0)
+    }
+    if (y < 0) {
+      if (vertSwap) {
+        h += y;
+      }
       y = 0;
+    }
     if (x + w > rfb.framebufferWidth)
       w = rfb.framebufferWidth - x;
     if (y + h > rfb.framebufferHeight)