开发者

X11. How to know the full size of a window (with the size of its decorations)

I would like to retrieve the complete size of any windows in X11 in order to automatically resize it.

So far I have used wmctrl but the size seems to be incomplete. for instance

>$ wmctrl -lG
0x00e0000f -1 0    0    1920 1200 tclogin1 KDE Desktop
0x010000ee -1 0    1160 1920 40   tclogin1 kicker
0x01200008  0 4    28   1920 1127 tclogin1 ...p7zip_9.13/bin - Shell No. 8 - Konsole
开发者_JS百科

The Kicker height is 40 and the screen resolution is 1920x1200 so If I wanted to resize my Konsole to take all the screen but the kicker its size should be 1920x1160 (1200-40).

But when I do that, the Konsole overlaps the kicker size. So I assume that its means that the windows decorations might not be taken into account here.

How can I know the size of the decorations that I would have to add to the windows size given by wmctrl ?

Thanks


$ cat allborders.sh 
# assumptions:  
#   windows ids are at least 5 digits long
#   we dont need to bother with windows that have no name
#   "first argument" from the pipe is east (could be west)
#   

WINDOW_IDS=`xwininfo -int -root -tree   |\
    grep '[0-9]*\ (has no name)' -v     |\
    grep -Eo '[0-9]{5,}'`

for win in $WINDOW_IDS;
do 
    xprop -id $win |\
        grep -Ee '^(_NET_FRAME_EXTENTS|WM_CLASS)' |\
        sed 's/.*=\ //' |\
        sed -e :a -e '/$/N;s/\n/ /;ta' |\
        grep  ^[0-9]    |\
    while read line;
    do
        set -- $line
        E=`echo $1|sed 's/,$//'`
        W=`echo $2|sed 's/,$//'`
        N=`echo $3|sed 's/,$//'`
        S=`echo $4|sed 's/,$//'`
        NAME=`echo $5|sed 's/,$//'`
        CLASS=`echo $6|sed 's/,$//'`
        echo -e "$CLASS $NAME $N $E $S $W"
    done
done
$ ./allborders.sh 
"URxvt" "urxvt" 1 1 1 1
"XTerm" "aterm" 0 0 0 0
"XTerm" "aterm" 0 0 0 0
"Firefox" "Navigator" 18 1 3 1
"Gmpc" "gmpc" 18 1 3 1
"XTerm" "aterm" 0 0 0 0
"XTerm" "one" 0 0 0 0
"XTerm" "aterm" 0 0 0 0
"XTerm" "one" 0 0 0 0
"XTerm" "aterm" 0 0 0 0
"XTerm" "aterm" 0 0 0 0
"XTerm" "aterm" 0 0 0 0
"XTerm" "aterm" 0 0 0 0
"XTerm" "aterm" 0 0 0 0
"FbPager" "fbpager" 0 0 0 0
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜