diff options
author | kraxel <kraxel> | 2006-10-25 15:07:04 +0000 |
---|---|---|
committer | kraxel <kraxel> | 2006-10-25 15:07:04 +0000 |
commit | 6caa675a9500d283d31dfb7a5eb87f4950731592 (patch) | |
tree | 9201dd2a0a5a0c28954c212b18aa6c8b2f7c6cc6 | |
parent | e4309b4efef95f8f7a617c529642c29ccbf46690 (diff) | |
download | xenwatch-6caa675a9500d283d31dfb7a5eb87f4950731592.tar.gz |
make kbd handling configurable
-rw-r--r-- | vnc-client.c | 17 | ||||
-rw-r--r-- | vnc.c | 9 | ||||
-rw-r--r-- | vnc.h | 6 | ||||
-rw-r--r-- | xd_view.c | 2 |
4 files changed, 22 insertions, 12 deletions
diff --git a/vnc-client.c b/vnc-client.c index a8012cb..9dc221c 100644 --- a/vnc-client.c +++ b/vnc-client.c @@ -15,17 +15,16 @@ /* ------------------------------------------------------------------ */ - -/* ------------------------------------------------------------------ */ - static void usage(FILE *fp) { fprintf(fp, - "This is a vnc client\n" + "This is a simple vnc client\n" "\n" "usage: vnc-client [options] hostname displayno\n" "options:\n" - " -h print this text\n" + " -h Print this text.\n" + " -k Send locally translated keysyms. Default is to send\n" + " us-layout keysyms no matter what the local kbd layout is.\n" "\n" "-- \n" "(c) 2006 Gerd Hoffmann <kraxel@suse.de>\n"); @@ -34,13 +33,17 @@ static void usage(FILE *fp) int main(int argc, char *argv[]) { + int keysyms = 0; int c; gtk_init(&argc, &argv); for (;;) { - if (-1 == (c = getopt(argc, argv, "h"))) + if (-1 == (c = getopt(argc, argv, "hk"))) break; switch (c) { + case 'k': + keysyms = 1; + break; case 'h': usage(stdout); exit(0); @@ -55,7 +58,7 @@ main(int argc, char *argv[]) exit(1); } - if (NULL == vnc_open(argv[optind], atoi(argv[optind+1]), 1)) + if (NULL == vnc_open(argv[optind], atoi(argv[optind+1]), 1, keysyms)) exit(1); gtk_main(); @@ -289,8 +289,11 @@ static gboolean key_cb(GtkWidget *widget, GdkEventKey *event, int keydown; keydown = (8 == event->type); - if (event->hardware_keycode < linux_us_kbd_size) + if (vnc->keysyms) + keysym = event->keyval; + else if (event->hardware_keycode < linux_us_kbd_size) keysym = linux_us_kbd[event->hardware_keycode]; + if (keysym) SendKeyEvent(vnc->client, keysym, keydown ? TRUE : FALSE); else @@ -302,7 +305,8 @@ static gboolean key_cb(GtkWidget *widget, GdkEventKey *event, /* ------------------------------------------------------------------ */ /* public API functions */ -struct vnc_window* vnc_open(char *hostname, int displayno, int standalone) +struct vnc_window* vnc_open(char *hostname, int displayno, + int standalone, int keysyms) { char display[128]; char *argv[] = { "vnc-client", display, NULL }; @@ -315,6 +319,7 @@ struct vnc_window* vnc_open(char *hostname, int displayno, int standalone) goto err; memset(vnc,0,sizeof(*vnc)); vnc->standalone = standalone; + vnc->keysyms = keysyms; /* x11 */ vnc->dpy = gdk_x11_display_get_xdisplay(gdk_display_get_default()); @@ -17,9 +17,11 @@ struct vnc_window { void *shm; GC gc; Display *dpy; - /* misc */ + /* config */ int standalone; + int keysyms; }; void vnc_release(struct vnc_window*); -struct vnc_window* vnc_open(char *hostname, int displayno, int standalone); +struct vnc_window* vnc_open(char *hostname, int displayno, + int standalone, int keysyms); @@ -136,7 +136,7 @@ static void open_vnc(gint id, char *name, char *ostype) if (0 == strcmp(ostype, "hvm")) { /* works for hvm ... */ #ifdef HAVE_VNC - vnc_open("localhost", id, 0); + vnc_open("localhost", id, 0, 0); #else if (-1 == open_vnc_session("localhost", id)) gtk_message(GTK_MESSAGE_ERROR, app_error); |