summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorConstantin Kaplinsky <const@tightvnc.com>2008-09-03 03:12:18 +0000
committerConstantin Kaplinsky <const@tightvnc.com>2008-09-03 03:12:18 +0000
commit10da44dee7982dd14b1ccecd9af6f100123cd272 (patch)
tree6e4381da938918208946ef6b18eb3060f3f3b64c /java
parent6b5b878913fd50e85aac2b64585e9c9206b63117 (diff)
downloadtigervnc-10da44dee7982dd14b1ccecd9af6f100123cd272.tar.gz
tigervnc-10da44dee7982dd14b1ccecd9af6f100123cd272.zip
[Bugfix] Make sure the video selection is always a multiple of 16x8 pixels. Previously, the selection could cross the framebuffer boundaries and clipping it back to screen could break 16x8 alignment.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2746 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'java')
-rw-r--r--java/src/com/tightvnc/vncviewer/VncCanvas.java21
1 files changed, 12 insertions, 9 deletions
diff --git a/java/src/com/tightvnc/vncviewer/VncCanvas.java b/java/src/com/tightvnc/vncviewer/VncCanvas.java
index 332efa38..5422137b 100644
--- a/java/src/com/tightvnc/vncviewer/VncCanvas.java
+++ b/java/src/com/tightvnc/vncviewer/VncCanvas.java
@@ -2015,9 +2015,18 @@ class VncCanvas extends Canvas
w = (w * 100 + scalingFactor/2) / scalingFactor;
h = (h * 100 + scalingFactor/2) / scalingFactor;
}
+ // Clip the selection to framebuffer.
+ if (x < 0)
+ x = 0;
+ if (y < 0)
+ y = 0;
+ if (x + w > rfb.framebufferWidth)
+ w = rfb.framebufferWidth - x;
+ if (y + h > rfb.framebufferHeight)
+ h = rfb.framebufferHeight - y;
// Make width a multiple of 16.
int widthCorrection = w % 16;
- if (widthCorrection >= 8) {
+ if (widthCorrection >= 8 && x + (w / 16 + 1) * 16 <= rfb.framebufferWidth) {
widthCorrection -= 16;
}
w -= widthCorrection;
@@ -2026,7 +2035,7 @@ class VncCanvas extends Canvas
}
// Make height a multiple of 8.
int heightCorrection = h % 8;
- if (heightCorrection >= 4) {
+ if (heightCorrection >= 4 && y + (h / 8 + 1) * 8 <= rfb.framebufferHeight) {
heightCorrection -= 8;
}
h -= heightCorrection;
@@ -2034,20 +2043,14 @@ class VncCanvas extends Canvas
y += heightCorrection;
}
// Translate the selection back to screen coordinates if requested.
- int clipWidth = rfb.framebufferWidth;
- int clipHeight = rfb.framebufferHeight;
if (useScreenCoords && rfb.framebufferWidth != scaledWidth) {
x = (x * scalingFactor + 50) / 100;
y = (y * scalingFactor + 50) / 100;
w = (w * scalingFactor + 50) / 100;
h = (h * scalingFactor + 50) / 100;
- clipWidth = scaledWidth;
- clipHeight = scaledHeight;
}
// Clip the selection to screen/framebuffer and return the result.
- Rectangle selection = new Rectangle(x, y, w, h);
- Rectangle clip = new Rectangle(0, 0, clipWidth, clipHeight);
- return selection.intersection(clip);
+ return new Rectangle(x, y, w, h);
}
/**