linux-window-session-manager
linux-window-session-manager copied to clipboard
GTK-3 (in xfce4) need to have there X and Y coordinates adjusted for restoring.
BUG: When restoring in XFCE4 (Not sure about other DE) any app that is GTK-3 will adjust oddly on the x/y axis. When doing some debugging I noticed that GTK-3 apps will restore further down on the y access till I found if I subtract the titlebar size then it's fine. Below is a script I used to detect whether an app is GTK or not, if GTK then subtract the titlebar and border appropriately. Then restoring with these coordinates work.
Not sure if this is an option you can add to the config to detect and turn on or off for different DE's.
#!/bin/bash
entire=true
aw=$(xdotool getactivewindow)
pid=$(xdotool getactivewindow getwindowpid)
eval $(xwininfo -id "$aw" |
sed -n -e "s/^ \+Absolute upper-left X: \+\([0-9]\+\).*/x=\1/p" \
-e "s/^ \+Absolute upper-left Y: \+\([0-9]\+\).*/y=\1/p" \
-e "s/^ \+Width: \+\([0-9]\+\).*/w=\1/p" \
-e "s/^ \+Height: \+\([0-9]\+\).*/h=\1/p" )
if [ "$entire" = true ]
then
extents=$(xprop _NET_FRAME_EXTENTS -id "$aw" | grep "NET_FRAME_EXTENTS" | cut -d '=' -f 2 | tr -d ' ')
bl=$(echo $extents | cut -d ',' -f 1) # width of left border
br=$(echo $extents | cut -d ',' -f 2) # width of right border
t=$(echo $extents | cut -d ',' -f 3) # height of title bar
bb=$(echo $extents | cut -d ',' -f 4) # height of bottom border
gtk=$(grep -Poi '\b(lib)?\K(gtk|qt|tk)([^a-z/]*\d)*(?=[^/]*\.so\b)' /proc/$pid/maps | sort -u)
if [ -z "$gtk" ]
then
gtkyn="no"
let nx=$x
let ny=$y
let nw=$w
let nh=$h
else
gtkyn="yes"
let nx=$x-$bl-$br
let ny=$y-$t
let nw=$w
let nh=$h
fi
fi
echo "ID=$aw"
echo "GTK Type=$gtk"
echo "GTK=$gtkyn"
echo ""
echo "x=$x"
echo "y=$y"
echo "w=$w"
echo "h=$h"
echo ""
echo "t=$t"
echo "bl=$bl"
echo "br=$br"
echo "bb=$bb"
echo ""
echo "nx=$nx"
echo "ny=$ny"
echo "nw=$nw"
echo "nh=$nh"