【问题标题】:XCreateWindow fails on CentOS 5.6 with error: BadValueXCreateWindow 在 CentOS 5.6 上失败并出现错误:BadValue
【发布时间】:2011-05-08 22:19:53
【问题描述】:

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

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

以上是原代码的修改版,占用空间更小(见full source code)。

以上代码在 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 开发还很陌生,所以我不知道各种错误值的含义(例如,失败请求中的值)或如何使用它们。有人可以为我简要解释一下吗?

【问题讨论】:

    标签: c++ centos xlib x11


    【解决方案1】:

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

    【讨论】:

    • 谢谢。我试图在集成测试中复制真实环境,但由于我只是用剪贴板做事,也许我可以有一个 0 值掩码。
    猜你喜欢
    • 2020-08-31
    • 2017-02-17
    • 2018-02-24
    • 2012-09-24
    • 2016-06-07
    • 2017-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多