From acd92160c3d51ffac68c458d1d659bd9660fcfdc Mon Sep 17 00:00:00 2001 From: angelic-sedition Date: Sun, 15 Feb 2015 23:18:09 -0500 Subject: [PATCH] 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. --- tdrop | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tdrop b/tdrop index 40babde..c61ad7c 100755 --- a/tdrop +++ b/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 }