I'm using the following code to create a fake window for some integration tests:
class CXWindowsClipboardTests
{
protected:
virtual void
SetUp()
{
m_display = XOpenDisplay(NULL);
int screen = DefaultScreen(m_display);
Window root = XRootWindow(m_display, screen);
XSetWindowAttributes attr;
attr.do_not_propagate_mask = 0;
attr.override_redirect = True;
attr.cursor = Cursor();
m_window = XCreateWindow(
m_display, root, 0, 0, 1, 1, 0, 0,
InputOnly, CopyFromParent,
CWDontPropagate | CWEventMask |
CWOverrideRedirect | CWCursor,
&attr);
}
virtual void
TearDown()
{
XDestroyWindow(m_display, m_window);
XCloseDisplay(m_display);
}
};
The above is a modified version of original code to take up less space (see full source code).
The above code fails intermittently on CentOS 5.6 with the following error:
X Error of failed request: BadValue
(integer parameter out of range for operation)
Major opcode of failed request: 1 (X_CreateWindow)
Value in failed request: 0x844b530
Serial number of failed request: 7
Current serial number in output stream: 8
So, two questions really:
You're using the CWEventMask
but not initializing attr.event_mask
. This could be your problem. (since the structure is created on stack, it'll contain random data in that field.)