开发者

XCreateWindow fails on CentOS 5.6 with error: BadValue

开发者 https://www.devze.com 2023-03-04 20:54 出处:网络
I\'m using the following code to create a fake window for some integration tests: class CXWindowsClipboardTests

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 orig开发者_开发知识库inal 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:

  • What could cause XCreateWindow to fail on CentOS intermittently in this way?
  • And, I'm fairly new to X development, so I have no idea what the various error values mean (e.g. Value in failed request) or how to use them. Could someone briefly explain these for me?


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.)

0

精彩评论

暂无评论...
验证码 换一张
取 消