aboutsummaryrefslogtreecommitdiffstats
path: root/vnc.c
diff options
context:
space:
mode:
Diffstat (limited to 'vnc.c')
-rw-r--r--vnc.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/vnc.c b/vnc.c
index 7fccf78..b4a1517 100644
--- a/vnc.c
+++ b/vnc.c
@@ -16,6 +16,8 @@
#ifdef HAVE_VNC
+static int debug = 0;
+
/* ------------------------------------------------------------------ */
/* data tables */
@@ -139,10 +141,9 @@ static void vnc_blit(char *reason, struct vnc_window *vnc, int x, int y, int w,
Window win = gdk_x11_drawable_get_xid(vnc->draw->window);
XGCValues values;
-#if 0
- fprintf(stderr, "%s [%s]: %dx%d+%d+%d\n",
- __FUNCTION__, reason, w, h, x, y);
-#endif
+ if (debug)
+ fprintf(stderr, "%s [%s]: %dx%d+%d+%d\n",
+ __FUNCTION__, reason, w, h, x, y);
if (x > vnc->ximage->width)
return;
if (y > vnc->ximage->height)
@@ -176,8 +177,9 @@ static rfbBool vnc_resize(rfbClient* client)
{
struct vnc_window *vnc = rfbClientGetClientData(client, vnc_open);
- fprintf(stderr, "%s: %dx%d\n",
- __FUNCTION__, client->width, client->height);
+ if (debug)
+ fprintf(stderr, "%s: %dx%d\n",
+ __FUNCTION__, client->width, client->height);
if (vnc->ximage) {
x11_destroy_ximage(vnc->dpy, vnc->ximage, vnc->shm);
@@ -242,6 +244,8 @@ static gboolean vnc_data_cb(GIOChannel *source, GIOCondition condition,
{
struct vnc_window *vnc = data;
+ if (debug)
+ fprintf(stderr,"%s: called\n", __FUNCTION__);
if (!HandleRFBServerMessage(vnc->client)) {
/* server closed connection */
g_source_destroy(g_main_context_find_source_by_id
@@ -256,6 +260,8 @@ static void destroy_cb(GtkWidget *widget, gpointer data)
{
struct vnc_window *vnc = data;
+ if (debug)
+ fprintf(stderr,"%s: called\n", __FUNCTION__);
if (vnc->standalone)
gtk_main_quit();
vnc_release(vnc);
@@ -277,6 +283,8 @@ static gboolean button_cb(GtkWidget *widget, GdkEventButton *event,
{
struct vnc_window *vnc = data;
+ if (debug)
+ fprintf(stderr,"%s: called\n", __FUNCTION__);
SendPointerEvent(vnc->client, event->x, event->y, event->state);
return TRUE;
}
@@ -288,6 +296,9 @@ static gboolean key_cb(GtkWidget *widget, GdkEventKey *event,
rfbKeySym keysym = 0;
int keydown;
+ if (debug)
+ fprintf(stderr,"%s[%d]: called: sym %d, code %d\n", __FUNCTION__,
+ event->type, event->keyval, event->hardware_keycode);
keydown = (8 == event->type);
if (vnc->keysyms)
keysym = event->keyval;
@@ -324,12 +335,16 @@ struct vnc_window* vnc_open(char *hostname, int displayno,
/* x11 */
vnc->dpy = gdk_x11_display_get_xdisplay(gdk_display_get_default());
if (NULL == x11_info)
- x11_color_init(vnc->dpy);
+ if (0 != x11_color_init(vnc->dpy))
+ goto err;
/* rfb client */
snprintf(display, sizeof(display), "%s:%d", hostname, displayno);
fprintf(stderr, "%s: connecting to %s:%d\n", __FUNCTION__, hostname, displayno);
- vnc->client = rfbGetClient(8,3,3);
+ if (8 == x11_red_bits)
+ vnc->client = rfbGetClient(8,3,4);
+ else
+ vnc->client = rfbGetClient(5,3,2);
if (NULL == vnc->client)
goto err;
rfbClientSetClientData(vnc->client, vnc_open, vnc);