soul_of_moon 发表于 2006-10-16 15:35:09

如何移动gtk的鼠标?

gtk2.0
如何取得鼠标的坐标,如何移动?
先谢了!

Linux_Lyb 发表于 2006-10-19 10:01:04


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

soul_of_moon 发表于 2006-10-19 13:48:09

Display的相关函数接口都至少要2.2,2.0不能用啊

mozilla 发表于 2006-10-20 09:13:35

用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]
查看完整版本: 如何移动gtk的鼠标?