[英]Position toolbar on reserved desktop space obtained with _NET_WM_STRUT and _NET_WM_STRUT_PARTIAL
I am new to x11 calls. 我是x11电话的新手。
I am developing a custom applications toolbar using QT 4.8 on a SLED11. 我正在使用SLED11上的QT 4.8开发自定义应用程序工具栏。
I have a problem with positioning my toolbar on a reserved space obtained with x11 call (_NET_WM_STRUT and _NET_WM_STRUT_PARTIAL) 我的工具栏位于通过x11调用(_NET_WM_STRUT和_NET_WM_STRUT_PARTIAL)获得的保留空间上时遇到问题
Looking on some forums I understood that I have to reserve the toolbar area so other application windows cannot cover it. 在一些论坛上浏览时,我了解到我必须保留工具栏区域,以便其他应用程序窗口无法覆盖它。 I used _NET_WM_STRUT and _NET_WM_STRUT_PARTIAL. 我使用了_NET_WM_STRUT和_NET_WM_STRUT_PARTIAL。
This is the code I use for reserving the space: 这是我用来保留空间的代码:
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);
}
And this is my call on the GUI controller when i create the toolbar: 这是我创建工具栏时在GUI控制器上的调用:
ToolbarWindow *toolbar = new ToolbarWindow(co);
toolbar->setGeometry(monitor->getX(), monitor->getY(), monitor->getWidth(), 170);
toolbar->show();
toolbar->dock(monitor->getWidth(), 170);
What I see is that the space is reserved, but my toolbar appear beneath the reserved area. 我看到的是该空间是保留的,但是我的工具栏显示在保留区域的下面 。 But this is not what i want, I would like to have all the other windows to stay beneath (even when maximized) but not my toolbar...i reserved the space for it and I want it to fill that space... 但这不是我想要的,我想让所有其他窗口都留在下面(即使最大化),但我的工具栏也不要...我保留了它的空间,我希望它填充那个空间...
Can anyone help me? 谁能帮我?
Thanks. 谢谢。
The nm' answer is correct. nm'的答案是正确的。
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. 我发现,要使此窗口可靠运行,该窗口的类型应为_NET_WM_TYPE_DOCK,您必须先将其映射,然后将其移动到适当的位置,否则WM有时可能会将其放置在其自身的支撑之外。 – nm –纳米
This is the code I added: 这是我添加的代码:
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);
Thanks a lot. 非常感谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.