From 128ee3ec4ebe6dce7d002c33c932c76183c0fa76 Mon Sep 17 00:00:00 2001 From: runge Date: Mon, 16 Mar 2009 11:09:53 -0400 Subject: [PATCH] Add some -remap tricks. Limit rfbCFD message count. --- x11vnc/README | 22 ++++++++++++++++++--- x11vnc/enc.h | 14 ++++++++++++-- x11vnc/help.c | 18 ++++++++++++++++- x11vnc/keyboard.c | 46 ++++++++++++++++++++++++++++++++++++-------- x11vnc/util.c | 13 ++++++++++++- x11vnc/x11vnc.1 | 18 ++++++++++++++++- x11vnc/x11vnc.c | 2 +- x11vnc/x11vnc_defs.c | 2 +- 8 files changed, 117 insertions(+), 18 deletions(-) diff --git a/x11vnc/README b/x11vnc/README index e446ec2..0ba8bb1 100644 --- a/x11vnc/README +++ b/x11vnc/README @@ -2,7 +2,7 @@ Copyright (C) 2002-2009 Karl J. Runge All rights reserved. -x11vnc README file Date: Sat Mar 14 21:57:32 EDT 2009 +x11vnc README file Date: Sun Mar 15 18:06:19 EDT 2009 The following information is taken from these URLs: @@ -12500,7 +12500,7 @@ x11vnc: a VNC server for real X displays Here are all of x11vnc command line options: % x11vnc -opts (see below for -help long descriptions) -x11vnc: allow VNC connections to real X11 displays. 0.9.7 lastmod: 2009-03-14 +x11vnc: allow VNC connections to real X11 displays. 0.9.7 lastmod: 2009-03-15 x11vnc options: -display disp -auth file -N @@ -12625,7 +12625,7 @@ libvncserver-tight-extension options: % x11vnc -help -x11vnc: allow VNC connections to real X11 displays. 0.9.7 lastmod: 2009-03-14 +x11vnc: allow VNC connections to real X11 displays. 0.9.7 lastmod: 2009-03-15 (type "x11vnc -opts" to just list the options.) @@ -15251,10 +15251,26 @@ t "string" exists, it is instead interpreted as this form: key1-key2,key3-key4,... See header file for a list of Keysym names, or use xev(1). + To map a key to a button click, use the fake Keysyms "Button1", ..., etc. E.g: "-remap Super_R-Button2" (useful for pasting on a laptop) + I use these if the machine I am viewing from does not + have a scrollwheel or I don't like using the one it has: + + -remap Super_R-Button4,Menu-Button5 + -remap KP_Add-Button4,KP_Enter-Button5 + + the former would be used on a PC, the latter on a + MacBook. This way those little used keys can be used + to generate bigger hops than the Up and Down arrows + provide. One can scroll through text or web pages more + quickly this way (especially if x11vnc scroll detection + is active.) + + Use Button44, Button12, etc. for multiple clicks. + To disable a keysym (i.e. make it so it will not be injected), remap it to "NoSymbol" or "None". diff --git a/x11vnc/enc.h b/x11vnc/enc.h index 4301b86..64fdf51 100644 --- a/x11vnc/enc.h +++ b/x11vnc/enc.h @@ -66,7 +66,7 @@ so, delete this exception statement from your version. * without using SSH or SSL. * * ----------------------------------------------------------------------- - * Copyright (c) 2008 Karl J. Runge + * Copyright (C) 2008-2009 Karl J. Runge * All rights reserved. * * This is free software; you can redistribute it and/or modify @@ -81,7 +81,17 @@ so, delete this exception statement from your version. * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - * USA. + * USA or see . + * + * In addition, as a special exception, Karl J. Runge + * gives permission to link the code of its release of x11vnc with the + * OpenSSL project's "OpenSSL" library (or with modified versions of it + * that use the same license as the "OpenSSL" library), and distribute + * the linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If you + * modify this file, you may extend this exception to your version of the + * file, but you are not obligated to do so. If you do not wish to do + * so, delete this exception statement from your version. * ----------------------------------------------------------------------- */ diff --git a/x11vnc/help.c b/x11vnc/help.c index 0a6e1b2..9e61b0b 100644 --- a/x11vnc/help.c +++ b/x11vnc/help.c @@ -2683,10 +2683,26 @@ void print_help(int mode) { " \"string\" exists, it is instead interpreted as this\n" " form: key1-key2,key3-key4,... See \n" " header file for a list of Keysym names, or use xev(1).\n" +"\n" " To map a key to a button click, use the fake Keysyms\n" " \"Button1\", ..., etc. E.g: \"-remap Super_R-Button2\"\n" " (useful for pasting on a laptop)\n" "\n" +" I use these if the machine I am viewing from does not\n" +" have a scrollwheel or I don't like using the one it has:\n" +"\n" +" -remap Super_R-Button4,Menu-Button5\n" +" -remap KP_Add-Button4,KP_Enter-Button5\n" +"\n" +" the former would be used on a PC, the latter on a\n" +" MacBook. This way those little used keys can be used\n" +" to generate bigger hops than the Up and Down arrows\n" +" provide. One can scroll through text or web pages more\n" +" quickly this way (especially if x11vnc scroll detection\n" +" is active.)\n" +"\n" +" Use Button44, Button12, etc. for multiple clicks.\n" +"\n" " To disable a keysym (i.e. make it so it will not be\n" " injected), remap it to \"NoSymbol\" or \"None\".\n" "\n" @@ -5432,7 +5448,7 @@ void print_license(void) { "\n" "x11vnc: a VNC server for X displays. %s\n" "\n" -"Copyright (c) 2002-2008 Karl J. Runge \n" +"Copyright (C) 2002-2009 Karl J. Runge \n" "All rights reserved.\n" "\n" ; diff --git a/x11vnc/keyboard.c b/x11vnc/keyboard.c index 1edc40b..040b2d0 100644 --- a/x11vnc/keyboard.c +++ b/x11vnc/keyboard.c @@ -2860,6 +2860,8 @@ static void pipe_keyboard(rfbBool down, rfbKeySym keysym, rfbClientPtr client) { if (isbutton) { int mask, button = (int) keysym; int x = cursor_x, y = cursor_y; + char *b, bstr[32]; + if (!down) { return; } @@ -2874,10 +2876,23 @@ static void pipe_keyboard(rfbBool down, rfbKeySym keysym, rfbClientPtr client) { * remap the button click to keystroke sequences! * Usually just will simulate the button click. */ - mask = 1<<(button-1); - pointer(mask, x, y, client); - mask = 0; - pointer(mask, x, y, client); + + /* loop over possible multiclicks: Button123 */ + sprintf(bstr, "%d", button); + b = bstr; + while (*b != '\0') { + char t[2]; + int butt; + t[0] = *b; + t[1] = '\0'; + if (sscanf(t, "%d", &butt) == 1) { + mask = 1<<(butt-1); + pointer(mask, x, y, client); + mask = 0; + pointer(mask, x, y, client); + } + b++; + } return; } @@ -3302,6 +3317,8 @@ void keyboard(rfbBool down, rfbKeySym keysym, rfbClientPtr client) { if (isbutton) { int mask, button = (int) keysym; + char *b, bstr[32]; + if (! down) { return; /* nothing to send */ } @@ -3317,10 +3334,23 @@ void keyboard(rfbBool down, rfbKeySym keysym, rfbClientPtr client) { * remap the button click to keystroke sequences! * Usually just will simulate the button click. */ - mask = 1<<(button-1); - do_button_mask_change(mask, button); /* down */ - mask = 0; - do_button_mask_change(mask, button); /* up */ + + /* loop over possible multiclicks: Button123 */ + sprintf(bstr, "%d", button); + b = bstr; + while (*b != '\0') { + char t[2]; + int butt; + t[0] = *b; + t[1] = '\0'; + if (sscanf(t, "%d", &butt) == 1) { + mask = 1<<(butt-1); + do_button_mask_change(mask, butt); /* down */ + mask = 0; + do_button_mask_change(mask, butt); /* up */ + } + b++; + } XFlush_wr(dpy); X_UNLOCK; return; diff --git a/x11vnc/util.c b/x11vnc/util.c index dfb617d..e7f7863 100644 --- a/x11vnc/util.c +++ b/x11vnc/util.c @@ -568,7 +568,18 @@ void rfbCFD(long usec) { return; } if (unixpw && unixpw_in_progress && !unixpw_in_rfbPE) { - rfbLog("unixpw_in_rfbPE: skipping rfbCFD\n"); + static int msgs = 0; + static double last_reset = 0.0; + if (dnow() > last_reset + 5.0) { + msgs = 0; + last_reset = dnow(); + } + if (msgs++ < 10) { + rfbLog("unixpw_in_rfbPE: skipping rfbCFD\n"); + if (msgs == 10) { + rfbLog("unixpw_in_rfbPE: skipping rfbCFD ...\n"); + } + } return; } if (usec > USEC_MAX) { diff --git a/x11vnc/x11vnc.1 b/x11vnc/x11vnc.1 index 22e9203..b042633 100644 --- a/x11vnc/x11vnc.1 +++ b/x11vnc/x11vnc.1 @@ -2,7 +2,7 @@ .TH X11VNC "1" "March 2009" "x11vnc " "User Commands" .SH NAME x11vnc - allow VNC connections to real X11 displays - version: 0.9.7, lastmod: 2009-03-14 + version: 0.9.7, lastmod: 2009-03-15 .SH SYNOPSIS .B x11vnc [OPTION]... @@ -3048,10 +3048,26 @@ or hex value) separated by a space. If no file named form: key1-key2,key3-key4,... See header file for a list of Keysym names, or use .IR xev (1). +.IP To map a key to a button click, use the fake Keysyms "Button1", ..., etc. E.g: "\fB-remap\fR \fISuper_R-Button2\fR" (useful for pasting on a laptop) .IP +I use these if the machine I am viewing from does not +have a scrollwheel or I don't like using the one it has: +.IP +\fB-remap\fR Super_R-Button4,Menu-Button5 +\fB-remap\fR KP_Add-Button4,KP_Enter-Button5 +.IP +the former would be used on a PC, the latter on a +MacBook. This way those little used keys can be used +to generate bigger hops than the Up and Down arrows +provide. One can scroll through text or web pages more +quickly this way (especially if x11vnc scroll detection +is active.) +.IP +Use Button44, Button12, etc. for multiple clicks. +.IP To disable a keysym (i.e. make it so it will not be injected), remap it to "NoSymbol" or "None". .IP diff --git a/x11vnc/x11vnc.c b/x11vnc/x11vnc.c index f55aaec..35e0fc3 100644 --- a/x11vnc/x11vnc.c +++ b/x11vnc/x11vnc.c @@ -34,7 +34,7 @@ /* * This program is based on some ideas from the following programs: * - * the originial x11vnc.c in libvncserver (Johannes E. Schindelin) + * the initial x11vnc.c in libvncserver (Johannes E. Schindelin) * x0rfbserver, the original native X vnc server (Jens Wagner) * krfb, the KDE desktopsharing project (Tim Jansen) * diff --git a/x11vnc/x11vnc_defs.c b/x11vnc/x11vnc_defs.c index 1e7ada5..97ec5e0 100644 --- a/x11vnc/x11vnc_defs.c +++ b/x11vnc/x11vnc_defs.c @@ -47,7 +47,7 @@ int xtrap_base_event_type = 0; int xdamage_base_event_type = 0; /* date +'lastmod: %Y-%m-%d' */ -char lastmod[] = "0.9.7 lastmod: 2009-03-14"; +char lastmod[] = "0.9.7 lastmod: 2009-03-15"; /* X display info */