Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use 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.

But how do I use this function? I cannot get a GdkDevice, since there is no factory, nor is there a constructor.

like image 625
Kugel Avatar asked Jul 19 '14 20:07

Kugel


1 Answers

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);
like image 175
luciomrx Avatar answered Sep 18 '22 01:09

luciomrx