From X2Go-ML-1@baur-itcs.de  Tue Jan  6 18:50:19 2015
Received: (at 719) by bugs.x2go.org; 6 Jan 2015 17:50:21 +0000
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on
	ymir.das-netzwerkteam.de
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham
	version=3.3.2
Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.130])
	by ymir.das-netzwerkteam.de (Postfix) with ESMTPS id 031C45DB53
	for <719@bugs.x2go.org>; Tue,  6 Jan 2015 18:50:18 +0100 (CET)
Received: from [192.168.0.3] ([188.105.114.75]) by mrelayeu.kundenserver.de
 (mreue002) with ESMTPSA (Nemesis) id 0LkG7v-1XY83N1Wfb-00cRzz; Tue, 06 Jan
 2015 18:50:18 +0100
Message-ID: <54AC208B.4000900@baur-itcs.de>
Date: Tue, 06 Jan 2015 18:51:07 +0100
From: Stefan Baur <X2Go-ML-1@baur-itcs.de>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0
MIME-Version: 1.0
To: 719@bugs.x2go.org
Subject: Re: [X2Go-Dev] Bug#719: Clone screens for touch-enabled devices
References: <54ABEC61.7040006@baur-itcs.de> <54ABF5F3.1030603@baur-itcs.de>
In-Reply-To: <54ABF5F3.1030603@baur-itcs.de>
Content-Type: multipart/mixed;
 boundary="------------090607010707090606090108"
X-Provags-ID:  V03:K0:MYAXBgNylrQzY1Ca9o5XDI786bXU38iMuvpYdqssVybbVZ0BVip
 0p98AwQ+WSuUMBu0I43HgPICGradQTUKG0dMivCwSMHOOI0JiGvz6axV0etYaI0Xx/7ti3p
 t3cllStYH/TQSy8rwjuE1DRqnVp7OLQpAM5WFha8g0UHSB9MDYRrbwAy/MJzEtKAMxE+XKy
 UjFVBLGlC+2xWCNsAKW5Q==
X-UI-Out-Filterresults: notjunk:1;

This is a multi-part message in MIME format.
--------------090607010707090606090108
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 8bit

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Please disregard my earlier patch and use this one instead.

I have added functionality for mouse detection and an override option
via boot parameter.

- -- 
BAUR-ITCS UG (haftungsbeschränkt)
Geschäftsführer: Stefan Baur
Eichenäckerweg 10, 89081 Ulm | Registergericht Ulm, HRB 724364
Fon/Fax 0731 40 34 66-36/-35 | USt-IdNr.: DE268653243
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (MingW32)

iQEcBAEBAgAGBQJUrCCLAAoJEG7d9BjNvlEZBYIH/2fjVDuMzmDHZmR5yiUwFxXA
5q1q5O/R//jV6UI2FJ4uXlFTNanBzlc6eQLdGKffi+guS7FmV7+Vz3UPTsSII2/M
zOx7+3EYvh9D3ato7uXpH9ZfgMHeRcM7N2Ff57N3vhqyLdF9NWu7vNrwCZarqqNf
0oSkmbkN+tkQx4QqMV8HNJApP0mbqAgb8r/ImfAvBg25OTx6Tij9ibiTfVAV00Aq
Xv+PgbOLambziMak9OUgwIQS3cet58RG+RXtqFLLIlCesH4fgMFPl058NEptUGke
MX/KBUdAXUrBOQbbJkZziLMC7FZGVUQbbCersznRSuP/HU9QLsEQnVEUUzU5X9E=
=foAA
-----END PGP SIGNATURE-----

--------------090607010707090606090108
Content-Type: text/plain; charset=windows-1252;
 name="clone-screens-for-touch-enabled-devices-x2gothinclientd-v2.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename*0="clone-screens-for-touch-enabled-devices-x2gothinclientd-v2.p";
 filename*1="atch"

--- /usr/sbin/x2gothinclientd.orig      2015-01-06 18:34:27.591213413 +0000
+++ /usr/sbin/x2gothinclientd   2015-01-06 18:44:40.679505839 +0000
@@ -111,19 +111,67 @@
                        # wait for X-Server to come up
                        sleep(3);

-                       # align displays next to each other in order of appearance in xrandr
-                       my $this_display;
-                       my $next_display;
-                       foreach (`DISPLAY=:0 LANG=C xrandr 2>/dev/null | grep ' connected ' | cut -d ' ' -f1`)
+                       # Align displays next to each other in order of appearance in xrandr, unless touch
+                       # devices are detected - in that case, clone displays so that touchable area and display
+                       # stay aligned.  This fix has been introduced for a certain make of wacom touch-sensitive
+                       # displays.  If you have a touch-sensitive device that isn't affected by this, or that
+                       # is negatively affected by this fix, please let us know so we can add a better detection.
+                       # The fix is bypassed if a mouse device is detected.
+                       # Note that you can manually override the behavior by passing a kernel parameter
+                       # xinerama=above|below|same-as|left-of|right-of to override the autodetection.
+
+                       # check if a xinerama kernel parameter is set
+                       my $xrandrcmdtainted = `cat /proc/cmdline | tr ' ' '\n' | awk -F '=' '$1 == "xinerama" { print $2 }'`;
+                       my $xrandrcmd;
+                       if ($xrandrcmdtainted =~ /(^above$|^below$|^same-as$|^left-of$|^right-of$)/)
                        {
-                               $next_display = $_;
-                               $next_display =~ s/\n//;
-                               if (defined($this_display))
-                               {
-                                       `DISPLAY=:0 /usr/bin/xrandr --output $next_display --left-of $this_display`;
-                               }
-                               $this_display = $next_display;
+                               # if the parameter value matches one value of the defined set, use that
+                               $xrandrcmd = $1;
                        }
+                       else
+                       {
+                               # else default to "left-of", which was our standard behavior in previous versions
+                               $xrandrcmd = "left-of";
+                       }
+
+                       # find out how many touch devices we have
+                        my $touchdevicescount = `DISPLAY=:0 xsetwacom -d localhost:0.0 --list devices | wc -l`;
+
+                       # find out how many mouse devices we have
+                       my $micecount = `find /dev/input -maxdepth 1 -name "mouse*" | wc -l`;
+
+                       # declare two variables for the upcoming loop
+                       my $this_display;
+                       my $next_display;
+
+                       # loop through the following code block for all connected display devices
+                        foreach (`DISPLAY=:0 LANG=C xrandr 2>/dev/null | grep ' connected ' | cut -d ' ' -f1`)
+                        {
+                               # assign a value to $next_display and remove newline from it
+                                chomp ($next_display = $_);
+
+                               # $this_display won't be defined until the second time the loop is executed, which is a
+                               # neat way of running xrandr only if there are at least two connected display devices
+                                if (defined($this_display))
+                                {
+                                       if (($touchdevicescount > 0) && ($micecount < 1) && ($xrandrcmdtainted eq ""))
+                                       {
+                                               # we have a touch device and no mice, and no xinerama parameter was set,
+                                               # so switch to clone view to make the touch device usable
+                                               `DISPLAY=:0 /usr/bin/xrandr --output $next_display --same-as $this_display`;
+                                       }
+                                       else
+                                       {
+                                               # else use whatever is in $xrandrcmd (which is either our default of "left-of",
+                                               # or a valid xinerama kernel parameter value)
+                                               `DISPLAY=:0 /usr/bin/xrandr --output $next_display --$xrandrcmd $this_display`;
+                                       }
+                               }
+
+                               # now set $this_display -> every subsequent iteration of the loop will now enter the code block
+                               # above where (defined($this_display)) is the conditional
+                                $this_display = $next_display;
+                        }
                }

                # test if pulseaudio is running, if not launch it...

--------------090607010707090606090108
Content-Type: application/octet-stream;
 name="clone-screens-for-touch-enabled-devices-x2gothinclientd-v2.patch.sig"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename*0="clone-screens-for-touch-enabled-devices-x2gothinclientd-v2.p";
 filename*1="atch.sig"

iQEcBAABAgAGBQJUrCCLAAoJEG7d9BjNvlEZKZ0H/iyg8ElwhCIyYuNlBXrCvNFhMDh3LYkV
Uv2b4TwsUEJaFHhHYAbx9zcg3eCHB8TqQ3QuXvvKetbdrvZjnnEkt64vtCcV+FGmLTtStPqg
uImf0QiHYiVHjQkiwRmr2VfS3P6tv/Wt2L+CkzbSoobdOfZsuRCnUEFg7Gmp38CBjYc7O862
SgKXotMo27G5cLvZcFV6nf5Pbx09W2uxVYaT36n2JarZqHEwrG/F7QAfFUR6CgW8lyRJoOu3
uE4gR0jJr8QabfwJwWEP96kb5ImU4SxvdM9myorq6t6n2sEJ/YF2p92yzRXFvaYGjH7m6Ymr
K0NjHn4N3uyzC19/HgE5QqE=
--------------090607010707090606090108--

