📄 pointer-grabbing.html
字号:
<HTML><HEAD><TITLE>Xlib Programming Manual: Pointer Grabbing</TITLE></HEAD><BODY><H1 ALIGN=center>12.1 Pointer Grabbing</H1>Xlib provides functions that you can use to control input from the pointer,which usually is a mouse.Usually, as soon as keyboard and mouse events occur,the X server delivers them to the appropriate client,which is determined by the window and input focus.The X server provides sufficient control over event delivery toallow window managers to support mouse ahead and various otherstyles of user interface.Many of these user interfaces depend upon synchronous delivery of events.The delivery of pointer and keyboard events can be controlledindependently.<P>When mouse buttons or keyboard keys are grabbed, eventswill be sent to the grabbing client rather than the normalclient who would have received the event.If the keyboard or pointer is in asynchronous mode,further mouse and keyboard events will continue to be processed.If the keyboard or pointer is in synchronous mode, nofurther events are processed until the grabbing clientallows them (see<B><A HREF="XAllowEvents.html">XAllowEvents()</A></B>).The keyboard or pointer is considered frozen during thisinterval.The event that triggered the grab can also be replayed.<P>Note that the logical state of a device (as seen by client applications)may lag the physical state if device event processing is frozen.<A NAME="active-grab"></A><A NAME="passive-grab"></A><P><!.IN "Active grab" "" "@DEF@">There are two kinds of grabs:active and passive.An active grab occurs when a single client grabs the keyboard and/or pointerexplicitly (see<B><A HREF="XGrabPointer.html">XGrabPointer()</A></B>and<B><A HREF="XGrabKeyboard.html">XGrabKeyboard()</A></B>).<!.IN "Passive grab">A passive grab occurs when clients grab a particular keyboard key or pointer button in a window,and the grab will activate when the key or button is actually pressed.Passive grabs are convenient for implementing reliable pop-up menus.For example, you can guarantee that the pop-up is mapped before the up pointer button event occurs bygrabbing a button requesting synchronous behavior.The down event will trigger the grab and freeze furtherprocessing of pointer events until you have the chance tomap the pop-up window.You can then allow further event processing.The up event will then be correctly processed relative to thepop-up window.<A NAME="Time"><P>For many operations,there are functions that take a time argument.The X server includes a timestamp in various events.One special time, called<!.IN "CurrentTime" "" "@DEF@"><!.IN "Time" "" "@DEF@"><B>CurrentTime</B>,represents the current server time.The X server maintains the time when the input focus was last changed,when the keyboard was last grabbed,when the pointer was last grabbed,or when a selection was last changed.Yourapplication may be slow reacting to an event.You often need some way to specify that yourrequest should not occur if another application has in the meanwhiletaken control of the keyboard, pointer, or selection.By providing the timestamp from the event in the request, you can arrange that the operation not take effectif someone else has performed an operation in the meanwhile.<P>A timestamp is a time value, expressed in milliseconds. It typically is the time since the last server reset.Timestamp values wrap around (after about 49.7 days).The server, given its current time is represented by timestamp T, always interprets timestamps from clients by treating half of the timestamp space as being later in time than T.One timestamp value, named<B>CurrentTime</B>,is never generated by the server.This value is reserved for use in requests to represent the current server time.<P>For many functions in this section,you pass pointer event mask bits.The valid pointer event mask bits are:<B><A HREF="../events/processing-overview.html#ButtonPressMask">ButtonPressMask</A></B>,<B><A HREF="../events/processing-overview.html#ButtonReleaseMask">ButtonReleaseMask</A></B>,<B><A HREF="../events/processing-overview.html#EnterWindowMask">EnterWindowMask</A></B>,<B><A HREF="../events/processing-overview.html#LeaveWindowMask">LeaveWindowMask</A></B>,<B><A HREF="../events/processing-overview.html#PointerMotionMask">PointerMotionMask</A></B>,<B><A HREF="../events/processing-overview.html#PointerMotionHintMask">PointerMotionHintMask</A></B>,<B><A HREF="../events/processing-overview.html#Button1MotionMask">Button1MotionMask</A></B>,<B><A HREF="../events/processing-overview.html#Button2MotionMask">Button2MotionMask</A></B>,<B><A HREF="../events/processing-overview.html#Button3MotionMask">Button3MotionMask</A></B>,<B><A HREF="../events/processing-overview.html#Button4MotionMask">Button4MotionMask</A></B>,<B><A HREF="../events/processing-overview.html#Button5MotionMask">Button5MotionMask</A></B>,<B><A HREF="../events/processing-overview.html#ButtonMotionMask">ButtonMotionMask</A></B>,and<B><A HREF="../events/processing-overview.html#KeymapStateMask">KeymapStateMask</A></B>.For other functions in this section,you pass keymask bits.The valid keymask bits are:<B>ShiftMask</B>,<B>LockMask</B>,<B>ControlMask</B>,<B>Mod1Mask</B>,<B>Mod2Mask</B>,<B>Mod3Mask</B>,<B>Mod4Mask</B>,and<B>Mod5Mask</B>.<P>To grab the pointer, use<B><A HREF="XGrabPointer.html">XGrabPointer()</A></B>.<P>To ungrab the pointer, use<B><A HREF="XUngrabPointer.html">XUngrabPointer()</A></B>.<P>To change an active pointer grab, use<B><A HREF="XChangeActivePointerGrab.html">XChangeActivePointerGrab()</A></B>.<P>To grab a pointer button, use<B><A HREF="XGrabButton.html">XGrabButton()</A></B>.<P>To ungrab a pointer button, use<B><A HREF="XUngrabButton.html">XUngrabButton()</A></B>.<H5 ALIGN=right><I>Next: <A HREF="keyboard-grabbing.html">Keyboard Grabbing</A></I></H5><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 + -