← Back to team overview

epoptes team mailing list archive

[Merge] lp:~oiteam/epoptes/lock-pointer into lp:epoptes

 

Laércio de Sousa has proposed merging lp:~oiteam/epoptes/lock-pointer into lp:epoptes.

Requested reviews:
  Epoptes Developers (epoptes)
Related bugs:
  Bug #1428141 in Epoptes: "Clients' local pointer movement can't be grabbed when they get assisted"
  https://bugs.launchpad.net/epoptes/+bug/1428141

For more details, see:
https://code.launchpad.net/~oiteam/epoptes/lock-pointer/+merge/251742

We propose a solution to prevent user client from moving mouse pointer locally while getting assisted, if Epoptes server is configured to grab user input.
-- 
Your team Epoptes Developers is requested to review the proposed merge of lp:~oiteam/epoptes/lock-pointer into lp:epoptes.
=== modified file 'data/client-functions'
--- data/client-functions	2013-11-03 20:44:59 +0000
+++ data/client-functions	2015-03-04 13:56:48 +0000
@@ -233,7 +233,8 @@
 # $1 = port.
 # $2 = grab keyboard and mouse.
 get_assisted() {
-    background x11vnc -noshm -24to32 ${2:+-grabptr -grabkbd} -connect_or_exit "$SERVER:$1"
+    X11VNC_PID=$(background -p x11vnc -noshm -24to32 ${2:+-grabptr -grabkbd} -connect_or_exit "$SERVER:$1")
+    [ "$2" = "True" ] && background ./lock-pointer $X11VNC_PID
 }
 
 # Deactivate the screensaver, in order for the users to watch a broadcast.

=== added file 'epoptes-client/lock-pointer'
--- epoptes-client/lock-pointer	1970-01-01 00:00:00 +0000
+++ epoptes-client/lock-pointer	2015-03-04 13:56:48 +0000
@@ -0,0 +1,52 @@
+#!/bin/sh
+###########################################################################
+# Prevents a local user from moving pointer while getting assisted,
+# if mouse grabbing is enabled. This circumvents a x11vnc limtation where
+# only mouse buttons, not pointer movement, can be grabbed with -grabptr
+# command line option.
+# Usage: lock-pointer <x11vnc PID>
+#
+# Copyright (C) 2015 Laércio de Sousa <laerciosousa@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# On Debian GNU/Linux systems, the complete text of the GNU General
+# Public License can be found in `/usr/share/common-licenses/GPL'.
+###########################################################################
+
+# Get xinput IDs for all local pointer devices
+# found in this seat (excluding virtual XTEST one).
+ids=$(xinput --list | awk '/slave.*pointer/ {
+                              if ($0 !~ /XTEST/) {
+                                  match($0, /id=[0-9]+/)
+                                  if (RSTART)
+                                      print substr($0, RSTART+3, RLENGTH-3)
+                              }
+                           }')
+
+# Lock pointer movement from local devices, slowing them down
+# by a huge factor.
+for id in ${ids}; do
+    xinput --set-prop ${id} "Device Accel Constant Deceleration" 999999
+done
+
+# Wait until given proccess is gone.
+while kill -0 ${1} 2> /dev/null; do
+    sleep 0.5
+done
+
+# Restore pointer movement for local devices.
+for id in ${ids}; do
+    xinput --set-prop ${id} "Device Accel Constant Deceleration" 1
+done