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.&nbsp;</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> &nbsp; &nbsp;xcb=5Fcursor=5Ft cursor;</span></div></div>=
<div><div><span> &nbsp; &nbsp;xcb=5Fgeneric=5Fevent=5Ft *event;</span></d=
iv></div><div><div><span> &nbsp; &nbsp;xcb=5Fwindow=5Ft target=5Fwin =3D =
XCB=5FWINDOW=5FNONE;</span></div></div><div><div><span> &nbsp; &nbsp;xcb=5F=
window=5Ft root =3D screen-&gt;root;</span></div></div><div><div><span> &=
nbsp; &nbsp;int buttons =3D 0;</span></div></div><div><div><span> &nbsp; =
&nbsp;xcb=5Fgeneric=5Ferror=5Ft *err;</span></div></div><div><div><span> =
&nbsp; &nbsp;xcb=5Fgrab=5Fpointer=5Fcookie=5Ft grab=5Fcookie;</span></div=
></div><div><div><span> &nbsp; &nbsp;xcb=5Fgrab=5Fpointer=5Freply=5Ft *gr=
ab=5Freply;</span></div></div><div><div><span><br></span></div></div><div=
><div><span> &nbsp; &nbsp;/* Make the target cursor */</span></div></div>=
<div><div><span> &nbsp; &nbsp;cursor =3D Create=5F=46ont=5FCursor (dpy, X=
C=5Fcrosshair);</span></div></div><div><div><span><br></span></div></div>=
<div><div><span> &nbsp; &nbsp;/* Grab the pointer using target cursor, le=
tting it room all over */</span></div></div><div><div><span> &nbsp; &nbsp=
;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> &nbsp; &nbsp;grab=5Freply =
=3D xcb=5Fgrab=5Fpointer=5Freply (dpy, grab=5Fcookie, &amp;err);</span></=
div></div><div><div><span> &nbsp; &nbsp;if (grab=5Freply-&gt;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&lt;psychon=40znc.in&gt;</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&lt;starcold14=40gmail.com&gt;</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&lt;xcb=40lists.fr=
eedesktop.org&gt;</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 />&gt; Hi=EF=BC=8CUli Schlachter=EF=BC=8C
<br />&gt; I am very grateful for your reply.
<br />&gt; I am now a little confused about the XML specification. I cann=
ot understand how
<br />&gt; the XML specification describes a function like xcb=5Fgrab=5Fp=
ointer=5Freply() .
<br />&gt; 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 &lt;request&gt; tag provides the name of the request. Since it =
contains a =20
<br />&lt;reply&gt; 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 />&gt; &lt;https://maas.mail.163.com/dashi-web-extend/html/proSignatu=
re.html=3FftlId=3D1&amp;name=3Dstarcold14&amp;uid=3Dstarcold14%40gmail.co=
m&amp;iconUrl=3Dhttps%3A%2=46%2=46mail-online.nosdn.127.net%2=46qiyelogo%=
2=46defaultAvatar.png&amp;items=3D%5B%22starcold14%40gmail.com%22%5D&gt;
<br />&gt; On 12/29/2023 21:00=EF=BC=8CUli Schlachter&lt;psychon=40znc.in=
&gt; &lt;mailto:psychon=40znc.in&gt; wrote=EF=BC=9A
<br />&gt; =20
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Hi starcold,
<br />&gt; =20
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Am 29.12.23 um 09:37 schrieb sta=
rcold14:
<br />&gt; =20
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Hi=EF=BC=
=8C
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I'm a ne=
wbie and don't know much about libxcb,
<br />&gt; =20
<br />&gt; =20
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;There is xcb/proto and libxcb. p=
roto contains a XML description of the
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;X11 protocol and libxcb uses thi=
s XML to generate C code.
<br />&gt; =20
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and I'm =
currently having a
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;problem =
where when I want to find a function named xcb=5Fgrab=5Fpointer=5Freply, =
I
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;can't fi=
nd it in the code from
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gitlab(h=
ttps://gitlab.freedesktop.org/xorg/lib/libxcb
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;http=
s://gitlab.freedesktop.org/xorg/lib/libxcb&gt;) using the grep tool.
<br />&gt; =20
<br />&gt; =20
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;You can find he XML specificatio=
n for GrabPointer here: =5B0=5D
<br />&gt; =20
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=5B0=5D:
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;https://gitlab.freedesktop.org/x=
org/proto/xcbproto/-/blob/1388374c7149114888a6a5cd6e9bf6ad4b42adf8/src/xp=
roto.xml=23L2585-2596
<br />&gt; =20
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;When you build libxcb from sourc=
e, the appropriate C code is then
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;generated. You won't find much h=
elpful in there. This is the generated
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;code for xcb=5Fgrab=5Fpointer=5F=
reply():
<br />&gt; =20
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xcb=5Fgrab=5Fpointer=5Freply=5Ft=
 *
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xcb=5Fgrab=5Fpointer=5Freply (xc=
b=5Fconnection=5Ft &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;*c,
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xcb=5Fgrab=5Fpointer=5Fcookie=5F=
t &nbsp;&nbsp;cookie &nbsp;/**&lt; */,
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xcb=5Fgeneric=5Ferror=5Ft &nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**e)
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=7B
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return (xcb=5Fgrab=5Fpointer=5Fr=
eply=5Ft *) xcb=5Fwait=5Ffor=5Freply(c,
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cookie.sequence, e);
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=7D
<br />&gt; =20
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cheers,
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Uli
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--
<br />&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=E2=80=9CSome people are worth m=
elting for.=E2=80=9D - Olaf
<br />&gt; =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>