Fix geometry restoration for auto_show

Geometry restoration broke in 056edc6. Now width and height are also
explicitly restored.
performance
noctuid 7 years ago
parent 0facf21df7
commit 36995d1090

36
tdrop

@ -83,7 +83,8 @@ dec_fix=
# pekwm, xfwm4, sawfish, openbox need subtract_when_same to be true # pekwm, xfwm4, sawfish, openbox need subtract_when_same to be true
# for awesome, fluxbox, blackbox, mutter, fvwm, and metacity, the value # for awesome, fluxbox, blackbox, mutter, fvwm, and metacity, the value
# does not matter # does not matter
subtract_when_same=true # set in decoration_settings
subtract_when_same=
is_floating= is_floating=
program_flags= program_flags=
clearwid=false clearwid=false
@ -325,9 +326,12 @@ set_wm() {
} }
decoration_settings() { decoration_settings() {
if [[ -z $subtract_when_same ]] && $auto_detect_wm; then if [[ -z $subtract_when_same ]]; then
if [[ $wm =~ ^(Mutter|GNOME Shell|bspwm|i3|GoomwW)$ ]]; then if $auto_detect_wm \
&& [[ $wm =~ ^(Mutter|GNOME Shell|bspwm|i3|GoomwW)$ ]]; then
subtract_when_same=false subtract_when_same=false
else
subtract_when_same=true
fi fi
fi fi
@ -683,14 +687,14 @@ wid_toggle() {
# * Helper Functions for Auto Hiding/Showing # * Helper Functions for Auto Hiding/Showing
get_geometry() { get_geometry() {
# so that won't float a tiled window later when showing # so that won't float a tiled window later when showing
if is_floating "$1"; then if is_floating "$1" &> /dev/null; then
local wininfo x y rel_x rel_y local wininfo x y rel_x rel_y width height
wininfo=$(xwininfo -id "$1") wininfo=$(xwininfo -id "$1")
x=$(echo "$wininfo" | awk '/Absolute.*X/ {print $4}') x=$(echo "$wininfo" | awk '/Absolute.*X/ {print $4}')
y=$(echo "$wininfo" | awk '/Absolute.*Y/ {print $4}') y=$(echo "$wininfo" | awk '/Absolute.*Y/ {print $4}')
rel_x=$(echo "$wininfo" | awk '/Relative.*X/ {print $4}') rel_x=$(echo "$wininfo" | awk '/Relative.*X/ {print $4}')
rel_y=$(echo "$wininfo" | awk '/Relative.*Y/ {print $4}') rel_y=$(echo "$wininfo" | awk '/Relative.*Y/ {print $4}')
if $subtract_when_same; then if [[ $subtract_when_same != false ]]; then
# behaviour works for most WMs (at least floating ones) # behaviour works for most WMs (at least floating ones)
x=$((x-rel_x)) x=$((x-rel_x))
y=$((y-rel_y)) y=$((y-rel_y))
@ -704,23 +708,27 @@ get_geometry() {
y=$((y-rel_y)) y=$((y-rel_y))
fi fi
fi fi
echo -n -e "X=$x\nY=$y" width=$(xwininfo -id "$(xdotool getactivewindow)" | \
awk '/Width/ {print $2}')
height=$(xwininfo -id "$(xdotool getactivewindow)" | \
awk '/Height/ {print $2}')
echo -n -e "xoff=$x\nyoff=$y\nwidth=$width\nheight=$height"
else else
# window is not floating; don't bother saving geometry # window is not floating; don't bother saving geometry
echo -n "false" echo -n "false"
fi fi
} }
retrieve_geometry() { # set global xoff, yoff, width, and height based on stored values
restore_geometry() {
local x_fix y_fix
eval "$(< "$MUTDROP_PATH"/auto_hidden/geometry)" eval "$(< "$MUTDROP_PATH"/auto_hidden/geometry)"
local x_fix y_fix X Y
if [[ -n $dec_fix ]]; then if [[ -n $dec_fix ]]; then
x_fix=$(echo "$dec_fix" | awk -F "x" '{print $1}') x_fix=$(echo "$dec_fix" | awk -F "x" '{print $1}')
y_fix=$(echo "$dec_fix" | awk -F "x" '{print $2}') y_fix=$(echo "$dec_fix" | awk -F "x" '{print $2}')
X=$((X-x_fix)) xoff=$((xoff-x_fix))
Y=$((Y-y_fix)) yoff=$((yoff-y_fix))
fi fi
echo -n "$X $Y"
} }
toggle_auto_hide() { toggle_auto_hide() {
@ -757,9 +765,7 @@ auto_show() {
wid=$(< "$MUTDROP_PATH"/auto_hidden/wid) wid=$(< "$MUTDROP_PATH"/auto_hidden/wid)
class=$(< "$MUTDROP_PATH"/auto_hidden/class) class=$(< "$MUTDROP_PATH"/auto_hidden/class)
was_floating=$(< "$MUTDROP_PATH"/auto_hidden/geometry) was_floating=$(< "$MUTDROP_PATH"/auto_hidden/geometry)
XY=$(retrieve_geometry "$wid") restore_geometry "$wid"
xoff=$(echo "$XY" | awk '{print $1}')
yoff=$(echo "$XY" | awk '{print $2}')
pre_map "$was_floating" pre_map "$was_floating"
map_and_post_map "$was_floating" map_and_post_map "$was_floating"
fi fi

Loading…
Cancel
Save