aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkraxel <kraxel>2007-05-23 09:19:33 +0000
committerkraxel <kraxel>2007-05-23 09:19:33 +0000
commit97198ecff9fe2b9919073aee0dfaa2f12603070f (patch)
tree3ab686d54c69e4beec7dac24d1e2b3438df0054b
parentd4f83cad7b67bd8d98e1e94d23fa3607e777e5ab (diff)
downloadxenwatch-97198ecff9fe2b9919073aee0dfaa2f12603070f.tar.gz
misc
-rw-r--r--vnc-client.c9
-rw-r--r--vnc.c107
-rw-r--r--vnc.h3
3 files changed, 83 insertions, 36 deletions
diff --git a/vnc-client.c b/vnc-client.c
index 4f0fdac..2883a0e 100644
--- a/vnc-client.c
+++ b/vnc-client.c
@@ -26,7 +26,7 @@ static void usage(FILE *fp)
" -d Enable debug output.\n"
" -u Send us kbd layout keysyms.\n"
" -p Show mouse pointer.\n"
- " -g Disable OpewnGL.\n"
+ " -g Enable OpenGL.\n"
" -o View only.\n"
"\n"
"-- \n"
@@ -44,7 +44,7 @@ main(int argc, char *argv[])
gtk_init(&argc, &argv);
for (;;) {
- if (-1 == (c = getopt(argc, argv, "hdupgo")))
+ if (-1 == (c = getopt(argc, argv, "hdupgGo")))
break;
switch (c) {
case 'd':
@@ -60,7 +60,10 @@ main(int argc, char *argv[])
vnc_flags |= VNC_FLAG_VIEW_ONLY;
break;
case 'g':
- vnc_flags |= VNC_FLAG_NOGL;
+ vnc_flags |= VNC_FLAG_GL_FULLSCR;
+ break;
+ case 'G':
+ vnc_flags |= VNC_FLAG_GL_ALLWAYS;
break;
case 'h':
usage(stdout);
diff --git a/vnc.c b/vnc.c
index 7f9c957..4b09b06 100644
--- a/vnc.c
+++ b/vnc.c
@@ -28,6 +28,11 @@ static int debug_libvnc;
/* ------------------------------------------------------------------ */
+struct pos {
+ int x;
+ int y;
+};
+
struct rect {
int w;
int h;
@@ -55,12 +60,6 @@ struct vnc_window {
Display *dpy;
unsigned char keydown[32];
- /* window / vnc display config */
- struct rect window;
- struct rect vncdpy;
- struct rect texture;
- int updates, redraw;
-
/* opengl */
int have_gl;
GLuint tex;
@@ -68,11 +67,20 @@ struct vnc_window {
unsigned char *tex_data;
unsigned int dirty_y1, dirty_y2;
+ /* window / vnc display config */
+ struct rect window;
+ struct pos vncoff;
+ struct rect vncdpy;
+ struct rect texture;
+ int updates, redraw;
+
/* config */
int fullscreen;
int viewonly;
int standalone;
int showpointer;
+ int gl_allways;
+ int gl_fullscreen;
int uskbd;
int debug;
};
@@ -247,8 +255,8 @@ static void gl_flush(struct vnc_window *vnc)
/* ------------------------------------------------------------------ */
/* x11 draw bits */
-static void x11_update(struct vnc_window *vnc,
- int x, int y, int w, int h)
+static void x11_update_win(struct vnc_window *vnc,
+ int x, int y, int w, int h)
{
Window win = gdk_x11_drawable_get_xid(vnc->draw->window);
@@ -265,26 +273,46 @@ static void x11_update(struct vnc_window *vnc,
GCForeground|GCFunction,
&values);
}
- if (vnc->redraw)
+
+ if (x < vnc->vncoff.x)
+ vnc->redraw++;
+ if (y < vnc->vncoff.y)
+ vnc->redraw++;
+ if (x+w > vnc->vncoff.x + vnc->vncdpy.w)
+ vnc->redraw++;
+ if (y+h > vnc->vncoff.y + vnc->vncdpy.h)
+ vnc->redraw++;
+
+ if (vnc->redraw) {
XFillRectangle(vnc->dpy, win, vnc->gc,
0,0, vnc->window.w, vnc->window.h);
-
- if (x > vnc->ximage->width)
- return;
- if (y > vnc->ximage->height)
- return;
- if (x+w > vnc->ximage->width)
- w = vnc->ximage->width - x;
- if (y+h > vnc->ximage->height)
- h = vnc->ximage->height - y;
-
- XPUTIMAGE(vnc->dpy, win, vnc->gc, vnc->ximage, x,y, x,y, w,h);
+ XPUTIMAGE(vnc->dpy, win, vnc->gc, vnc->ximage, 0,0,
+ vnc->vncoff.x, vnc->vncoff.y,
+ vnc->vncdpy.w, vnc->vncdpy.h);
+ vnc->redraw = 0;
+ } else {
+ XPUTIMAGE(vnc->dpy, win, vnc->gc, vnc->ximage,
+ x-vnc->vncoff.x, y-vnc->vncoff.y,
+ x,y, w,h);
+ }
+}
+
+static void x11_update_vnc(struct vnc_window *vnc,
+ int x, int y, int w, int h)
+{
+ x11_update_win(vnc, x + vnc->vncoff.x, y + vnc->vncoff.y, w, h);
+}
+
+static void x11_resize_window(struct vnc_window *vnc)
+{
+ vnc->vncoff.x = (vnc->window.w - vnc->vncdpy.w) / 2;
+ vnc->vncoff.y = (vnc->window.h - vnc->vncdpy.h) / 2;
}
static void x11_flush(struct vnc_window *vnc)
{
if (vnc->redraw)
- x11_update(vnc, 0, 0, vnc->vncdpy.w, vnc->vncdpy.w);
+ x11_update_win(vnc, 0, 0, vnc->vncdpy.w, vnc->vncdpy.w);
vnc->updates = 0;
vnc->redraw = 0;
}
@@ -302,7 +330,7 @@ static void dpy_update_vnc(struct vnc_window *vnc,
vnc->ximage ? " X11" : "",
w, h, x, y);
if (vnc->ximage)
- x11_update(vnc, x, y, w, h);
+ x11_update_vnc(vnc, x, y, w, h);
if (vnc->tex)
gl_update_vnc(vnc, x, y, w, h);
}
@@ -317,7 +345,7 @@ static void dpy_update_win(struct vnc_window *vnc,
vnc->ximage ? " X11" : "",
w, h, x, y);
if (vnc->ximage)
- x11_update(vnc, x, y, w, h);
+ x11_update_win(vnc, x, y, w, h);
if (vnc->tex)
gl_update_win(vnc, x, y, w, h);
}
@@ -346,6 +374,10 @@ static void dpy_flush(struct vnc_window *vnc, const char *caller)
static void dpy_resize_window(struct vnc_window *vnc)
{
+ vnc->vncoff.x = 0;
+ vnc->vncoff.y = 0;
+ if (vnc->ximage)
+ x11_resize_window(vnc);
if (vnc->tex)
gl_resize_window(vnc);
dpy_redraw(vnc);;
@@ -527,8 +559,12 @@ static rfbBool vnc_resize(rfbClient* client)
vnc->vncdpy.h = client->height;
/* opengl check */
- if (vnc->have_gl && vnc->vncdpy.w < vnc->tex_max && vnc->vncdpy.h < vnc->tex_max)
- using_gl = 1;
+ if (vnc->have_gl && vnc->vncdpy.w < vnc->tex_max && vnc->vncdpy.h < vnc->tex_max) {
+ if (vnc->gl_allways)
+ using_gl = 1;
+ if (vnc->gl_fullscreen && vnc->fullscreen)
+ using_gl = 1;
+ }
if (!using_gl) {
/* init X11 */
@@ -754,6 +790,9 @@ static gboolean window_state_cb(GtkWidget *widget, GdkEventWindowState *event,
if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) {
vnc->fullscreen = event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN;
+ if (vnc->debug)
+ fprintf(stderr, "%s: fullscreen %s\n", __FUNCTION__,
+ vnc->fullscreen ? "on" : "off");
vnc_window_texts(vnc);
}
return TRUE;
@@ -803,6 +842,8 @@ static void send_mouse(struct vnc_window *vnc, int x, int y,
rfbstate &= ~buttons[i].rfbmask;
}
+ /* FIXME: fixup mouse coordinates */
+
if (vnc->debug)
fprintf(stderr,"%s: +%d+%d x11state 0x%x rfbstate 0x%x\n",
__FUNCTION__, x, y, x11state, rfbstate);
@@ -987,12 +1028,14 @@ GtkWidget *vnc_open(char *hostname, int tcpport, unsigned long flags,
if (NULL == vnc)
goto err;
memset(vnc,0,sizeof(*vnc));
- vnc->standalone = (flags & VNC_FLAG_STANDALONE);
- vnc->showpointer = (flags & VNC_FLAG_SHOW_MOUSE);
- vnc->uskbd = (flags & VNC_FLAG_US_KBD);
- vnc->viewonly = (flags & VNC_FLAG_VIEW_ONLY);
- vnc->debug = debug_level;
- debug_libvnc = debug_level;
+ vnc->standalone = (flags & VNC_FLAG_STANDALONE);
+ vnc->showpointer = (flags & VNC_FLAG_SHOW_MOUSE);
+ vnc->uskbd = (flags & VNC_FLAG_US_KBD);
+ vnc->viewonly = (flags & VNC_FLAG_VIEW_ONLY);
+ vnc->gl_allways = (flags & VNC_FLAG_GL_ALLWAYS);
+ vnc->gl_fullscreen = (flags & VNC_FLAG_GL_FULLSCR);
+ vnc->debug = debug_level;
+ debug_libvnc = debug_level;
snprintf(vnc->display, sizeof(vnc->display),
"%s:%d", hostname, tcpport - 5900);
@@ -1091,7 +1134,7 @@ GtkWidget *vnc_open(char *hostname, int tcpport, unsigned long flags,
vnc_window_conf(vnc);
/* opengl */
- if (!(flags & VNC_FLAG_NOGL) && 0 == gl_init(vnc))
+ if ((vnc->gl_allways || vnc->gl_fullscreen) && 0 == gl_init(vnc))
vnc->have_gl = 1;
/* rfb client */
diff --git a/vnc.h b/vnc.h
index 839cdf2..0c5c34c 100644
--- a/vnc.h
+++ b/vnc.h
@@ -2,7 +2,8 @@
#define VNC_FLAG_US_KBD (1 << 2)
#define VNC_FLAG_SHOW_MOUSE (1 << 3)
#define VNC_FLAG_VIEW_ONLY (1 << 4)
-#define VNC_FLAG_NOGL (1 << 5)
+#define VNC_FLAG_GL_ALLWAYS (1 << 5)
+#define VNC_FLAG_GL_FULLSCR (1 << 6)
GtkWidget *vnc_open(char *hostname, int tcpport, unsigned long flags,
int debug_level);