找回密码
 注册
查看: 1779|回复: 3

如何移动gtk的鼠标?

[复制链接]
发表于 2006-10-16 15:35:09 | 显示全部楼层 |阅读模式
gtk2.0
如何取得鼠标的坐标,如何移动?
先谢了!
发表于 2006-10-19 10:01:04 | 显示全部楼层
[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]
回复

使用道具 举报

 楼主| 发表于 2006-10-19 13:48:09 | 显示全部楼层
Display的相关函数接口都至少要2.2,2.0不能用啊
回复

使用道具 举报

发表于 2006-10-20 09:13:35 | 显示全部楼层
用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]
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2025-2-6 12:50 , Processed in 0.028136 second(s), 16 queries .

© 2001-2025 Discuz! Team. Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表