---
name: "xcb_set_input_focus"
section: "3"
platform: "linux"
package: "libxcb"
version: "1.17.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/xcb_set_input_focus"
---

# xcb\_set\_input\_focus(3)

Sets input focus

## NAME

xcb\_set\_input\_focus - Sets input focus

## SYNOPSIS

**#include \<xcb/xproto.h\>**

### Request function

xcb\_void\_cookie\_t **xcb\_set\_input\_focus**(xcb\_connection\_t \**conn*, uint8\_t *revert\_to*, xcb\_window\_t *focus*, xcb\_timestamp\_t *time*);\

## REQUEST ARGUMENTS

- *conn*

  The XCB connection to X11.

- *revert\_to*

  One of the following values:

  - *XCB\_INPUT\_FOCUS\_NONE*

    The focus reverts to *XCB\_NONE*, so no window will have the input focus.

  - *XCB\_INPUT\_FOCUS\_POINTER\_ROOT*

    The focus reverts to *XCB\_POINTER\_ROOT* respectively. When the focus reverts, FocusIn and FocusOut events are generated, but the last-focus-change time is not changed.

  - *XCB\_INPUT\_FOCUS\_PARENT*

    The focus reverts to the parent (or closest viewable ancestor) and the new revert\_to value is *XCB\_INPUT\_FOCUS\_NONE*.

  - *XCB\_INPUT\_FOCUS\_FOLLOW\_KEYBOARD*

    NOT YET DOCUMENTED. Only relevant for the xinput extension.

  Specifies what happens when the *focus* window becomes unviewable (if *focus* is neither *XCB\_NONE* nor *XCB\_POINTER\_ROOT*).

- *focus*

  The window to focus. All keyboard events will be reported to this window. The window must be viewable (TODO), or a *xcb\_match\_error\_t* occurs (TODO).

  If *focus* is *XCB\_NONE* (TODO), all keyboard events are discarded until a new focus window is set.

  If *focus* is *XCB\_POINTER\_ROOT* (TODO), focus is on the root window of the screen on which the pointer is on currently.

- *time*

  Timestamp to avoid race conditions when running X over the network.

  The special value *XCB\_CURRENT\_TIME* will be replaced with the current server time.

## DESCRIPTION

Changes the input focus and the last-focus-change time. If the specified *time* is earlier than the current last-focus-change time, the request is ignored (to avoid race conditions when running X over the network).

A FocusIn and FocusOut event is generated when focus is changed.

## RETURN VALUE

Returns an *xcb\_void\_cookie\_t*. Errors (if any) have to be handled in the event loop.

If you want to handle errors directly with *xcb\_request\_check* instead, use *xcb\_set\_input\_focus\_checked*. See **[xcb-requests(3)](/xcb-requests/3.md)** for details.

## ERRORS

- *xcb\_match\_error\_t*

  The specified *focus* window is not viewable.

- *xcb\_value\_error\_t*

  TODO: Reasons?

- *xcb\_window\_error\_t*

  The specified *focus* window does not exist.

## SEE ALSO

[**xcb-requests**(3)](/xcb-requests/3.md), [**xcb\_focus\_in\_event\_t**(3)](/xcb_focus_in_event_t/3.md), **xcb\_focus\_out\_event\_t**(3)

## AUTHOR

Generated from xproto.xml. Contact xcb@lists.freedesktop.org for corrections and improvements.
