aboutsummaryrefslogtreecommitdiffstats
path: root/java/com/tigervnc/rfb
diff options
context:
space:
mode:
authorBrian P. Hinz <bphinz@users.sf.net>2017-02-27 16:38:30 -0500
committerBrian P. Hinz <bphinz@users.sf.net>2017-02-27 20:16:46 -0500
commit038dc6e2313e03775f214b7bffb247ada0d226fa (patch)
treee0f0904f816fa1ff6ceedcff484e01f585de0896 /java/com/tigervnc/rfb
parent684256630533309537fc9d15e0d3cd0c078f3578 (diff)
downloadtigervnc-038dc6e2313e03775f214b7bffb247ada0d226fa.tar.gz
tigervnc-038dc6e2313e03775f214b7bffb247ada0d226fa.zip
Java client support for X Cursor
Diffstat (limited to 'java/com/tigervnc/rfb')
-rw-r--r--java/com/tigervnc/rfb/CMsgReader.java59
-rw-r--r--java/com/tigervnc/rfb/CMsgWriter.java1
2 files changed, 60 insertions, 0 deletions
diff --git a/java/com/tigervnc/rfb/CMsgReader.java b/java/com/tigervnc/rfb/CMsgReader.java
index 12862c14..a5cc267f 100644
--- a/java/com/tigervnc/rfb/CMsgReader.java
+++ b/java/com/tigervnc/rfb/CMsgReader.java
@@ -95,6 +95,9 @@ public class CMsgReader {
case Encodings.pseudoEncodingLastRect:
nUpdateRectsLeft = 1; // this rectangle is the last one
break;
+ case Encodings.pseudoEncodingXCursor:
+ readSetXCursor(w, h, new Point(x,y));
+ break;
case Encodings.pseudoEncodingCursor:
readSetCursor(w, h, new Point(x,y));
break;
@@ -206,6 +209,62 @@ public class CMsgReader {
handler.dataRect(r, encoding);
}
+ protected void readSetXCursor(int width, int height, Point hotspot)
+ {
+ byte pr, pg, pb;
+ byte sr, sg, sb;
+ int data_len = ((width+7)/8) * height;
+ int mask_len = ((width+7)/8) * height;
+ ByteBuffer data = ByteBuffer.allocate(data_len);
+ ByteBuffer mask = ByteBuffer.allocate(mask_len);
+
+ int x, y;
+ byte[] buf = new byte[width*height*4];
+ ByteBuffer out;
+
+ if (width * height == 0)
+ return;
+
+ pr = (byte)is.readU8();
+ pg = (byte)is.readU8();
+ pb = (byte)is.readU8();
+
+ sr = (byte)is.readU8();
+ sg = (byte)is.readU8();
+ sb = (byte)is.readU8();
+
+ is.readBytes(data, data_len);
+ is.readBytes(mask, mask_len);
+
+ int maskBytesPerRow = (width+7)/8;
+ out = ByteBuffer.wrap(buf);
+ for (y = 0;y < height;y++) {
+ for (x = 0;x < width;x++) {
+ int byte_ = y * maskBytesPerRow + x / 8;
+ int bit = 7 - x % 8;
+
+ if ((data.get(byte_) & (1 << bit)) > 0) {
+ out.put(out.position() + 1, pr);
+ out.put(out.position() + 2, pg);
+ out.put(out.position() + 3, pb);
+ } else {
+ out.put(out.position() + 1, sr);
+ out.put(out.position() + 2, sg);
+ out.put(out.position() + 3, sb);
+ }
+
+ if ((mask.get(byte_) & (1 << bit)) > 0)
+ out.put(out.position() + 0, (byte)255);
+ else
+ out.put(out.position() + 0, (byte)0);
+
+ out.position(out.position() + 4);
+ }
+ }
+
+ handler.setCursor(width, height, hotspot, buf);
+ }
+
protected void readSetCursor(int width, int height, Point hotspot)
{
int data_len = width * height * (handler.cp.pf().bpp/8);
diff --git a/java/com/tigervnc/rfb/CMsgWriter.java b/java/com/tigervnc/rfb/CMsgWriter.java
index 701f2d3d..7838da34 100644
--- a/java/com/tigervnc/rfb/CMsgWriter.java
+++ b/java/com/tigervnc/rfb/CMsgWriter.java
@@ -65,6 +65,7 @@ public class CMsgWriter {
int[] encodings = new int[Encodings.encodingMax+3];
if (cp.supportsLocalCursor) {
+ encodings[nEncodings++] = Encodings.pseudoEncodingXCursor;
encodings[nEncodings++] = Encodings.pseudoEncodingCursor;
encodings[nEncodings++] = Encodings.pseudoEncodingCursorWithAlpha;
}