如何使用gdk_device_get_position()? [英] How to use gdk_device_get_position()?
本文介绍了如何使用gdk_device_get_position()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在Gdk中获取指针在屏幕上的位置,并找到 gdk_display_get_pointer()
,它可以正常工作,但已标记为已弃用,并引用了 gdk_device_get_position()
现在。
I am trying to get the pointer position on screen in Gdk and found gdk_display_get_pointer()
, which works fine, but it's marked as deprecated and refers to gdk_device_get_position()
now.
但是如何使用此功能?我找不到 GdkDevice
,因为没有工厂,也没有构造函数。
But how do I use this function? I cannot get a GdkDevice
, since there is no factory, nor is there a constructor.
推荐答案
使用Gdk.DeviceManager。
use Gdk.DeviceManager.
.....
.....
GdkDisplay *display = gdk_display_get_default ();
GdkDeviceManager *device_manager = gdk_display_get_device_manager (display);
GdkDevice *device = gdk_device_manager_get_client_pointer (device_manager);
// do whatever with Gdk.Device, i.e:
int x, y;
gdk_device_get_position (device, NULL, &x, &y);
printf ("x= %d, y=%d", x,y);
这篇关于如何使用gdk_device_get_position()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文