如何移动gtk的鼠标?
gtk2.0如何取得鼠标的坐标,如何移动?
先谢了!
gdk_display_get_pointer ()
void gdk_display_get_pointer (GdkDisplay *display,
GdkScreen **screen,
gint *x,
gint *y,
GdkModifierType *mask);
Gets the current location of the pointer and the current modifier mask for a given display.
display : a GdkDisplay
screen : location to store the screen that the cursor is on, or NULL.
x : location to store root window X coordinate of pointer, or NULL.
y : location to store root window Y coordinate of pointer, or NULL.
mask : location to store current modifier mask, or NULL
Display的相关函数接口都至少要2.2,2.0不能用啊 用Xlib接口
#include <X11/Xlib.h>
main()
{
Display *dpy;
Window win;
Window root;
Window child;
int rootx,rooty,winx,winy,mask;
dpy=XOpenDisplay(NULL);
if(!dpy)
{
printf("XOpenDisplay error\n");
return;
}
XQueryPointer(dpy, RootWindow(dpy,0), &root, &child,
&rootx, &rooty, &winx, &winy, &mask);
printf("x=%d y=%d\n", rootx, rooty);
XCloseDisplay(dpy);
}
页:
[1]