¿Cómo hacer que una ventana tenga fobia a los punteros?

¿Cómo hacer que una ventana tenga fobia a los punteros?

Quiero decir que la ventana debería moverse cada vez que intento mover el puntero sobre ella. Tengo un "pantalla de reloj analógico" y un "cuadro de diálogo de progreso del archivo" que modifiqué para permanecer "siempre visible" de otras ventanas con CCSM, pero a veces interfieren en hacer las cosas.

Si eso no es posible, ¿hay algún método para que se oculten cuando muevo el puntero sobre ellos para poder hacer clic en la aplicación directamente debajo?

Además, si eso no es posible, ¿podemos hacer que las ventanas se comporten como si no estuvieran allí? Quiero decir, veré la ventana pero el puntero no debería reconocerla y debería funcionar normalmente en la aplicación que se encuentra debajo. ¿Cambiaré la transparencia de las aplicaciones y haré que funcione si es posible?

Respuesta1

Script Bash y xdotool == cursophobia.sh

Descripción general
Creo que tengo una solución que funcionará para ti. Es un script bash que le permite seleccionar una ventana. Una vez seleccionada una ventana, el script sondea continuamente las posiciones de la ventana y del cursor a intervalos predefinidos. Si el cursor se acerca demasiado, la ventana se aparta.

Dependencia
Este script depende del xdotool. Para instalar, ejecutesudo apt-get install xdotool

El guión: cursophobia.sh
Cree un nuevo script bash con el siguiente contenido y hágalo ejecutable.

#!/bin/bash

windowSelectionDelay=5  # How long to wait for user to select a window?
buffer=10               # How close do we need to be to border to get scared?
jump=20                 # How far do we jump away from pointer when scared?
poll=.25                # How often in seconds should we poll window and mouse?
                        # locations. Increasing poll should lighten CPU load.

# ask user which window to make phobic
for s in $(seq 0 $((windowSelectionDelay - 1)))
do
    clear
    echo "Activate the window that you want to be cursophobic: $((windowSelectionDelay - s))"  
    sleep 1
done
wID=$(xdotool getactivewindow)

# find some boundary info and adjustments
# determine where the window is now
info=$(xdotool getwindowgeometry $wID)
base=$(grep -oP "[\d]+,[\d]+" <<< "$info")

# move the window to 0 0 and get real location
xdotool windowmove $wID 0 0
info=$(xdotool getwindowgeometry $wID)
realMins=$(grep -oP "[\d]+,[\d]+" <<< "$info")
xMin=$(cut -f1 -d, <<< "$realMins")
yMin=$(cut -f2 -d, <<< "$realMins")

# find offset values for no movement. This is necessary because moving 0,0
# relative to the current position sometimes actually moves the window
xdotool windowmove --relative $wID 0 0
info=$(xdotool getwindowgeometry $wID)
diff=$(grep -oP "[\d]+,[\d]+" <<< "$info")
xOffset=$[xMin - $(cut -f1 -d, <<< "$diff")]
yOffset=$[yMin- $(cut -f2 -d, <<< "$diff")]

# move window back to original location
x=$(cut -f1 -d, <<< "$base")
y=$(cut -f2 -d, <<< "$base")
xdotool windowmove $wID $[x + xOffset] $[y + yOffset]

dispSize=$(xdotool getdisplaygeometry)
xMax=$(cut -f1 -d ' ' <<< "$dispSize")
yMax=$(cut -f2 -d ' ' <<< "$dispSize")

clear
echo "You can minimize this window, but don't close it, or your window will overcome its cursophobia"
# start an infinite loop polling to see if we need to move the window.
while :
do
    # get information about where the window is
    info=$(xdotool getwindowgeometry $wID)
    position=$(grep -oP "[\d]+,[\d]+" <<< "$info")
    geometry=$(grep -oP "[\d]+x[\d]+" <<< "$info")
    height=$(cut -f2 -dx <<< "$geometry")
    width=$(cut -f1 -dx <<< "$geometry")
    top=$(cut -f2 -d, <<< "$position")
    left=$(cut -f1 -d, <<< "$position")
    bottom=$((top + height))
    right=$((left + width))

    # save mouse coordinates to x & y
    eval "$(xdotool getmouselocation | cut -f 1-2 -d ' ' | tr ' :' '\n=')"

    # If the mouse is too close to the window, move the window
    if [ $x -gt $((left - buffer)) ] && [ $x -lt $((right + buffer)) ] && [ $y -gt $((top - buffer)) ] && [ $y -lt $((bottom + buffer)) ]; then
        #figure out what side we're closest to so we know which direction to move the window
        t="$((y - top)):0 $((jump + (y - top)))"
        l="$((x - left)):$((jump + (x - left))) 0"
        b="$((bottom - y)):0 -$((jump + (bottom - y)))"
        r="$((right - x)):-$((jump + (right - x))) 0"
        coord="$(echo -e "$t\n$l\n$b\n$r" | sort -n | head -n 1 | cut -f2 -d:)"

        # set the offset values for x and y
        newX=$(cut -f1 -d ' ' <<< "$coord")
        newY=$(cut -f2 -d ' ' <<< "$coord")

        #check to make sure we're not out of bounds
        if [ $((right + newX)) -gt $xMax ]; then
            newX=$((-1 * left + xOffset))
        elif [ $((left + newX)) -lt $xMin ]; then
            newX=$((xMax - width))
        fi
        if [ $((bottom + newY)) -gt $yMax ]; then
            newY=$((-1 * top + yOffset))
        elif [ $((top + newY)) -lt $yMin ]; then
            newY=$((yMax - height))
        fi

        # move the window if it has focus
        [ $(xdotool getactivewindow) -eq $wID ] && xdotool windowmove --relative $wID $((newX + xOffset)) $((newY + yOffset))
    fi
    sleep $poll
done

No olvides editar las cuatro variables en la parte superior a tu gusto. Si este script asigna tareas a su CPU, intente aumentar la pollvariable a un valor mayor.

cursofobia.sh en acción
Una vez que haya creado su script y lo haya hecho ejecutable, ejecútelo. Le pedirá que seleccione una ventana. Haz clic en la ventana en la que quieras tener fobia al cursor y espera hasta que termine la cuenta regresiva. Una vez finalizada la cuenta atrás, la ventana que seleccione será cursorfóbica. Cuando esté listo para ayudar a la ventana a superar su miedo a los cursores, cierre la ventana del terminal o elimine el script desde la ventana del terminal con Ctrl+c

Múltiples pantallas
Tenga en cuenta que esto restringe la ventana cursorfóbica a una sola pantalla. Estoy abierto a modificaciones que hagan que funcione en múltiples pantallas.

información relacionada