Function x11rb::protocol::xproto::change_gc

source ·
pub fn change_gc<'c, 'input, Conn>(
    conn: &'c Conn,
    gc: Gcontext,
    value_list: &'input ChangeGCAux
) -> Result<VoidCookie<'c, Conn>, ConnectionError>
where Conn: RequestConnection + ?Sized,
Expand description

change graphics context components.

Changes the components specified by value_mask for the specified graphics context.

Fields

  • gc - The graphics context to change.
  • value_mask -
  • value_list - Values for each of the components specified in the bitmask value_mask. The order has to correspond to the order of possible value_mask bits. See the example.

Errors

  • Font - TODO: reasons?
  • GContext - TODO: reasons?
  • Match - TODO: reasons?
  • Pixmap - TODO: reasons?
  • Value - TODO: reasons?
  • Alloc - The X server could not allocate the requested resources (no memory?).

Example

/*
 * Changes the foreground color component of the specified graphics context.
 *
 */
void my_example(xcb_connection_t *conn, xcb_gcontext_t gc, uint32_t fg, uint32_t bg) {
    /* C99 allows us to use a compact way of changing a single component: */
    xcb_change_gc(conn, gc, XCB_GC_FOREGROUND, (uint32_t[]){ fg });

    /* The more explicit way. Beware that the order of values is important! */
    uint32_t mask = 0;
    mask |= XCB_GC_FOREGROUND;
    mask |= XCB_GC_BACKGROUND;

    uint32_t values[] = {
        fg,
        bg
    };
    xcb_change_gc(conn, gc, mask, values);
    xcb_flush(conn);
}