打印

如何移动gtk的鼠标?

如何移动gtk的鼠标?

gtk2.0
如何取得鼠标的坐标,如何移动?
先谢了!
不是每朵花都能代表爱情,但是玫瑰做到了; 不是每个人都能让我想念,但是你做到了。

TOP

[code:1]
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
[/code:1]

TOP

Display的相关函数接口都至少要2.2,2.0不能用啊
不是每朵花都能代表爱情,但是玫瑰做到了; 不是每个人都能让我想念,但是你做到了。

TOP

用Xlib接口
[code:1]
#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);
}
[/code:1]

TOP