<div>Hi,Uli Schlachter, I am so happy reading your reply. The reason I want to know the function is that I have got a problem. I have emailed the problem to petter hutterer(hutterer did not answer the email, QAQ), the following is the whole email: </div><div><br></div><div><div><div><span>"Hi, peter hutterer, </span></div><div><br></div><div>I am very sorry to bother you. I am a debian user in china. </div> <div> <span> I encountered a problem when I was using the computer, the left mouse button would randomly appear to be unresponsive, at that time I thought it might be a hardware problem or a driver problem, or even a kernel problem. However, after my investigation, I found that the mouse device is working normally. The following is the test I did:<br>1. The keyboard can be used, so I use crtl+alt+T to open gnome-terminal, enter xinput test-xi2, press enter, and then click the left mouse button to confirm that gnome-terminal can output the record of mouse click events (thus I think the driver and kernel work well);<br>2. When I input xwininfo in gnome-terminal, the error message "Can't grab the mouse." is displayed. Then I check the xwininfo code: </span> </div></div><div><span>dsimple.c in x11-utils:</span></div><blockquote><div><div><span>xcb_window_t Select_Window(xcb_connection_t *dpy,</span></div></div><div><div><span>   const xcb_screen_t *screen,</span></div></div><div><div><span>   int descend)</span></div></div><div><div><span>{</span></div></div><div><div><span>    xcb_cursor_t cursor;</span></div></div><div><div><span>    xcb_generic_event_t *event;</span></div></div><div><div><span>    xcb_window_t target_win = XCB_WINDOW_NONE;</span></div></div><div><div><span>    xcb_window_t root = screen->root;</span></div></div><div><div><span>    int buttons = 0;</span></div></div><div><div><span>    xcb_generic_error_t *err;</span></div></div><div><div><span>    xcb_grab_pointer_cookie_t grab_cookie;</span></div></div><div><div><span>    xcb_grab_pointer_reply_t *grab_reply;</span></div></div><div><div><span><br></span></div></div><div><div><span>    /* Make the target cursor */</span></div></div><div><div><span>    cursor = Create_Font_Cursor (dpy, XC_crosshair);</span></div></div><div><div><span><br></span></div></div><div><div><span>    /* Grab the pointer using target cursor, letting it room all over */</span></div></div><div><div><span>    grab_cookie = xcb_grab_pointer</span></div></div><div><div><span> (dpy, False, root,</span></div></div><div><div><span> XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE,</span></div></div><div><div><span> XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC,</span></div></div><div><div><span> root, cursor, XCB_TIME_CURRENT_TIME);</span></div></div><div><div><span>    grab_reply = xcb_grab_pointer_reply (dpy, grab_cookie, &err);</span></div></div><div><div><span>    if (grab_reply->status != XCB_GRAB_STATUS_SUCCESS)</span></div></div><div><div><span> Fatal_Error ("<span>Can't grab the mouse.</span>");</span></div></div></blockquote><font color="#0061ff"><span>xwininfo uses the libxcb library to communicate with xserver, and xserver cannot grab the mouse at this point.</span></font><div><font color="#242424">I had a hard time understanding the meaning of "Can't grab the mouse." So I searched the Internet for relevant information and found your previous blog post high-level-overview-of-grabs.</font></div><div><font color="#242424">I wonder if the xserver lost the cursor of the mouse and caused this problem (I am not a professional X user, so my understanding may be wrong, please point out any mistakes in my statement). This issue can be remedied in the following ways:<br>1. Use crtl+alt+F1 to switch to tty1, then use crtl+alt+F7 to switch to tty7, everything returns to normal, the left mouse button can normally click any window or function on the desktop;<br>2. When using a laptop, tap the touchpad to recover (this issue also occurs on my desktop).</font></div><div><font color="#242424"><br></font></div><div><font color="#242424">I hope your rich X input experience can help me find a solution. I would like to express my highest respect to you here. Thank you.</font></div><div><font color="#242424"><br></font></div><div><font color="#242424">Yours sincerely."</font></div>​<br></div><div>so I hope knowing about the xcb function will help resolving my problem. If you know anything about it,please tell me,thank you.</div><div><br></div><div>Yours sincerely.</div><div id="imail_signature" class="ntes-signature"></div><div class="ntes-mailmaster-quote" style="padding-top: 1px; padding-bottom: 1px"><div style="margin-top: 2em;margin-bottom: 1em;font-size: 14px;line-height: 1.25;color: #78787a;">---- Replied Message ----</div><div style="margin-bottom: 1em;font-size: 12px;line-height: 1.25;color: #232324;padding: 0.5em 0.25em;border-radius: 0.67em;background-color: #f0f0f0;"><table width="100%" cellpadding="0" cellspacing="9" border="0"><tbody><tr><td valign="top" style="width: 4.25em;font-size: 12px;line-height: 1.25;color: #78787a;"><span style="color:#8b8d94">From</span></td><td valign="top" style="font-size: 12px;line-height: 1.25;color: #232324;word-break: break-all;"><a class="mail-from" style="color: #0886e8; text-decoration: none" href="mailto:psychon@znc.in">Uli Schlachter<psychon@znc.in></a></td></tr><tr><td valign="top" style="width: 4.25em;font-size: 12px;line-height: 1.25;color: #78787a;"><span style="color:#8b8d94">Date</span></td><td class="mail-date" valign="top" style="font-size: 12px;line-height: 1.25;color: #232324;word-break: break-all;"><span class="mail-date" style="color:black">01/02/2024 13:49</span></td></tr><tr><td valign="top" style="width: 4.25em;font-size: 12px;line-height: 1.25;color: #78787a;"> <span style="color:#8b8d94">To</span></td><td valign="top" style="font-size: 12px;line-height: 1.25;color: #232324;word-break: break-all;"><a class="mail-to" style="color: #0886e8; text-decoration: none" href="mailto:starcold14@gmail.com">starcold14<starcold14@gmail.com></a></td></tr><tr><td valign="top" style="width: 4.25em;font-size: 12px;line-height: 1.25;color: #78787a;"> <span style="color:#8b8d94">Cc</span></td><td valign="top" style="font-size: 12px;line-height: 1.25;color: #232324;word-break: break-all;"><a class="mail-cc" style="color: #0886e8; text-decoration: none" href="mailto:xcb@lists.freedesktop.org">xcb@lists.freedesktop.org<xcb@lists.freedesktop.org></a></td></tr><tr><td valign="top" style="width: 4.25em;font-size: 12px;line-height: 1.25;color: #78787a;"><span style="color:#8b8d94">Subject</span></td><td class="mail-subject" valign="top" style="font-size: 12px;line-height: 1.25;color: #232324;word-break: break-all;"><span class="mail-subject" style="color:black">Re: A problem about reading the source code</span></td></tr></tbody></table></div><div>Hi,
<br />
<br />Am 01.01.24 um 14:39 schrieb starcold14:
<br />> Hi,Uli Schlachter,
<br />> I am very grateful for your reply.
<br />> I am now a little confused about the XML specification. I cannot understand how
<br />> the XML specification describes a function like xcb_grab_pointer_reply() .
<br />> Is there any documents describe the rules of turning XML to C code?
<br />
<br />I don't know about such a document. But the rule is quite simple, I think.
<br />
<br />The <request> tag provides the name of the request. Since it contains a  
<br /><reply> tag, the request has a reply (some requests do not generate a  
<br />reply). Thus, a function xcb_NameOfTheRequest_reply() is generated. The  
<br />contents of that function is always the same: a call to  
<br />xcb_wait_for_reply(). It's just that the result of xcb_wait_for_reply()  
<br />needs to be cast to xcb_NameOfTheRequest_reply_t.
<br />
<br />What the XML really describes are the contents of the struct, in this  
<br />case xcb_grab_pointer_reply_t. There is a single field called "status"  
<br />in our case here.
<br />
<br />I don't know why you want to look at the source code of  
<br />xcb_grab_pointer_reply(), but there is nothing interesting there.  
<br />Perhaps it makes more sense to talk about that reason.
<br />
<br />Cheers,
<br />Uli
<br />
<br />[...]
<br />> <https://maas.mail.163.com/dashi-web-extend/html/proSignature.html?ftlId=1&name=starcold14&uid=starcold14%40gmail.com&iconUrl=https%3A%2F%2Fmail-online.nosdn.127.net%2Fqiyelogo%2FdefaultAvatar.png&items=%5B%22starcold14%40gmail.com%22%5D>
<br />> On 12/29/2023 21:00,Uli Schlachter<psychon@znc.in> <mailto:psychon@znc.in> wrote:
<br />>  
<br />>      Hi starcold,
<br />>  
<br />>      Am 29.12.23 um 09:37 schrieb starcold14:
<br />>  
<br />>          Hi,
<br />>          I'm a newbie and don't know much about libxcb,
<br />>  
<br />>  
<br />>      There is xcb/proto and libxcb. proto contains a XML description of the
<br />>      X11 protocol and libxcb uses this XML to generate C code.
<br />>  
<br />>          and I'm currently having a
<br />>          problem where when I want to find a function named xcb_grab_pointer_reply, I
<br />>          can't find it in the code from
<br />>          gitlab(https://gitlab.freedesktop.org/xorg/lib/libxcb
<br />>          <https://gitlab.freedesktop.org/xorg/lib/libxcb>) using the grep tool.
<br />>  
<br />>  
<br />>      You can find he XML specification for GrabPointer here: [0]
<br />>  
<br />>      [0]:
<br />>      https://gitlab.freedesktop.org/xorg/proto/xcbproto/-/blob/1388374c7149114888a6a5cd6e9bf6ad4b42adf8/src/xproto.xml#L2585-2596
<br />>  
<br />>      When you build libxcb from source, the appropriate C code is then
<br />>      generated. You won't find much helpful in there. This is the generated
<br />>      code for xcb_grab_pointer_reply():
<br />>  
<br />>      xcb_grab_pointer_reply_t *
<br />>      xcb_grab_pointer_reply (xcb_connection_t           *c,
<br />>      xcb_grab_pointer_cookie_t   cookie  /**< */,
<br />>      xcb_generic_error_t       **e)
<br />>      {
<br />>      return (xcb_grab_pointer_reply_t *) xcb_wait_for_reply(c,
<br />>      cookie.sequence, e);
<br />>      }
<br />>  
<br />>      Cheers,
<br />>      Uli
<br />>      --
<br />>      “Some people are worth melting for.” - Olaf
<br />>  
<br />
<br />--  
<br />Homophobia - The fear that another man will treat you the way you treat  
<br />women.
<br />
<br /></div></div>