]> git.webhop.me Git - lcd4linux.git/commitdiff
more vnc driver stuff...
authormichux <michux@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Wed, 25 Mar 2009 22:56:29 +0000 (22:56 +0000)
committermichux <michux@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Wed, 25 Mar 2009 22:56:29 +0000 (22:56 +0000)
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@998 3ae390bd-cb1e-0410-b409-cd5a39f66f1f

configure
drivers.m4
drv_vnc.c

index 406156bce7329a44ec58c88d80e9990d71b7c625..7aaeebb30ab78290317a434d1623caab42dde449 100755 (executable)
--- a/configure
+++ b/configure
@@ -8607,7 +8607,7 @@ if test "$VNC" = "yes"; then
    if test "$has_vncserverlib" = "true"; then
       GRAPHIC="yes"
       DRIVERS="$DRIVERS drv_vnc.o"
-      DRVLIBS="$DRVLIBS -L/usr/local/lib -lvncserver -lnsl -lpthread -lz /usr/lib/libjpeg.la"
+      DRVLIBS="$DRVLIBS -L/usr/local/lib -lvncserver -lnsl -lz -ljpeg"
 
 cat >>confdefs.h <<\_ACEOF
 #define WITH_VNC 1
index 876631f7c9bdd2bac3a245391629b9f7ac73ebf1..576609390ed685ad8a5de95c1945117a75e606e4 100644 (file)
@@ -649,7 +649,7 @@ if test "$VNC" = "yes"; then
    if test "$has_vncserverlib" = "true"; then
       GRAPHIC="yes"
       DRIVERS="$DRIVERS drv_vnc.o"
-      DRVLIBS="$DRVLIBS -L/usr/local/lib -lvncserver -lnsl -lpthread -lz /usr/lib/libjpeg.la"
+      DRVLIBS="$DRVLIBS -L/usr/local/lib -lvncserver -lnsl -lz -ljpeg"
       AC_DEFINE(WITH_VNC,1,[vnc driver])
    else
       AC_MSG_WARN(libvncserver not found: vnc driver disabled)
index a8bbbc816c2e99f99f9e71cec344056941b042ba..1ed4019b5a98df0d177aada23b660d83a9270127 100644 (file)
--- a/drv_vnc.c
+++ b/drv_vnc.c
@@ -42,7 +42,7 @@
 #include <string.h>
 #include <errno.h>
 
-#include <rfb/rfb.h> 
+#include <rfb/rfb.h>
 
 #include "debug.h"
 #include "cfg.h"
 
 #include "drv_generic_graphic.h"
 
-
+//todo: fps limiter
+//      key widget
 
 /* 15 frames per second (if we can) */
-#define PICTURE_TIMEOUT (1.0/15.0) 
+#define PICTURE_TIMEOUT (1.0/15.0)
 
 static char Name[] = "VNC";
 
@@ -69,17 +70,49 @@ static int xres = 320;
 static int yres = 200;
 static int BPP = 4;
 
+static int clientCount = 0;
+static int oldClientCount = 0;
+
+static void clientgone(rfbClientPtr cl)
+{
+    if (clientCount > 0)
+       clientCount--;
+    debug("%d clients connected\n", clientCount);
+}
+
+static enum rfbNewClientAction newclient(rfbClientPtr cl)
+{
+    cl->clientGoneHook = clientgone;
+    clientCount++;
+    debug("%d clients connected\n", clientCount);
+    return RFB_CLIENT_ACCEPT;
+}
+
+static void doptr(int buttonMask, int x, int y, rfbClientPtr cl)
+{
+    //printf("doptr\n");
+//    ClientData* cd=cl->clientData;
+
+    if (x >= 0 && y >= 0 && x < xres && y < yres) {
+       if (buttonMask) {
+           printf("btn:%d, x:%d, y:%d\n", buttonMask, x, y);
+       }
+    }
+
+    rfbDefaultPtrAddEvent(buttonMask, x, y, cl);
+}
+
 
 static int drv_vnc_open(const char *Section)
 {
     if (cfg_number(Section, "xres", 320, 32, 2048, &xres) < 1) {
-        info("[DRV_VNC] no '%s.xres' entry from %s using default %d", Section, cfg_source(), xres);
-    }                    
+       info("[DRV_VNC] no '%s.xres' entry from %s using default %d", Section, cfg_source(), xres);
+    }
     if (cfg_number(Section, "yres", 200, 32, 2048, &yres) < 1) {
-        info("[DRV_VNC] no '%s.yres' entry from %s using default %d", Section, cfg_source(), yres);
+       info("[DRV_VNC] no '%s.yres' entry from %s using default %d", Section, cfg_source(), yres);
     }
     if (cfg_number(Section, "bpp", 4, 1, 4, &BPP) < 1) {
-        info("[DRV_VNC] no '%s.bpp' entry from %s using default %d", Section, cfg_source(), BPP);
+       info("[DRV_VNC] no '%s.bpp' entry from %s using default %d", Section, cfg_source(), BPP);
     }
     return 0;
 }
@@ -92,11 +125,11 @@ static int drv_vnc_close(void)
     return 0;
 }
 
-static void drv_vnc_blit_it(const int row, const int col, const int height, const int width, unsigned charbuffer)
+static void drv_vnc_blit_it(const int row, const int col, const int height, const int width, unsigned char *buffer)
 {
     int r, c, ofs;
     RGBA p;
-    
+
     for (r = row; r < row + height; r++) {
        for (c = col; c < col + width; c++) {
            p = drv_generic_graphic_rgb(r, c);
@@ -104,7 +137,7 @@ static void drv_vnc_blit_it(const int row, const int col, const int height, cons
            buffer[ofs++] = p.R;
            buffer[ofs++] = p.G;
            buffer[ofs++] = p.B;
-           buffer[ofs  ] = 255;
+           buffer[ofs] = 255;
        }
     }
 }
@@ -112,32 +145,17 @@ static void drv_vnc_blit_it(const int row, const int col, const int height, cons
 static void drv_vnc_blit(const int row, const int col, const int height, const int width)
 {
     if (rfbIsActive(server)) {
-    //todo blit only if client are connected...
-       drv_vnc_blit_it(row, col, height, width, (unsigned char *)server->frameBuffer);
-        rfbMarkRectAsModified(server, 0, 0, xres, yres);
-        rfbProcessEvents(server, server->deferUpdateTime*1000);
+       //todo blit only if client are connected...
+
+//      if (clientCount > 0) {
+       drv_vnc_blit_it(row, col, height, width, (unsigned char *) server->frameBuffer);
+       rfbMarkRectAsModified(server, 0, 0, xres, yres);
+//      }
+       oldClientCount = clientCount;
+       rfbProcessEvents(server, server->deferUpdateTime * 1000);
     }
 }
 
-static void doptr(int buttonMask,int x,int y,rfbClientPtr cl)
-{
-    //printf("doptr\n");
-//    ClientData* cd=cl->clientData;
-    
-    if(x>=0 && y>=0 && x<xres && y<yres) {
-       if(buttonMask) {
-               printf("btn:%d, x:%d, y:%d\n", buttonMask, x, y);
-       }
-    }    
-    
-    rfbDefaultPtrAddEvent(buttonMask,x,y,cl);
-}
-
-static void dokey(rfbBool down,rfbKeySym key,rfbClientPtr cl)
-{
-    printf("dokey\n");
-}
-
 /* start graphic display */
 static int drv_vnc_start(const char *section)
 {
@@ -168,16 +186,17 @@ static int drv_vnc_start(const char *section)
     }
 
     /* you surely want to allocate a framebuffer or something... */
-    server=rfbGetScreen(0, NULL, xres, yres, 8, 3, BPP);
+    server = rfbGetScreen(0, NULL, xres, yres, 8, 3, BPP);
     server->desktopName = "LCD4Linux VNC Driver";
-    server->frameBuffer=(char*)malloc(xres*yres*BPP);
-    server->alwaysShared=(1==1);
+    server->frameBuffer = (char *) malloc(xres * yres * BPP);
+    server->alwaysShared = (1 == 1);
     server->ptrAddEvent = doptr;
 //    server->kbdAddEvent = dokey;
-    
+    server->newClientHook = newclient;
+
     /* Initialize the server */
     rfbInitServer(server);
-                
+
     /* set width/height */
     DROWS = yres;
     DCOLS = xres;