how to send data to Xorg.log and XQueryPointer crash
Peter Hutterer
peter.hutterer at who-t.net
Tue May 21 21:47:18 PDT 2013
On Tue, May 21, 2013 at 08:09:24AM -0700, First Last wrote:
> Hi,
> I try to get the position of my pointer, I tried whit this code :
> #include<X11/Xlib.h>
> #include<X11/cursorfont.h>
> #include<stdio.h>
> #include<stdlib.h>
> #include<string.h>
>
> #define DPYW DisplayWidth(dpy,scr)
> #define DPYH DisplayHeight(dpy,scr)
>
>
> int main(int argc, char *argv[]){
> Display *dpy;
> int scr, stop=0;
> Window rootwin;
> Window wbg;
> XEvent e;
> Cursor theCursor;
>
> dpy = XOpenDisplay(NULL);
>
> scr=DefaultScreen(dpy);
> rootwin=RootWindow(dpy, scr);
> wbg=XCreateSimpleWindow(dpy,rootwin,0,0,
> DPYW,DPYH,0,
> BlackPixel(dpy, scr),
> BlackPixel(dpy, scr) );
>
>
> XStoreName(dpy, wbg, "background");
> XSelectInput(dpy, wbg, ExposureMask|KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask);
> XMapWindow(dpy, wbg);
>
>
> theCursor = XCreateFontCursor(dpy, XC_left_ptr);
>
> XDefineCursor(dpy,wbg,theCursor);
>
>
> // where is my mouse ?
> int mousex, mousey;
> XQueryPointer(dpy,rootwin,None,None,&mousex,&mousey,None,None,None); // problem...
none of these may be NULL (or None, which is just 0 anyway). you do need to
provide some valid pointers here.
>
> while(stop==0) {
> XNextEvent(dpy, &e);
> if(e.type==Expose && e.xexpose.count<1) {
> XFlush(dpy);
> }
>
> switch(e.type){
> case KeyRelease : stop=1;break;
> }
>
> }
> XFreeCursor(dpy,theCursor);
> XCloseDisplay(dpy);
>
> return 0;
> }
>
>
>
> but, when I'm running it, X exits without complains.
>
> also, there is a function like fprintf to write directly to xorg.log through xlib ?
are you saying your X server crashes when you run this? that shouldn't
happen and would certainly be a bug.
The Xorg.log is only for the X server, you're writing a client application
and can't access it.
Cheers,
Peter
More information about the xorg
mailing list