gpt4 book ai didi

unix - X11。如何知道 window 的完整尺寸(及其装饰物的尺寸)

转载 作者:行者123 更新时间:2023-12-02 13:23:01 27 4
gpt4 key购买 nike

我想检索 X11 中任何窗口的完整大小,以便自动调整其大小。

到目前为止我已经使用了wmctrl,但大小似乎不完整。例如

>$ 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

Kicker 高度为 40,屏幕分辨率为 1920x1200,因此如果我想调整 Konsole 的大小以占据所有屏幕,但 Kicker 的大小应为 1920x1160 (1200-40)。

但是当我这样做时,Konsole 会与踢球尺寸重叠。所以我认为这意味着这里可能不考虑 window 装饰。

我怎样才能知道我必须添加到 wmctrl 给定的窗口大小中的装饰的大小?

谢谢

最佳答案

$ 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

关于unix - X11。如何知道 window 的完整尺寸(及其装饰物的尺寸),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6372734/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com