Re: A problem about reading the source code
starcold14 <[email protected]> Tue, 2 Jan 2024 14:17:29 +0800
| Newsgroups | gmane.comp.freedesktop.xcb |
|---|---|
| Message-ID | <[email protected]> |
<div>Hi=EF=BC=8CUli Schlachter=EF=BC=8C I am so happy reading your reply.= The reason I want to know the function is that I have got a problem. I h= ave emailed the problem to petter hutterer(hutterer did not answer the em= ail, QAQ), the following is the whole email: </div><div><br></div><div><d= iv><div><span>=22Hi, peter hutterer, </span></div><div><br></div><div>I a= m 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 tho= ught 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 tes= t-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-te= rminal, the error message =22Can't grab the mouse.=22 is displayed. Then = I check the xwininfo code: </span> </div></div><div><span>dsimple.c in x1= 1-utils:</span></div><blockquote><div><div><span>xcb=5Fwindow=5Ft Select=5F= Window(xcb=5Fconnection=5Ft *dpy,</span></div></div><div><div><span> &nbs= p; const xcb=5Fscreen=5Ft *screen,</span></div></div><div><div><span> &nb= sp; int descend)</span></div></div><div><div><span>=7B</span></div></div>= <div><div><span> xcb=5Fcursor=5Ft cursor;</span></div></div>= <div><div><span> xcb=5Fgeneric=5Fevent=5Ft *event;</span></d= iv></div><div><div><span> xcb=5Fwindow=5Ft target=5Fwin =3D = XCB=5FWINDOW=5FNONE;</span></div></div><div><div><span> xcb=5F= window=5Ft root =3D screen->root;</span></div></div><div><div><span> &= nbsp; int buttons =3D 0;</span></div></div><div><div><span> = xcb=5Fgeneric=5Ferror=5Ft *err;</span></div></div><div><div><span> = xcb=5Fgrab=5Fpointer=5Fcookie=5Ft grab=5Fcookie;</span></div= ></div><div><div><span> xcb=5Fgrab=5Fpointer=5Freply=5Ft *gr= ab=5Freply;</span></div></div><div><div><span><br></span></div></div><div= ><div><span> /* Make the target cursor */</span></div></div>= <div><div><span> cursor =3D Create=5F=46ont=5FCursor (dpy, X= C=5Fcrosshair);</span></div></div><div><div><span><br></span></div></div>= <div><div><span> /* Grab the pointer using target cursor, le= tting it room all over */</span></div></div><div><div><span>  = ;grab=5Fcookie =3D xcb=5Fgrab=5Fpointer</span></div></div><div><div><span= > (dpy, =46alse, root,</span></div></div><div><div><span> XCB=5FEVENT=5FM= ASK=5FBUTTON=5FPRESS =7C XCB=5FEVENT=5FMASK=5FBUTTON=5FRELEASE,</span></d= iv></div><div><div><span> XCB=5FGRAB=5FMODE=5FSYNC, XCB=5FGRAB=5FMODE=5FA= SYNC,</span></div></div><div><div><span> root, cursor, XCB=5FTIME=5FCURRE= NT=5FTIME);</span></div></div><div><div><span> grab=5Freply = =3D xcb=5Fgrab=5Fpointer=5Freply (dpy, grab=5Fcookie, &err);</span></= div></div><div><div><span> if (grab=5Freply->status =21=3D= XCB=5FGRAB=5FSTATUS=5FSUCCESS)</span></div></div><div><div><span> =46ata= l=5FError (=22<span>Can't grab the mouse.</span>=22);</span></div></div><= /blockquote><font color=3D=22=230061ff=22><span>xwininfo uses the libxcb = library to communicate with xserver, and xserver cannot grab the mouse at= this point.</span></font><div><font color=3D=22=23242424=22>I had a hard= time understanding the meaning of =22Can't grab the mouse.=22 So I searc= hed the Internet for relevant information and found your previous blog po= st high-level-overview-of-grabs.</font></div><div><font color=3D=22=23242= 424=22>I wonder if the xserver lost the cursor of the mouse and caused th= is problem (I am not a professional X user, so my understanding may be wr= ong, please point out any mistakes in my statement). This issue can be re= medied in the following ways:<br>1. Use crtl+alt+=461 to switch to tty1, = then use crtl+alt+=467 to switch to tty7, everything returns to normal, t= he left mouse button can normally click any window or function on the des= ktop;<br>2. When using a laptop, tap the touchpad to recover (this issue = also occurs on my desktop).</font></div><div><font color=3D=22=23242424=22= ><br></font></div><div><font color=3D=22=23242424=22>I hope your rich X i= nput experience can help me find a solution. I would like to express my h= ighest respect to you here. Thank you.</font></div><div><font color=3D=22= =23242424=22><br></font></div><div><font color=3D=22=23242424=22>Yours si= ncerely.=22</font></div>=E2=80=8B<br></div><div>so I hope knowing about t= he xcb function will help resolving my problem. If you know anything abou= t it,please tell me,thank you.</div><div><br></div><div>Yours sincerely.<= /div><div id=3D=22imail=5Fsignature=22 class=3D=22ntes-signature=22></div= ><div class=3D=22ntes-mailmaster-quote=22 style=3D=22padding-top: 1px; pa= dding-bottom: 1px=22><div style=3D=22margin-top: 2em;margin-bottom: 1em;f= ont-size: 14px;line-height: 1.25;color: =2378787a;=22>---- Replied Messag= e ----</div><div style=3D=22margin-bottom: 1em;font-size: 12px;line-heigh= t: 1.25;color: =23232324;padding: 0.5em 0.25em;border-radius: 0.67em;back= ground-color: =23f0f0f0;=22><table width=3D=22100%=22 cellpadding=3D=220=22= cellspacing=3D=229=22 border=3D=220=22><tbody><tr><td valign=3D=22top=22= style=3D=22width: 4.25em;font-size: 12px;line-height: 1.25;color: =23787= 87a;=22><span style=3D=22color:=238b8d94=22>=46rom</span></td><td valign=3D= =22top=22 style=3D=22font-size: 12px;line-height: 1.25;color: =23232324;w= ord-break: break-all;=22><a class=3D=22mail-from=22 style=3D=22color: =23= 0886e8; text-decoration: none=22 href=3D=22mailto:psychon=40znc.in=22>Uli= Schlachter<psychon=40znc.in></a></td></tr><tr><td valign=3D=22top=22= style=3D=22width: 4.25em;font-size: 12px;line-height: 1.25;color: =23787= 87a;=22><span style=3D=22color:=238b8d94=22>Date</span></td><td class=3D=22= mail-date=22 valign=3D=22top=22 style=3D=22font-size: 12px;line-height: 1= .25;color: =23232324;word-break: break-all;=22><span class=3D=22mail-date= =22 style=3D=22color:black=22>01/02/2024 13:49</span></td></tr><tr><td va= lign=3D=22top=22 style=3D=22width: 4.25em;font-size: 12px;line-height: 1.= 25;color: =2378787a;=22> <span style=3D=22color:=238b8d94=22>To</span></t= d><td valign=3D=22top=22 style=3D=22font-size: 12px;line-height: 1.25;col= or: =23232324;word-break: break-all;=22><a class=3D=22mail-to=22 style=3D= =22color: =230886e8; text-decoration: none=22 href=3D=22mailto:starcold14= =40gmail.com=22>starcold14<starcold14=40gmail.com></a></td></tr><tr= ><td valign=3D=22top=22 style=3D=22width: 4.25em;font-size: 12px;line-hei= ght: 1.25;color: =2378787a;=22> <span style=3D=22color:=238b8d94=22>Cc</s= pan></td><td valign=3D=22top=22 style=3D=22font-size: 12px;line-height: 1= .25;color: =23232324;word-break: break-all;=22><a class=3D=22mail-cc=22 s= tyle=3D=22color: =230886e8; text-decoration: none=22 href=3D=22mailto:xcb= =40lists.freedesktop.org=22>xcb=40lists.freedesktop.org<xcb=40lists.fr= eedesktop.org></a></td></tr><tr><td valign=3D=22top=22 style=3D=22widt= h: 4.25em;font-size: 12px;line-height: 1.25;color: =2378787a;=22><span st= yle=3D=22color:=238b8d94=22>Subject</span></td><td class=3D=22mail-subjec= t=22 valign=3D=22top=22 style=3D=22font-size: 12px;line-height: 1.25;colo= r: =23232324;word-break: break-all;=22><span class=3D=22mail-subject=22 s= tyle=3D=22color:black=22>Re: A problem about reading the source code</spa= n></td></tr></tbody></table></div><div>Hi, <br /> <br />Am 01.01.24 um 14:39 schrieb starcold14: <br />> Hi=EF=BC=8CUli Schlachter=EF=BC=8C <br />> I am very grateful for your reply. <br />> I am now a little confused about the XML specification. I cann= ot understand how <br />> the XML specification describes a function like xcb=5Fgrab=5Fp= ointer=5Freply() . <br />> Is there any documents describe the rules of turning XML to C = code=3F <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 =20 <br /><reply> tag, the request has a reply (some requests do not ge= nerate a =20 <br />reply). Thus, a function xcb=5FNameOfTheRequest=5Freply() is genera= ted. The =20 <br />contents of that function is always the same: a call to =20 <br />xcb=5Fwait=5Ffor=5Freply(). It's just that the result of xcb=5Fwait= =5Ffor=5Freply() =20 <br />needs to be cast to xcb=5FNameOfTheRequest=5Freply=5Ft. <br /> <br />What the XML really describes are the contents of the struct, in th= is =20 <br />case xcb=5Fgrab=5Fpointer=5Freply=5Ft. There is a single field call= ed =22status=22 =20 <br />in our case here. <br /> <br />I don't know why you want to look at the source code of =20 <br />xcb=5Fgrab=5Fpointer=5Freply(), but there is nothing interesting th= ere. =20 <br />Perhaps it makes more sense to talk about that reason. <br /> <br />Cheers, <br />Uli <br /> <br />=5B...=5D <br />> <https://maas.mail.163.com/dashi-web-extend/html/proSignatu= re.html=3FftlId=3D1&name=3Dstarcold14&uid=3Dstarcold14%40gmail.co= m&iconUrl=3Dhttps%3A%2=46%2=46mail-online.nosdn.127.net%2=46qiyelogo%= 2=46defaultAvatar.png&items=3D%5B%22starcold14%40gmail.com%22%5D> <br />> On 12/29/2023 21:00=EF=BC=8CUli Schlachter<psychon=40znc.in= > <mailto:psychon=40znc.in> wrote=EF=BC=9A <br />> =20 <br />> Hi starcold, <br />> =20 <br />> Am 29.12.23 um 09:37 schrieb sta= rcold14: <br />> =20 <br />> Hi=EF=BC= =8C <br />> I'm a ne= wbie and don't know much about libxcb, <br />> =20 <br />> =20 <br />> There is xcb/proto and libxcb. p= roto contains a XML description of the <br />> X11 protocol and libxcb uses thi= s XML to generate C code. <br />> =20 <br />> and I'm = currently having a <br />> problem = where when I want to find a function named xcb=5Fgrab=5Fpointer=5Freply, = I <br />> can't fi= nd it in the code from <br />> gitlab(h= ttps://gitlab.freedesktop.org/xorg/lib/libxcb <br />> <http= s://gitlab.freedesktop.org/xorg/lib/libxcb>) using the grep tool. <br />> =20 <br />> =20 <br />> You can find he XML specificatio= n for GrabPointer here: =5B0=5D <br />> =20 <br />> =5B0=5D: <br />> https://gitlab.freedesktop.org/x= org/proto/xcbproto/-/blob/1388374c7149114888a6a5cd6e9bf6ad4b42adf8/src/xp= roto.xml=23L2585-2596 <br />> =20 <br />> When you build libxcb from sourc= e, the appropriate C code is then <br />> generated. You won't find much h= elpful in there. This is the generated <br />> code for xcb=5Fgrab=5Fpointer=5F= reply(): <br />> =20 <br />> xcb=5Fgrab=5Fpointer=5Freply=5Ft= * <br />> xcb=5Fgrab=5Fpointer=5Freply (xc= b=5Fconnection=5Ft = *c, <br />> xcb=5Fgrab=5Fpointer=5Fcookie=5F= t cookie /**< */, <br />> xcb=5Fgeneric=5Ferror=5Ft = **e) <br />> =7B <br />> return (xcb=5Fgrab=5Fpointer=5Fr= eply=5Ft *) xcb=5Fwait=5Ffor=5Freply(c, <br />> cookie.sequence, e); <br />> =7D <br />> =20 <br />> Cheers, <br />> Uli <br />> -- <br />> =E2=80=9CSome people are worth m= elting for.=E2=80=9D - Olaf <br />> =20 <br /> <br />-- =20 <br />Homophobia - The fear that another man will treat you the way you t= reat =20 <br />women. <br /> <br /></div></div>