Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 x2x (1.30-3) unstable; urgency=medium
 .
   * Merge upstream patches
   * Bump standards version (no changes required)
   * Secure some URLs
   * Harden
Author: Barak A. Pearlmutter <bap@debian.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- x2x-1.30.orig/Makefile.am
+++ x2x-1.30/Makefile.am
@@ -4,9 +4,6 @@
 # BSD-3
 #
 
-AM_CFLAGS = $(X11_CFLAGS) -Wall
-AM_LDFLAGS = $(X11_LIBS)
-
 bin_PROGRAMS = x2x
 
 x2x_SOURCES = x2x.c
@@ -18,8 +15,8 @@ dist_man1_MANS = x2x.1
 
 if WIN32
 
-AM_CFLAGS += -DWIN_2_X
-AM_LDFLAGS += -luser32 -lgdi32 # Ugly hack
+AM_CFLAGS = -DWIN_2_X
+LIBS += -luser32 -lgdi32 # Ugly hack
 x2x_SOURCES += keymap.c winmsg.c x2xwin.rc
 
 .o:.rc
--- x2x-1.30.orig/README
+++ x2x-1.30/README
@@ -32,3 +32,11 @@ Authors
 
 x2x was initially developed in DEC by David Chaiken.
 Current maintainer is Mikhail Gusarov.
+
+== Installing on Fedora  ==
+
+1. git clone
+2. ./bootstrap.sh
+3. sudo yum -y install libXext-devel libXtst-devel
+4. ./configure
+5.  make; make install
--- x2x-1.30.orig/configure.ac
+++ x2x-1.30/configure.ac
@@ -15,23 +15,24 @@ AC_CONFIG_HEADERS([config.h])
 AC_PROG_CC
 AC_PROG_INSTALL
 
+AX_CFLAGS_WARN_ALL
+
 ## This PKG_CHECK_MODULES can be replaced by the following three
-## AC_CHECK_LIBs and the non-Cygwin setting of AM_LDFLAGS and
+## AC_SEARCH_LIBSs and the non-Cygwin setting of AM_LDFLAGS and
 ## AM_CFLAGS in Makefile.am removed.
 PKG_CHECK_MODULES(X11, xext xtst x11)
-# AC_CHECK_LIB([X11], [XOpenDisplay])
-# AC_CHECK_LIB([Xext], [XextFindDisplay])
-# AC_CHECK_LIB([Xtst], [XTestFakeKeyEvent])
+# AC_SEARCH_LIBS([XOpenDisplay], [X11 x11])
+# AC_SEARCH_LIBS([XextFindDisplay], [Xext xext])
+# AC_SEARCH_LIBS([XTestFakeKeyEvent], [Xtst xtst])
+
+CFLAGS="${X11_CFLAGS} ${CFLAGS}"
+LIBS="${X11_LIBS} ${LIBS}"
 
 AC_ARG_ENABLE([win32],
     AS_HELP_STRING(
         [--enable-win32],
         [enable Win32 support (-fromwin option). Disabled by default]))
 
-AC_SUBST(X11_CFLAGS)
-AC_SUBST(X11_LIBS)
-AC_SUBST(enable_win32)
-
 AM_CONDITIONAL(WIN32, [test x$enable_win32 = xyes])
 
 AC_CONFIG_FILES([Makefile])
--- x2x-1.30.orig/x2x.1
+++ x2x-1.30/x2x.1
@@ -1,4 +1,9 @@
 .nh
+.de URL
+\\$2 \(laURL: \\$1 \(ra\\$3
+..
+.if \n[.g] .mso www.tmac
+\" .mso www.tmac
 .TH x2x 1
 .SH NAME
 x2x \- X to X connection
@@ -244,10 +249,45 @@ Override the title of the control window
 .B \-copyright
 .IP
 Prints the full copyright for the x2x code.
+.TP
+.B \-noscale
+.IP
+This option turns off the mouse scaling.  In some circumstances, the
+remote screen is so different in physical size or resolution that the
+normal mouse scaling applied by x2x distorts the mouse movement so much
+as to be practially unusable.  Note: this is only useful if the remote
+screen is lower resolution than the local screen and also causes the
+remote mouse pointer to warp around when it hits the edges.
+.SH EXAMPLES
+Calling the system whose keyboard is to be used "primary" and the
+other system "secondary", you need to specify either \-from
+primary-x-display or \-to secondary-x-display.  The x2x program can be
+run on either system.  The easiest way to maintain security is to
+tunnel an X connection over ssh.  Since x2x can be run on either
+computer, it can be invoked in either of the following ways, where we
+assume the local display on each system is :0.
+.TP
+run indirectly on secondary:
+.IP
+primary $ ssh \-X secondary x2x \-to :0 \-east
+.TP
+run indirectly on primary:
+.IP
+secondary $ ssh \-X primary x2x \-from :0 \-west
+.TP
+run directly indirectly on primary:
+.IP
+primary $ ssh \-A secondary env DISPLAY=:0.0 ssh \-X primary x2x \-from :0 \-east
+.SH SEE ALSO
+The
+.URL http://synergy-project.org "synergy program"
+has similar functionality to that of x2x, supports multiple platforms,
+and when I try to use it my X session crashes.
+
+There is a nice
+.URL http://www.linuxjournal.com/content/share-keyboardmouse-between-multiple-computers-x2x "Linux Journal article on x2x" .
 .SH AUTHOR
-David Chaiken
-.br
-(chaiken@pa.dec.com)
+David Chaiken <chaiken@pa.dec.com>
 .br
 Mark Hayter (\-fromwin code, thanks to the WinVNC sources)
 .br
@@ -259,8 +299,9 @@ Current maintaner is Mikhail Gusarov <do
 This software is experimental!  Heaven help you if your network
 connection should go down.  Caveat hacker.  TANSTAAFL.
 
-Nevertheless, bugtracker is at
-http://x2x.dottedmag.net/trac/do/newticket
+The
+.URL http://github.com/dottedmag/x2x "x2x repository and issue tracker"
+has moved to github.
 
 When using the \-fromwin option if the Ctrl-Alt-Del keysequence is used
 while the mouse is forwarded to the X display then the Ctrl and Alt
@@ -273,6 +314,9 @@ and Alt should restore correct operation
 mouse to the Windows display (or using the RightAlt-Home magic key
 sequence).
 
+If you have trouble with some keys not working, try setting the
+keymaps on both systems to be the same using \fBsetxkbmap\fR.
+
 .SH LAWYERESE
 Copyright (c) 1997
 Digital Equipment Corporation.  All rights reserved.
--- x2x-1.30.orig/x2x.c
+++ x2x-1.30/x2x.c
@@ -373,6 +373,7 @@ static Bool    doDpmsMouse  = False;
 static int     logicalOffset= 0;
 static int     nButtons     = 0;
 static KeySym  buttonmap[N_BUTTONS + 1][MAX_BUTTONMAPEVENTS + 1];
+static Bool    noScale      = False;
 
 #ifdef WIN_2_X
 /* These are used to allow pointer comparisons */
@@ -731,6 +732,8 @@ char **argv;
       triggerw = atoi(argv[arg]);
     } else if (!strcasecmp(argv[arg], "-copyright")) {
       puts(lawyerese);
+    } else if (!strcasecmp(argv[arg], "-noscale")) {
+      noScale = True;
     } else {
       Usage();
     } /* END if... */
@@ -1324,13 +1327,31 @@ PDPYINFO pDpyInfo;
     pDpyInfo->yTables[screenNum] = yTable =
       (short *)xmalloc(sizeof(short) * fromHeight);
 
-    /* vertical conversion table */
-    for (counter = 0; counter < fromHeight; ++counter)
-      yTable[counter] = (counter * toHeight) / fromHeight;
-
-    /* horizontal conversion table entries */
-    for (counter = 0; counter < fromWidth; ++counter)
-      xTable[counter] = (counter * toWidth) / fromWidth;
+    if (noScale) {
+        /* TODO:
+            - the fake tables should be built as "starting ignored", 1:1 map
+              region and "ending ignored".  Then the rest of the code would
+              need to be taught to disallow mouse movements in the two ignored
+              areas.  This would stop the mouse wrap-around that the simple
+              tables below result in.
+        */
+
+        /* fake vertical conversion table */
+        for (counter = 0; counter < fromHeight; ++counter)
+          yTable[counter] = counter % (toHeight - 1);
+
+        /* fake horizontal conversion table entries */
+        for (counter = 0; counter < fromWidth; ++counter)
+          xTable[counter] = counter % (toWidth - 1);
+    } else {
+        /* vertical conversion table */
+        for (counter = 0; counter < fromHeight; ++counter)
+          yTable[counter] = (counter * toHeight) / fromHeight;
+
+        /* horizontal conversion table entries */
+        for (counter = 0; counter < fromWidth; ++counter)
+          xTable[counter] = (counter * toWidth) / fromWidth;
+    }
 
     /* adjustment for boundaries */
     if (vertical) {
