If the keyboard_mode argument is _G_r_a_b_M_o_d_e_A_s_y_n_c, keyboard event processing continues as usual. If the keyboard is currently frozen by this client, then processing of keyboard events is resumed. If the keyboard_mode argument is _G_r_a_b_M_o_d_e_S_y_n_c, the state of the keyboard (as seen by client applications) appears to freeze, and the X server generates no further keyboard events until the grabbing client issues a releasing _X_A_l_l_o_w_E_v_e_n_t_s call or until the keyboard grab is released. Actual keyboard changes are not lost while the keyboard is frozen; they are simply queued in the server for later processing.
If pointer_mode is _G_r_a_b_M_o_d_e_A_s_y_n_c, pointer event processing is unaffected by activation of the grab. If pointer_mode is _G_r_a_b_M_o_d_e_S_y_n_c, the state of the pointer (as seen by client applications) appears to freeze, and the X server generates no further pointer events until the grabbing client issues a releasing _X_A_l_l_o_w_E_v_e_n_t_s call or until the keyboard grab is released. Actual pointer changes are not lost while the pointer is frozen; they are simply queued in the server for later processing.
If the keyboard is actively grabbed by some other client, _X_G_r_a_b_K_e_y_b_o_a_r_d fails and returns _A_l_r_e_a_d_y_G_r_a_b_b_e_d. If grab_window is not viewable, it fails and returns _G_r_a_b_N_o_t_V_i_e_w_a_b_l_e. If the keyboard is frozen by an active grab of another client, it fails and returns _G_r_a_b_F_r_o_z_e_n. If the specified time is earlier than the last-keyboard-grab time or later than the current X server time, it fails and returns _G_r_a_b_I_n_v_a_l_i_d_T_i_m_e. Otherwise, the last-keyboard-grab time is set to the specified time (_C_u_r_r_e_n_t_T_i_m_e is replaced by the current X server time).
_X_G_r_a_b_K_e_y_b_o_a_r_d can generate _B_a_d_V_a_l_u_e and _B_a_d_W_i_n_d_o_w errors.
The _X_U_n_g_r_a_b_K_e_y_b_o_a_r_d function releases the keyboard and any queued events if this client has it actively grabbed from either _X_G_r_a_b_K_e_y_b_o_a_r_d or _X_G_r_a_b_K_e_y. _X_U_n_g_r_a_b_K_e_y_b_o_a_r_d does not release the keyboard and any queued events if the specified time is earlier than the last-keyboard-grab time or is later than the current X server time. It also generates _F_o_c_u_s_I_n and _F_o_c_u_s_O_u_t events. The X server automatically performs an _U_n_g_r_a_b_K_e_y_b_o_a_r_d request if the event window for an active keyboard grab becomes not viewable.