我对 XSetWMNormalHints
和 XSetWMSizeHints
感到困惑。我想将窗口设置为不可调整大小,并且调用 XSetWMNormalHints
可以正确完成此操作。但如果我改为调用 XSetWMSizeHints
,则什么也不会发生;窗口的大小仍然可以调整。这两个函数如何用于我的目的?XSetWMSizeHints
到底有什么作用?我已经阅读了多次文档,但我仍然很困惑,所以在这里提问。
sh = XAllocSizeHints();
sh->flags = PMinSize | PMaxSize;
sh->min_width = sh->max_width = 100;
sh->min_height = sh->max_height = 100;
XSetWMNormalHints(d, w, sh);
//XSetWMSizeHints(d, w, sh, PMinSize | PMaxSize);
XFree(sh);
最佳答案
这个问题已经有近 4 年历史了,但这也许可以为其他有类似问题的人澄清。
使用 WM_NORMAL_HINTS 属性调用 XSetWMSizeHints 与 XSetWMNormalHints 执行相同的操作。调用 XSetWMSizeHints 的问题在于“PminSize | PMaxSize”是一个值而不是属性。以下是修改为使用带有属性的 XSetWMSizeHints 的代码。
#include <X11/Xatom.h> // XA_WM_NORMAL_HINTS
...
sh = XAllocSizeHints();
sh->flags = PMinSize | PMaxSize;
sh->min_width = sh->max_width = 100;
sh->min_height = sh->max_height = 100;
//XSetWMNormalHints(d, w, sh);
XSetWMSizeHints(d, w, sh, XA_WM_NORMAL_HINTS);
XFree(sh);
关于c++ - `XSetWMNormalHints` 和 `XSetWMSizeHints`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30994485/