📄 xgrabkeyboard.html
字号:
<HTML><HEAD><TITLE>Xlib Programming Manual: XGrabKeyboard</TITLE></HEAD><BODY><H1 ALIGN=center>XGrabKeyboard</H1><H2>Syntax</H2><!.IN "Keyboard" "grabbing"><!.IN "Grabbing" "keyboard"><!.IN "XGrabKeyboard" "" "@DEF@"><CODE><PRE>int XGrabKeyboard(<B>display</B>, <B>grab_window</B>, <B>owner_events</B>, <B>pointer_mode</B>, <B>keyboard_mode</B>, <B>time</B>) <A HREF="../display/opening.html#Display">Display</A> *<B>display</B>; Window <B>grab_window</B>; Bool <B>owner_events</B>; int <B>pointer_mode</B>, <B>keyboard_mode</B>; <A HREF="pointer-grabbing.html#Time">Time</A> <B>time</B>;</PRE></CODE><H2>Arguments</H2><TABLE><TR><TD> <B>display</B><TD> Specifies the connection to the X server.<TR><TD> <B>grab_window</B><TD> Specifies the grab window.<TR><TD> <B>owner_events</B><TD> Specifies a Boolean value that indicates whether the keyboard events are to be reported as usual.<TR><TD> <B>pointer_mode</B><TD> Specifies further processing of pointer events.You can pass <B>GrabModeSync</B> or<B>GrabModeAsync</B>.<TR><TD> <B>keyboard_mode</B><TD> Specifies further processing of keyboard events.You can pass <B>GrabModeSync</B> or<B>GrabModeAsync</B>.<TR><TD> <B>time</B><TD> Specifies the time.You can pass either a timestamp or<B>CurrentTime</B>.</TABLE><H2>Description</H2>The<B>XGrabKeyboard()</B>function actively grabs control of the keyboard and generates<B><A HREF="../events/input-focus/">FocusIn</A></B>and<B><A HREF="../events/input-focus/">FocusOut</A></B>events.Further key events are reported only to thegrabbing client.<B>XGrabKeyboard()</B>overrides any active keyboard grab by this client.If owner_events is <B>False</B>, all generated key events are reported withrespect to grab_window. If owner_events is <B>True</B> and if a generatedkey event would normally be reported to this client, it is reportednormally; otherwise, the event is reported with respect to thegrab_window. Both <B><A HREF="../events/keyboard-pointer/keyboard-pointer.html">KeyPress</A></B> and <B><A HREF="../events/keyboard-pointer/keyboard-pointer.html">KeyRelease</A></B> events are always reported,independent of any event selection made by the client.<P>If the keyboard_mode argument is <B>GrabModeAsync</B>,keyboard event processing continuesas usual. If the keyboard is currently frozen by this client, then processing of keyboard events is resumed.If the keyboard_mode argument is<B>GrabModeSync</B> ,the state of the keyboard (as seen by client applications) appears to freeze,and the X server generates no further keyboard events until thegrabbing client issues a releasing <B><A HREF="XAllowEvents.html">XAllowEvents()</A></B>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.<P>If pointer_mode is <B>GrabModeAsync</B> ,pointer event processing is unaffectedby activation of the grab. If pointer_mode is <B>GrabModeSync</B> ,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 <B><A HREF="XAllowEvents.html">XAllowEvents()</A></B>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.<P>If the keyboard is actively grabbed by some other client,<B>XGrabKeyboard()</B>fails and returns<B>AlreadyGrabbed</B>.If grab_window is not viewable,it fails and returns<B>GrabNotViewable</B>.If the keyboard is frozen by an active grab of another client,it fails and returns<B>GrabFrozen</B>.If the specified time is earlier than the last-keyboard-grab time or later than the current X server time,it fails and returns<B>GrabInvalidTime</B>.Otherwise, the last-keyboard-grab time is set to the specified time(<B>CurrentTime</B> is replaced by the current X server time).<P><B>XGrabKeyboard()</B>can generate<B>BadValue</B>and <B>BadWindow</B> errors.<H2>Diagnostics</H2><TABLE><TR><TD><B>BadValue</B><TD> Some numeric value falls outside the range of values accepted by the request. Unless a specific range is specified for an argument, the full range defined by the argument's type is accepted. Any argument defined as a set of alternatives can generate this error.<TR><TD><B>BadWindow</B><TD>A value for a Window argument does not name a defined Window.</TABLE><H2>See also</H2><B><A HREF="XAllowEvents.html">XAllowEvents()</A></B>,<B><A HREF="XGrabButton.html">XGrabButton()</A></B>,<B><A HREF="XGrabKey.html">XGrabKey()</A></B>,<B><A HREF="XGrabPointer.html">XGrabPointer()</A></B>,<B><A HREF="XUngrabKeyboard.html">XUngrabKeyboard()</A></B>,"<A HREF="keyboard-grabbing.html">Keyboard Grabbing</A>".<HR><ADDRESS><A HREF="http://tronche.com/">Christophe Tronche</A>, <A HREF="mailto:ch.tronche@computer.org">ch.tronche@computer.org</A></ADDRESS></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -