I am developing an applications toolbar in QT 4.8.5 (this version is mandatory for my client) on a SLED 11. I am also in a multimonitor environment.
My purpose is to show an extended toolbar on a specified monitor and a reduced one on the others. From the main toolbar is possibile to open different applications installed in the system. These applications can be QT based or not.
In order to make xserver to handle the toolbar as a docking window and reserve the space on the desktop (so the other windows cannot be moved on the toolbar and make the window maximization not cover the toolbar) I used some xlib call.
This is the way I reserved the space:
void ToolbarWindow::dock(int x, int y, int width, int height)
{
#ifdef Q_WS_X11 //only define on Qt 4.X
Display *display = QX11Info::display();
// Change the window type in order to make it DOCK.
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);
// Reserve the space.
// [0]left, [1]right, [2]top, [3]bottom, [4]left_start_y, [5]left_end_y, [6]right_start_y, [7]right_end_y, [8]top_start_x, [9]top_end_x, [10]bottom_start_x, [11]bottom_end_x
long insets[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
insets[2] = height;
insets[8] = x;
insets[9] = x+width;
XChangeProperty(display,
winId(),
XInternAtom(display, "_NET_WM_STRUT", False),
XA_CARDINAL ,
32,
PropModeReplace,
(unsigned char *)&insets, 4);
XChangeProperty(display,
winId(),
XInternAtom(display, "_NET_WM_STRUT_PARTIAL", False),
XA_CARDINAL ,
32,
PropModeReplace,
(unsigned char *)&insets, 12);
#endif
}
Everything seems to work fine, but after some tests I had a big problem with the QT dropdown menu. It seems that, when QT calculate the position of a dropdown it consider the max reserved height independently of the monitor the window is in.
Here there are two images showing the problem.
The first image show that the problem can be test even in QTCreator dropdown menu.
The second image show a test I made in order to see what happened on combobox dropdown on a custom QMainWindow. The problem seems to be the same.
I can also add that moving the window beneath the height of the main toolbar on the second monitor the dropdown position is correct. Moreover other non-QT application DO NOT have this behavior, so I think this is a QT 4.8.5 problem during the dropdown positioning.
I also found similar bugs related to Mac OS X. I do not know if these bugs can be meaningful but I will list them anyway:
- https://bugreports.qt.io/browse/QTBUG-36672
- https://bugreports.qt.io/browse/QTBUG-36984
- https://bugreports.qt.io/browse/QTCREATORBUG-11364
Anyone can help me found out a solution to this problem?
Thanks a lot.