我有一个带有此代码的Qt Widget:
this->setAttribute(Qt::WA_X11NetWmWindowTypeDock, true);
unsigned long desstrut[12];
memset(desstrut,0,sizeof(desstrut));
desstrut[0] = 0; desstrut[1] = 0;
desstrut[2] = 32; desstrut[3] = 0;
desstrut[4] = 0; desstrut[5] = 0;
desstrut[6] = 0; desstrut[7] = 0;
desstrut[8] = 0; desstrut[9] = 1366;
desstrut[10] = 0; desstrut[11] = 0;
const char* atomName1 = "_NET_WM_STRUT_PARTIAL";
Atom atom1 = XInternAtom(QX11Info::display(), atomName1, false);
XChangeProperty(QX11Info::display(), (unsigned long) this->winId(), atom1,
XA_CARDINAL, 32, PropModeReplace, (unsigned char *) desstrut, 12 );
const char* atomName2 = "_NET_WM_STRUT";
Atom atom2 = XInternAtom(QX11Info::display(), atomName2, false);
XChangeProperty(QX11Info::display(), (unsigned long) this->winId(), atom2,
XA_CARDINAL, 32, PropModeReplace, (unsigned char*) desstrut, 4);
我尝试在Qt Quick项目中编写相同的想法:
Display *display = QX11Info::display();
QObject* rootObject = engine.rootObjects().first();
QWindow *window = qobject_cast<QWindow *>(rootObject);
unsigned long windowId = window->winId();
Atom _NET_WM_WINDOW_TYPE = XInternAtom(display, "_NET_WM_WINDOW_TYPE", false);
long _NET_WM_WINDOW_TYPE_DOCK = XInternAtom(display, "_NET_WM_WINDOW_TYPE_DOCK", false);
XChangeProperty(display, windowId, _NET_WM_WINDOW_TYPE,
XA_ATOM, 32, PropModeReplace, (unsigned char *) &_NET_WM_WINDOW_TYPE_DOCK, 1);
unsigned long strutPartial[12] = {
0, 0, 32, 0,
0, 0, 0, 0,
0, 1366, 0, 0
};
Atom _NET_WM_STRUT_PARTIAL = XInternAtom(display, "_NET_WM_STRUT_PARTIAL", false);
XChangeProperty(display, windowId, _NET_WM_STRUT_PARTIAL,
XA_CARDINAL, 32, PropModeReplace, (unsigned char *) strutPartial, 12 );
Atom _NET_WM_STRUT = XInternAtom(display, "_NET_WM_STRUT", false);
XChangeProperty(display, windowId, _NET_WM_STRUT,
XA_CARDINAL, 32, PropModeReplace, (unsigned char*) strutPartial, 4);
但它不起作用:我的窗口不会成为面板。 有人可以帮我吗?