[X2Go-Dev] Bug#719: Bug#719: Clone screens for touch-enabled devices

Stefan Baur X2Go-ML-1 at baur-itcs.de
Tue Jan 6 19:36:57 CET 2015


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

Third time's a charm ...
Again, please disregard my earlier patch and use this one instead.

v2 had introduced formatting errors, also, two escape signs were
missing.  v3 fixes that.

- -- 
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)

iQEcBAEBAgAGBQJUrCtJAAoJEG7d9BjNvlEZUKIH/134doSYAlVMRcreOr9pSUv/
pKKxOLSnR+P7sAjlyf4UGuqIUNIVdsrRdh1zTPwygZsnlLVU0rgnXum8K7bKV/WV
XcvFKrBi5ZtURvMQoqrpDiXgvM4csfO9n01i5umTxIoX7l4hrmT4q4PKX8Wncaxb
2V49BQsG4Uah5juZHWUqt/LDWkjMK8fduaMkRogp7neoO6LT8G/WEKYhAUug8Roe
n8ZyuyCKjB97lFpPZu1ub3deGX/WfSlT3CbJpbRtZO4anSAoNGC2f+JMmjY1mKNd
An3v4Tbr6N7pS8HAPqwhKw1uAe0eqif7fD7FY2wp+PD/BiJwQ9Ng/Ejl8xFamf4=
=v2VE
-----END PGP SIGNATURE-----
-------------- next part --------------
--- /usr/sbin/x2gothinclientd   2014-02-27 13:27:09.000000000 +0000
+++ /usr/sbin/x2gothinclientd.new       2015-01-06 19:32:47.231326854 +0000
@@ -103,6 +103,7 @@
                        system("shutdown -h now");
                        system("chvt 7");
                }
+
                # test if XServer is running, if not launch it...
                if ( check_x() ==0 )
                {
@@ -111,17 +112,65 @@
                        # wait for X-Server to come up
                        sleep(3);

-                       # align displays next to each other in order of appearance in xrandr
+                       # 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$)/)
+                       {
+                               # 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`)
                        {
-                               $next_display = $_;
-                               $next_display =~ s/\n//;
+                               # 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))
                                {
-                                       `DISPLAY=:0 /usr/bin/xrandr --output $next_display --left-of $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;
                        }
                }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clone-screens-for-touch-enabled-devices-x2gothinclientd-v3.patch.sig
Type: application/octet-stream
Size: 287 bytes
Desc: not available
URL: <http://lists.x2go.org/pipermail/x2go-dev/attachments/20150106/1e6a59c7/attachment.obj>


More information about the x2go-dev mailing list