如何使用xcb将像素图绘制到根窗口?

时间:2016-12-31 21:12:43

标签: linux window-managers xcb

我试图用壁纸切换器编写一个窗口管理器:

void smoke_change_background(smoke_wm_state_t *config, char *desktop) {
  struct smoke_desktop_list_element_t *node = smoke_desktop_list_node(config->tree, desktop);

  if (node->background != 0) {
    xcb_intern_atom_reply_t *xpmap = xcb_intern_atom_reply(config->connection,
            xcb_intern_atom(config->connection,
                            false,
                            strlen("_X_ROOTPMAP_ID"),
                            "_X_ROOTPMAP_ID"),
            NULL);
    xcb_intern_atom_reply_t *esetr = xcb_intern_atom_reply(config->connection,
            xcb_intern_atom(config->connection,
                            false,
                            strlen("ESETROOT_PMAP_ID"),
                            "ESETROOT_PMAP_ID"),
            NULL);

    xcb_get_property_reply_t *xrepl = xcb_get_property_reply(config->connection,
            xcb_get_property(config->connection,
                             0,
                             config->screen->root,
                             xpmap->atom,
                             XCB_ATOM_PIXMAP,
                             0,
                             32),
            NULL);
    uint32_t *xp = (uint32_t*) xcb_get_property_value(xrepl);

    xcb_get_property_reply_t *erepl = xcb_get_property_reply(config->connection,
            xcb_get_property(config->connection,
                             0,
                             config->screen->root,
                             esetr->atom,
                             XCB_ATOM_PIXMAP,
                             0, 32),
            NULL);
    uint32_t *ep = (uint32_t*) xcb_get_property_value(erepl);

    xcb_change_property(config->connection,
                            XCB_PROP_MODE_REPLACE,
                            config->screen->root,
                            xpmap->atom,
                            XCB_ATOM_PIXMAP,
                            32, 1,
                            (void*) &node->background);
    xcb_change_property(config->connection,
                            XCB_PROP_MODE_REPLACE,
                            config->screen->root,
                            esetr->atom,
                            XCB_ATOM_PIXMAP,
                            32, 1,
                            (void*) &node->background);

    xcb_free_pixmap(config->connection, *xp);
    xcb_free_pixmap(config->connection, *ep);

    uint32_t values[1];
    values[0] = node->background;
    xcb_change_window_attributes(config->connection, config->screen->root, XCB_CW_BACK_PIXMAP, values);

    xcb_clear_area(config->connection, false, config->screen->root, 0, 0, 0, 0);
    xcb_flush(config->connection);
  }
}

此代码应该更改根的pixmap,它应该显示在我的Xephyr窗口中,但事实并非如此。怎么了?

0 个答案:

没有答案
相关问题