qt - 在使用 _NET_WM_STRUT 和 _NET_WM_STRUT_PARTIAL 获得的保留桌面空间上定位工具栏

标签 qt x11 xlib xserver

我是 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/

相关文章:

c++ - 如何克服屏幕外和屏幕上帧缓冲区渲染之间的差异?

qt - 如何在小部件中显示 QColorDialog 中的 QColor?

c++ - 如何在 C++/Qt 中设置 30fps 循环

c - 如何退出xlib的XNextEvent的阻塞

x11 - 如何通过 Xlib 观察连接显示器的变化?

c - 同时访问一个 c union 的不同成员

qt - 将 Qt 默认编码设置为 UTF-8

perl - Perl 中的 SSH 与 X11 转发

macos - 是否有固定 6x13 位图字体的空白较少(行距 0.8)的版本?

ubuntu - 新应用程序在 Ubuntu 的错误 x 屏幕中打开