From 56e4c6c0a424b11c48af11eba28bb6f5a9e1eda0 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sat, 18 Mar 2023 12:51:07 +0000 Subject: [PATCH] bin/xzoomscr: New script and bindings to control XRANDR zoomy panny stuff. --- Makefile | 1 + bin/xzoomscr | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ dot/e16-bindings | 4 ++++ 3 files changed, 56 insertions(+) create mode 100755 bin/xzoomscr diff --git a/Makefile b/Makefile index 4388fe7..e9dc3b7 100644 --- a/Makefile +++ b/Makefile @@ -328,6 +328,7 @@ SCRIPTLINKS += xpra-start-xdummy SCRIPTLINKS += play-rawk SCRIPTLINKS += x2x-privsep SCRIPTLINKS += xduplic-terminal +SCRIPTLINKS += xzoomscr DOTCPP += .Xdefaults Xdefaults_DEFS = -DEMACSWD=$(call mdw-conf,emacs-width,77) diff --git a/bin/xzoomscr b/bin/xzoomscr new file mode 100755 index 0000000..f852297 --- /dev/null +++ b/bin/xzoomscr @@ -0,0 +1,51 @@ +#! /bin/sh -e + +case $# in 1) ;; *) echo >&2 "usage: $1 ZOOM"; exit 2 ;; esac +zoom=$1 + +ok=nil +case ${DISPLAY-nil} in + *:*[!0-9.]*) ;; + *:*.*.*) ;; + *:*.*) ok=t dpybase=${DISPLAY%.*} ;; + *:*) ok=t dpybase=$DISPLAY ;; +esac +case ok in nil) echo >&2 "$0: bad DISPLAY"; exit 2 ;; esac + +set -- $(xqueryptr); scr=$1 x=$2 y=$3 +DISPLAY=$dpybase.$scr; export DISPLAY + +eval $(xscsize -b) + +case $(( $XWIDTH % $zoom || XHEIGHT % $zoom )) in + 0) ;; + *) echo >&2 "$0: zoom multiplier doesn't divide screen size"; exit 2 ;; +esac + +{ read _ + found=nil + while read _ _ respos name; do + res=${respos%%+*} pos=${respos#*+} + ww=${res%x*} hh=${res#*x} + w=${ww%/*} h=${hh%/*} + x0=${pos%+*} y0=${pos#*+} + x1=$(( $x0 + $w )) y1=$(( $y0 + $h )) + case $(( $x0 <= $x && $x < $x1 && $y0 <= $y && $y < $y1 )) in + 1) found=t; break ;; + esac + done +} <&2 "$0: pointer not on any screen?"; exit 2 ;; esac + +case $zoom in + 1) pan= ;; + *) pan="--panning ${XWIDTH}x${XHEIGHT}" ;; +esac + +xrandr --fb ${XWIDTH}x${XHEIGHT} \ + --output $name \ + --mode $(( $XWIDTH/$zoom ))x$(( $XHEIGHT/$zoom )) \ + $pan diff --git a/dot/e16-bindings b/dot/e16-bindings index 5d604c8..593c35c 100644 --- a/dot/e16-bindings +++ b/dot/e16-bindings @@ -41,6 +41,10 @@ KeyDown 5 Up area move 0 -1 KeyDown 5 Down area move 0 1 KeyDown 5 Left area move -1 0 KeyDown 5 Right area move 1 0 +KeyDown C5 1 exec xzoomscr 1 +KeyDown C5 2 exec xzoomscr 2 +KeyDown C5 3 exec xzoomscr 3 +KeyDown C5 4 exec xzoomscr 4 KeyDown C5 a desk arrange KeyDown C5 c cm start KeyDown C5 d exec xfce4-display-settings -- 2.11.0