]> git.sesse.net Git - rdpsrv/blobdiff - rdpsrv.c
Valgrind fixes, re-request updates all the time.
[rdpsrv] / rdpsrv.c
index 1718dc1e30f169cfa52f4919bd6b6199dafbbab7..c838fc7a60c711d7f7ec8434a9b9755ad8040feb 100644 (file)
--- a/rdpsrv.c
+++ b/rdpsrv.c
@@ -113,6 +113,20 @@ void handle_input_pdu(STREAM s, int vnc_sock)
                }
                printf("\n");
        }
+       
+       // re-request the entire framebuffer
+       buf[0] = 3; // message type
+       buf[1] = 1; // incremental
+       buf[2] = 0; // xpos
+       buf[3] = 0;
+       buf[4] = 0; // ypos
+       buf[5] = 0;
+       buf[6] = 640 >> 8; // width
+       buf[7] = 640 & 0xff;
+       buf[8] = 480 >> 8; // height
+       buf[9] = 480 & 0xff;
+
+       write(vnc_sock, buf, 10);
 }
 
 struct ServerInitialization {
@@ -153,7 +167,7 @@ int vnc_init()
        if (read(vnc_sock, buf, ntohl(si.name_len)) != ntohl(si.name_len))
                error("short read on server name\n");
 
-       printf("Server name is '%*s' (%u bytes)\n", ntohl(si.name_len), buf, ntohl(si.name_len));
+//     printf("Server name is '%*s' (%u bytes)\n", ntohl(si.name_len), buf, ntohl(si.name_len));
 
        // we can only accept raw encoding
        buf[0] = 2; // message type
@@ -244,7 +258,7 @@ void handle_vnc_fbupdate(int vnc_sock)
                        
                                dst = smallblock;
                                for (y = 0; y < bh; ++y) {
-                                       src = data + ((yt * 64 + (bh + 1 - y)) * width + (xt * 64)) * 4;
+                                       src = data + ((yt * 64 + (bh - 1 - y)) * width + (xt * 64)) * 4;
                                        for (x = 0; x < bw; ++x) {
                                                *dst++ = *src++;
                                                *dst++ = *src++;
@@ -310,14 +324,20 @@ int serve_client()
 
                        printf("Activity on VNC socket!\n");
                        
-                       if (read(vnc_sock, buf, 2) != 2)
+                       if (read(vnc_sock, buf, 1) != 1)
                                error("short read on vnc_sock\n");
 
                        switch (buf[0]) {
                        case 0:
                                // frame buffer update!
+                               printf("Framebuffer update\n");
+                               if (read(vnc_sock, buf, 1) != 1)
+                                       error("short read on vnc_sock\n");
                                handle_vnc_fbupdate(vnc_sock);
                                break;
+                       case 2:
+                               printf("\a\n");
+                               break;
                        default:
                                printf("Unknown VNC server message %x\n", buf[0]);
                                exit(1);