<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span style="font-weight: bold;">Hi,</span></div><div><span style="font-weight: bold;">I try to get the position of my pointer, I tried whit this code :</span></div><div>#include<X11/Xlib.h><br>#include<X11/cursorfont.h><br>#include<stdio.h><br>#include<stdlib.h><br>#include<string.h><br><br>#define DPYW DisplayWidth(dpy,scr)<br>#define DPYH DisplayHeight(dpy,scr)<br><br><br>int main(int argc, char *argv[]){<br> Display *dpy;<br> int scr, stop=0;<br> Window rootwin;<br> Window wbg;<br> XEvent e;<br> Cursor
theCursor;<br><br> dpy = XOpenDisplay(NULL);<br><br> scr=DefaultScreen(dpy);<br> rootwin=RootWindow(dpy, scr);<br> wbg=XCreateSimpleWindow(dpy,rootwin,0,0,<br> DPYW,DPYH,0,<br> BlackPixel(dpy, scr),<br> BlackPixel(dpy, scr)
);<br><br><br> XStoreName(dpy, wbg, "background");<br> XSelectInput(dpy, wbg, ExposureMask|KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask);<br> XMapWindow(dpy, wbg);<br><br><br> theCursor = XCreateFontCursor(dpy, XC_left_ptr);<br><br> XDefineCursor(dpy,wbg,theCursor);<br><br><br> // where is my mouse ?<br> int mousex, mousey;<br> XQueryPointer(dpy,rootwin,None,None,&mousex,&mousey,None,None,None); // problem...<br><br> while(stop==0) {<br> XNextEvent(dpy,
&e);<br> if(e.type==Expose && e.xexpose.count<1) {<br> XFlush(dpy);<br> }<br><br> switch(e.type){<br> case KeyRelease : stop=1;break;<br> }<br><br> }<br> XFreeCursor(dpy,theCursor);<br>
XCloseDisplay(dpy);<br><br> return 0;<br>}<br><br><span style="font-weight: bold;"><br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><span style="font-weight: bold;">but, when I'm running it, X exits without complains.</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><span style="font-weight: bold;"><br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><span style="font-weight: bold;">also, there is a function like fprintf to write directly to xorg.log through xlib ?</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new
york,times,serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: times new roman,new york,times,serif; background-color: transparent; font-style: normal;"><span style="font-weight: bold;">-Nicoo</span></div></div></body></html>