获取 X11 窗口标题高度 [英] Get X11 window caption height
本文介绍了获取 X11 窗口标题高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 X11 中获取窗口的标题/标题高度?我正在使用以下内容来获取边框厚度:
XWindowAttributes wndattr;::XGetWindowAttributes(display, wnd, &wndattr)... = lWndAttr->border_width;
对于标题栏,我似乎找不到任何直截了当的内容.(这个答案似乎暗示我需要通过一种字体,但那不可能是对的,对吧?)
解决方案
答案实际上取决于所使用的窗口管理器,但大多数 WM 将目标窗口重新设置为框架的子窗口,因此算法将是:>
- 走到父窗口,直到到达 root.root 之前的可能是框架
- 将目标窗口矩形与框架矩形进行比较.框架顶部减去目标顶部会给你标题高度
How can I get the title/caption height of a window in X11? I'm using the following to get the border thickness:
XWindowAttributes wndattr;
::XGetWindowAttributes(display, wnd, &wndattr)
... = lWndAttr->border_width;
I can't seem to find anything as straight-forward for the title bar. (This answer seems to imply I need to go through a font, but that can't be right, right?)
解决方案
The answers depends really on the window managers used, but most of the WMs reparent target windows to be child of a frame, so the algorithm would be:
- walk to parent windows until you reach root. The one before root is likely frame
- compare your target window rectangle with frame rectangle. Frame top minus target top would give you caption height
这篇关于获取 X11 窗口标题高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文