make auto_show mantain previous window position

Originally tried parsing xwininfo's -geometry section output with awk, but signs (+/-) change depending on window position.
Instead, subtract relative from absolute if they are different.
On window managers with decorations/borders they will be different.
long-opts
angelic-sedition 10 years ago
parent fd8fca6913
commit acd92160c3

19
tdrop

@ -194,10 +194,28 @@ auto_hide() {
mkdir -p /tmp/tdrop/auto_hidden
echo "$wid" > /tmp/tdrop/auto_hidden/wid
get_class_name > /tmp/tdrop/auto_hidden/class
wininfo=$(xwininfo -id "$wid")
# save window position
x=$(echo "$wininfo" | awk '/Absolute.*X/ {print $4}')
y=$(echo "$wininfo" | awk '/Absolute.*Y/ {print $4}')
rel_x=$(echo "$wininfo" | awk '/Relative.*X/ {print $4}')
rel_y=$(echo "$wininfo" | awk '/Relative.*Y/ {print $4}')
if [[ $x -ne $rel_x ]]; then
x=$((x-rel_x))
fi
if [[ $y -ne $rel_y ]]; then
y=$((y-rel_y))
fi
echo -e "X=$x\nY=$y" > /tmp/tdrop/auto_hidden/geometry
xdotool windowunmap "$wid"
fi
}
geometry_set() {
eval "$(< /tmp/tdrop/auto_hidden/geometry)"
xdotool windowmove "$1" "$X" "$Y"
}
auto_show() {
no_hide=$(< /tmp/tdrop/auto_hidden/no_hide)
if [[ -z $no_hide ]]; then
@ -206,6 +224,7 @@ auto_show() {
float_pre_command "$class"
xdotool windowmap "$wid"
float_post_command "$wid"
geometry_set "$wid"
fi
}

Loading…
Cancel
Save