我是 x11 调用的新手。
我正在 SLED11 上使用 QT 4.8 开发自定义应用程序工具栏。
我在将工具栏定位到通过 x11 调用(_NET_WM_STRUT 和 _NET_WM_STRUT_PARTIAL)获得的保留空间时遇到问题
看一些论坛我了解到我必须保留工具栏区域以便其他应用程序窗口无法覆盖它。我使用了 _NET_WM_STRUT 和 _NET_WM_STRUT_PARTIAL。
这是我用来预留空间的代码:
void ToolbarWindow::dock(int width, int height)
{
Display *display = QX11Info::display();
int insets[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
insets[2] = height;
insets[8] = 0;
insets[9] = width;
XChangeProperty(display,
winId(),
XInternAtom(QX11Info::display(), "_NET_WM_STRUT", False),
XA_CARDINAL ,
32,
PropModeReplace,
(unsigned char *)&insets, 4);
XChangeProperty(display,
winId(),
XInternAtom(QX11Info::display(), "_NET_WM_STRUT_PARTIAL", False),
XA_CARDINAL ,
32,
PropModeReplace,
(unsigned char *)&insets, 12);
}
这是我在创建工具栏时对 GUI Controller 的调用:
ToolbarWindow *toolbar = new ToolbarWindow(co);
toolbar->setGeometry(monitor->getX(), monitor->getY(), monitor->getWidth(), 170);
toolbar->show();
toolbar->dock(monitor->getWidth(), 170);
我看到的是保留空间,但我的工具栏出现在保留区域下方。 但这不是我想要的,我想让所有其他窗口都留在下面(即使最大化)但不是我的工具栏......我为它保留了空间并且我希望它填充那个空间......
谁能帮帮我?
谢谢。
最佳答案
纳米'答案正确。
I have found that for this to work reliably, the window should be of type _NET_WM_TYPE_DOCK and you must first map it then move it to position, otherwise the WM may sometimes place it outside of it own strut. – n.m.
这是我添加的代码:
Atom tmp = XInternAtom(display, "_NET_WM_WINDOW_TYPE_DOCK", False);
XChangeProperty(display,
winId(),
XInternAtom(display, "_NET_WM_WINDOW_TYPE", False),
XA_ATOM ,
32,
PropModeReplace,
(unsigned char *)&tmp, 1);
非常感谢。
关于qt - 在使用 _NET_WM_STRUT 和 _NET_WM_STRUT_PARTIAL 获得的保留桌面空间上定位工具栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27927433/