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...
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 ?
-Nicoo
_______________________________________________
[email protected]: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: [email protected]