head 1.1; access; symbols OPENPKG_E1_MP_HEAD:1.1 OPENPKG_E1_MP:1.1 OPENPKG_E1_MP_2_STABLE:1.1.2.2 OPENPKG_E1_FP:1.1.2.2 OPENPKG_2_STABLE_MP:1.1 OPENPKG_2_STABLE_20061018:1.1.2.2 OPENPKG_2_STABLE:1.1.0.2 OPENPKG_CW_FP:1.1; locks; strict; comment @# @; 1.1 date 2004.08.28.19.14.58; author rse; state Exp; branches 1.1.2.1; next ; 1.1.2.1 date 2004.08.28.19.14.58; author rse; state dead; branches; next 1.1.2.2; commitid iZxwRSmmWscPXUQr; 1.1.2.2 date 2006.10.16.14.58.05; author rse; state Exp; branches; next ; commitid iZxwRSmmWscPXUQr; desc @@ 1.1 log @new package: x2x 1.27 (X11 to X11 Connection) @ text @This is the Debian patch set for X2X (x2x_1.27-5.1.diff.gz) Index: Imakefile --- Imakefile.orig 1997-08-20 18:14:52 +0200 +++ Imakefile 2004-08-28 20:56:14 +0200 @@@@ -2,7 +2,7 @@@@ DEPLIBS = $(DEPXTESTLIB) $(DEPEXTENSIONLIB) $(DEPXLIB) LOCAL_LIBRARIES = $(XTESTLIB) $(EXTENSIONLIB) $(XLIB) - SRCS = lawyerese.c x2x.c format.c - OBJS = lawyerese.o x2x.o format.o + SRCS = lawyerese.c x2x.c + OBJS = lawyerese.o x2x.o PROTO_DEFINES = --- format.c.orig 1997-08-20 18:14:52 +0200 +++ format.c 2004-08-28 20:56:14 +0200 @@@@ -199,7 +199,6 @@@@ { int fontheight, fontwidth; int width, height; - int len; int format; unsigned minchar, maxchar; unsigned char *buffer, thechar; --- x2x.1.orig 1997-08-20 18:14:51 +0200 +++ x2x.1 2004-08-28 20:56:14 +0200 @@@@ -3,7 +3,7 @@@@ .SH NAME x2x \- X to X connection .SH SYNTAX -\f x2x\fR <[-to ] | [-from ]> [options...] +\fB x2x\fR <[-to ] | [-from ]> [options...] .SH DESCRIPTION x2x allows the keyboard and mouse on one ("from") X display to be used to control another ("to") X display. Since x2x uses the XTEST extension, @@@@ -17,12 +17,12 @@@@ a subsequent multiple button click on the "to" display returns control to the "from" display. -If the -east or -west options are specified on the command line, x2x -starts up with a different interface. When the mouse moves to the -(east or west) side of the default screen on the "from" display, the -cursor slides over to the "to" display. When the mouse returns to -to side of the "to" display that it entered, it slides back onto -the "from" display. +If the -north, -south, -east or -west options are specified on the +command line, x2x starts up with a different interface. When the mouse +moves to the top, bottom, east side or west side of the default screen +on the "from" display, the cursor slides over to the "to" display. +When the mouse returns to to side of the "to" display that it entered, +it slides back onto the "from" display. Unless the -nosel option is specified, x2x relays X selections from one display to the other. @@@@ -55,6 +55,14 @@@@ Indicates the ("from") display that remotely controls the "to" display. Default is equivalent to the default display. .TP +.B \-north +.IP +Slide off the north side of the "to" display onto the "from" display. +.TP +.B \-south +.IP +Slide off the south side of the "to" display onto the "from" display. +.TP .B \-east .IP Slide off the east side of the "to" display onto the "from" display. @@@@ -70,7 +78,7 @@@@ .B \-geometry \fIspecification\fP .IP The X geometry specification for the x2x window. -(Overridden by -east or -west.) +(Overridden by -north, -south, -east or -west.) .TP .B \-wait .IP @@@@ -85,14 +93,21 @@@@ .TP .B \-buttonblock .IP -If this option is enabled with -east or -west, the cursor will not -slide back onto the "from" display when one or more mouse buttons -are pressed. +If this option is enabled with -north, -south, -east or -west, the +cursor will not slide back onto the "from" display when one or more +mouse buttons are pressed. +.TP +.B \-buttonmap \fIbutton#\fP \fR"\fP\fIKeySym ...\fP\fR"\fP +.IP +Map a mouse button to one or more keyboard events on the "to" display. +This is useful if you have a mouse with more buttons than the remote X +server can handle (e.g. a wheel mouse on a PC, merged with a Sun/Sparc +OpenWindows display). .TP .B \-nomouse .IP Don't capture the mouse. -(Overridden by -east or -west.) +(Overridden by -north, -south, -east or -west.) .TP .B \-nopointermap .IP @@@@ -119,11 +134,12 @@@@ .TP .B \-resurface .IP -Ugly hack to work-around window manager ugliness. The -east and -west -modes actually put a small window on the side of the "from" display. -This option causes this window to resurface itself if another window -ever obscures it. This option can cause really nasty behavior if another -application tries to do the same thing. Useful for login scripts. +Ugly hack to work-around window manager ugliness. The -north, -south, +-east and -west modes actually put a small window on the side of the +"from" display. This option causes this window to resurface itself if +another window ever obscures it. This option can cause really nasty +behavior if another application tries to do the same thing. Useful for +login scripts. .TP .B \-shadow \fIdisplay\fP .IP @@@@ -137,10 +153,17 @@@@ sticky option prevents autoup for the specified key. Look in /usr/include/X11/keysymdef.h for a list of valid names of keys (remove the leading XK_). +.TP +.B \-label \fIlabel\fP +Override the title of the control window (useful when running over ssh). +.IP .SH AUTHOR David Chaiken .br (chaiken@@pa.dec.com) +.PP +Addition of -north and -south options by Charles Briscoe-Smith +. .SH BUGS This software is experimental! Heaven help you if your network connection should go down. Caveat hacker. TANSTAAFL. --- x2x.c.orig 1997-08-20 18:14:52 +0200 +++ x2x.c 2004-08-28 20:58:23 +0200 @@@@ -1,7 +1,7 @@@@ /* - * x2x: Uses the XTEST extension to forward keystrokes from a window on - * one display to another display. Useful for desks - * with multiple keyboards. + * x2x: Uses the XTEST extension to forward mouse movements and keystrokes + * from a window on one display to another display. Useful for + * desks with multiple keyboards. * * Copyright (c) 1997 * Digital Equipment Corporation. All rights reserved. @@@@ -37,26 +37,37 @@@@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + #include #include #include +#include #include #include #include #include #include /* for selection */ +#include #include /* for select */ #include /* for select */ -#include "format.h" /*#define DEBUG*/ +#ifndef MIN +#define MIN(x,y) (((x) < (y)) ? (x) : (y)) +#endif +#ifndef MAX +#define MAX(x,y) (((x) > (y)) ? (x) : (y)) +#endif + /********** * definitions for edge **********/ #define EDGE_NONE 0 /* don't transfer between edges of screens */ -#define EDGE_EAST 1 /* from display is on the east side of to display */ -#define EDGE_WEST 2 /* from display is on the west side of to display */ +#define EDGE_NORTH 1 /* from display is on the north side of to display */ +#define EDGE_SOUTH 2 /* from display is on the south side of to display */ +#define EDGE_EAST 3 /* from display is on the east side of to display */ +#define EDGE_WEST 4 /* from display is on the west side of to display */ /********** * functions @@@@ -92,25 +103,6 @@@@ static void Usage(); /********** - * text formatting instructions - **********/ -#define toDpyFormatLength (sizeof(toDpyFormat) / sizeof(Format)) -static Format toDpyFormat[] = { - FormatMeasureText, - FormatSetLeft, 0, - FormatSetTop, 0, - FormatAddHalfTextX, 1, - FormatAddHalfTextY, 3, - FormatString, (Format)"unknown", - FormatAddHalfTextX, 1, - FormatAddHalfTextY, 1 - }; -/* indexes of values to be filled in at runtime */ -#define toDpyLeftIndex 2 -#define toDpyTopIndex 4 -#define toDpyStringIndex 10 - -/********** * stuff for selection forwarding **********/ typedef struct _dpyxtra { @@@@ -135,6 +127,8 @@@@ #define N_BUTTONS 5 +#define MAX_BUTTONMAPEVENTS 20 + #define GETDPYXTRA(DPY,PDPYINFO)\ (((DPY) == (PDPYINFO)->fromDpy) ?\ &((PDPYINFO)->fromDpyXtra) : &((PDPYINFO)->toDpyXtra)) @@@@ -161,9 +155,10 @@@@ GC textGC; Atom wmpAtom, wmdwAtom; Cursor grabCursor; - XFS *font; - int twidth, theight; - int lastFromX; + Font fid; + int width, height, twidth, theight, tascent; + Bool vertical; + int lastFromCoord; int unreasonableDelta; /* stuff on "to" display */ @@@@ -180,8 +175,10 @@@@ int nScreens; short **xTables; /* precalculated conversion tables */ short **yTables; - int fromXConn, fromXDisc; /* location of cursor after conn/disc ops */ - int fromXIncr, fromXDecr; /* location of cursor after incr/decr ops */ + int fromConnCoord; /* location of cursor after conn/disc ops */ + int fromDiscCoord; + int fromIncrCoord; /* location of cursor after incr/decr ops */ + int fromDecrCoord; /* selection forwarding info */ DPYXTRA fromDpyXtra; @@@@ -218,6 +215,7 @@@@ static char *toDpyName = NULL; static char *defaultFN = "-*-times-bold-r-*-*-*-180-*-*-*-*-*-*"; static char *fontName = "-*-times-bold-r-*-*-*-180-*-*-*-*-*-*"; +static char *label = NULL; static char *pingStr = "PING"; /* atom for ping request */ static char *geomStr = NULL; static Bool waitDpy = False; @@@@ -232,13 +230,13 @@@@ static Bool doPointerMap = True; static PSTICKY stickies = NULL; static Bool doBtnBlock = False; +static int nButtons = 0; +static KeySym buttonmap[N_BUTTONS + 1][MAX_BUTTONMAPEVENTS + 1]; /********** * main **********/ -main(argc, argv) -int argc; -char **argv; +int main(int argc, char **argv) { Display *fromDpy; PSHADOW pShadow; @@@@ -253,7 +251,7 @@@@ exit(1); } - /* no OS independent wat to stop Xlib from complaining via stderr, + /* no OS independent way to stop Xlib from complaining via stderr, but can always pipe stdout/stderr to /dev/null */ /* convert to real name: */ while ((fromDpy = XOpenDisplay(fromDpyName)) == NULL) { @@@@ -326,11 +324,18 @@@@ extern char *lawyerese; PSTICKY pNewSticky; KeySym keysym; + int button; + int eventno; + char *keyname, *argptr; #ifdef DEBUG printf ("programStr = %s\n", programStr); #endif + /* Clear button map */ + for (button = 0; button <= N_BUTTONS; button++) + buttonmap[button][0] = NoSymbol; + for (arg = 1; arg < argc; ++arg) { if (!strcasecmp(argv[arg], "-from")) { if (++arg >= argc) Usage(); @@@@ -353,6 +358,13 @@@@ #ifdef DEBUG printf ("fontName = %s\n", fontName); #endif + } else if (!strcasecmp(argv[arg], "-label")) { + if (++arg >= argc) Usage(); + label = argv[arg]; + +#ifdef DEBUG + printf ("label = %s\n", label); +#endif } else if (!strcasecmp(argv[arg], "-geometry")) { if (++arg >= argc) Usage(); geomStr = argv[arg]; @@@@ -384,6 +396,16 @@@@ #ifdef DEBUG printf("will not do pointer mapping\n"); #endif + } else if (!strcasecmp(argv[arg], "-north")) { + doEdge = EDGE_NORTH; +#ifdef DEBUG + printf("\"from\" is on the north side of \"to\"\n"); +#endif + } else if (!strcasecmp(argv[arg], "-south")) { + doEdge = EDGE_SOUTH; +#ifdef DEBUG + printf("\"from\" is on the south side of \"to\"\n"); +#endif } else if (!strcasecmp(argv[arg], "-east")) { doEdge = EDGE_EAST; #ifdef DEBUG @@@@ -422,6 +444,34 @@@@ } else { printf("x2x: warning: can't translate %s\n", argv[arg]); } + } else if (!strcasecmp(argv[arg], "-buttonmap")) { + if (++arg >= argc) Usage(); + button = atoi(argv[arg]); + + if ((button < 1) || (button > N_BUTTONS)) + printf("x2x: warning: invalid button %d\n", button); + else if (++arg >= argc) + Usage(); + else + { +#ifdef DEBUG + printf("will map button %d to keysyms '%s'\n", button, argv[arg]); +#endif + argptr = argv[arg]; + eventno = 0; + while ((keyname = strtok(argptr, " \t\n\r")) != NULL) + { + if ((keysym = XStringToKeysym(keyname)) == NoSymbol) + printf("x2x: warning: can't translate %s\n", keyname); + else if (eventno + 1 >= MAX_BUTTONMAPEVENTS) + printf("x2x: warning: too many keys mapped to button %d\n", + button); + else + buttonmap[button][eventno++] = keysym; + argptr = NULL; + } + buttonmap[button][eventno] = NoSymbol; + } } else if (!strcasecmp(argv[arg], "-resurface")) { doResurface = True; #ifdef DEBUG @@@@ -458,6 +508,9 @@@@ printf(" -big\n"); printf(" -buttonblock\n"); printf(" -nomouse\n"); + printf(" -nopointermap\n"); + printf(" -north\n"); + printf(" -south\n"); printf(" -east\n"); printf(" -west\n"); printf(" -nosel\n"); @@@@ -465,6 +518,8 @@@@ printf(" -resurface\n"); printf(" -shadow \n"); printf(" -sticky \n"); + printf(" -label