XCreateWindow 在 CentOS 5.6 上失败并出现错误:BadValue

发布于 2024-11-05 10:26:27 字数 1474 浏览 4 评论 0原文

我使用以下代码为一些集成测试创建一个假窗口:

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);
    }
};

上面是原始代码的修改版本,以占用更少的空间(请参阅完整源代码)。

上面的代码在 CentOS 5.6 上间歇性失败,并出现以下错误:

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

那么,实际上有两个问题:

  • 什么可能导致 XCreateWindow 在 CentOS 上以这种方式间歇性失败?
  • 而且,我对 X 开发相当陌生,所以我不知道各种错误值的含义(例如失败请求中的值)或如何使用它们。有人可以为我简要解释一下这些吗?

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:

  • 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烛影斜 2024-11-12 10:26:27

您正在使用CWEventMask,但未初始化attr.event_mask。这可能是你的问题。 (由于该结构是在堆栈上创建的,因此它将在该字段中包含随机数据。)

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文