1xcb_grab_keyboard(3)             XCB Requests             xcb_grab_keyboard(3)
2
3
4

NAME

6       xcb_grab_keyboard - Grab the keyboard
7

SYNOPSIS

9       #include <xcb/xproto.h>
10
11   Request function
12       xcb_grab_keyboard_cookie_t xcb_grab_keyboard(xcb_connection_t *conn,
13              uint8_t owner_events, xcb_window_t grab_window,
14              xcb_timestamp_t time, uint8_t pointer_mode,
15              uint8_t keyboard_mode);
16
17   Reply datastructure
18       typedef struct xcb_grab_keyboard_reply_t {
19           uint8_t  response_type;
20           uint8_t  status;
21           uint16_t sequence;
22           uint32_t length;
23       } xcb_grab_keyboard_reply_t;
24
25   Reply function
26       xcb_grab_keyboard_reply_t
27              *xcb_grab_keyboard_reply(xcb_connection_t *conn,
28              xcb_grab_keyboard_cookie_t cookie, xcb_generic_error_t **e);
29

REQUEST ARGUMENTS

31       conn      The XCB connection to X11.
32
33       owner_events
34                 If 1, the grab_window will still get the pointer events. If
35                 0, events are not reported to the grab_window.
36
37       grab_window
38                 Specifies the window on which the pointer should be grabbed.
39
40       time      Timestamp to avoid race conditions when running X over the
41                 network.
42
43                 The special value XCB_CURRENT_TIME will be replaced with the
44                 current server time.
45
46       pointer_mode
47                 One of the following values:
48
49                 XCB_GRAB_MODE_SYNC
50                           The state of the keyboard appears to freeze: No
51                           further keyboard events are generated by the server
52                           until the grabbing client issues a releasing Allow‐
53                           Events request or until the keyboard grab is re‐
54                           leased.
55
56                 XCB_GRAB_MODE_ASYNC
57                           Keyboard event processing continues normally.
58
59
60
61       keyboard_mode
62                 One of the following values:
63
64                 XCB_GRAB_MODE_SYNC
65                           The state of the keyboard appears to freeze: No
66                           further keyboard events are generated by the server
67                           until the grabbing client issues a releasing Allow‐
68                           Events request or until the keyboard grab is re‐
69                           leased.
70
71                 XCB_GRAB_MODE_ASYNC
72                           Keyboard event processing continues normally.
73
74
75

REPLY FIELDS

77       response_type
78                 The type of this reply, in this case XCB_GRAB_KEYBOARD. This
79                 field is also present in the xcb_generic_reply_t and can be
80                 used to tell replies apart from each other.
81
82       sequence  The sequence number of the last request processed by the X11
83                 server.
84
85       length    The length of the reply, in words (a word is 4 bytes).
86
87       status    One of the following values:
88
89                 XCB_GRAB_STATUS_SUCCESS
90                           TODO: NOT YET DOCUMENTED.
91
92                 XCB_GRAB_STATUS_ALREADY_GRABBED
93                           TODO: NOT YET DOCUMENTED.
94
95                 XCB_GRAB_STATUS_INVALID_TIME
96                           TODO: NOT YET DOCUMENTED.
97
98                 XCB_GRAB_STATUS_NOT_VIEWABLE
99                           TODO: NOT YET DOCUMENTED.
100
101                 XCB_GRAB_STATUS_FROZEN
102                           TODO: NOT YET DOCUMENTED.
103                 TODO: NOT YET DOCUMENTED.
104

DESCRIPTION

106       Actively grabs control of the keyboard and generates FocusIn and Focu‐
107       sOut events. Further key events are reported only to the grabbing
108       client.
109
110       Any active keyboard grab by this client is overridden. If the keyboard
111       is actively grabbed by some other client, AlreadyGrabbed is returned.
112       If grab_window is not viewable, GrabNotViewable is returned. If the
113       keyboard is frozen by an active grab of another client, GrabFrozen is
114       returned. If the specified time is earlier than the last-keyboard-grab
115       time or later than the current X server time, GrabInvalidTime is re‐
116       turned. Otherwise, the last-keyboard-grab time is set to the specified
117       time.
118

RETURN VALUE

120       Returns an xcb_grab_keyboard_cookie_t. Errors have to be handled when
121       calling the reply function xcb_grab_keyboard_reply.
122
123       If you want to handle errors in the event loop instead, use
124       xcb_grab_keyboard_unchecked. See xcb-requests(3) for details.
125

ERRORS

127       xcb_value_error_t
128                 TODO: reasons?
129
130       xcb_window_error_t
131                 The specified window does not exist.
132

EXAMPLE

134       /*
135        * Grabs the keyboard actively
136        *
137        */
138       void my_example(xcb_connection_t *conn, xcb_screen_t *screen) {
139           xcb_grab_keyboard_cookie_t cookie;
140           xcb_grab_keyboard_reply_t *reply;
141
142           cookie = xcb_grab_keyboard(
143               conn,
144               true,                /* report events */
145               screen->root,        /* grab the root window */
146               XCB_CURRENT_TIME,
147               XCB_GRAB_MODE_ASYNC, /* process events as normal, do not require sync */
148               XCB_GRAB_MODE_ASYNC
149           );
150
151           if ((reply = xcb_grab_keyboard_reply(conn, cookie, NULL))) {
152               if (reply->status == XCB_GRAB_STATUS_SUCCESS)
153                   printf("successfully grabbed the keyboard\n");
154
155               free(reply);
156           }
157       }
158

SEE ALSO

160       xcb-requests(3), xcb-examples(3), xcb_grab_pointer(3)
161

AUTHOR

163       Generated from xproto.xml. Contact xcb@lists.freedesktop.org for cor‐
164       rections and improvements.
165
166
167
168X Version 11                      libxcb 1.12             xcb_grab_keyboard(3)
Impressum