Hello,
a very basic answer to this would be the following example:
X.Display display = new X.Display();
X.Event event = X.Event();
X.Window window = display.default_root_window();
display.query_pointer(window, out window,
out event.xbutton.subwindow, out event.xbutton.x_root,
out event.xbutton.y_root, out event.xbutton.x,
out event.xbutton.y, out event.xbutton.state);
print("Mouse Coordinates: " + event.xbutton.x.to_string() + "," +
event.xbutton.y.to_string() + "\n");
I have derived the code from this example in C:
http://ubuntuforums.org/showpost.php?p=4110065&postcount=7
Also, the x11.vapi has to be extended by the following binding to make the code
work:
[CCode (cname = "XQueryPointer")]
public bool query_pointer (Window w, out Window root_return, out Window
child_return, out int root_x_return, out int root_y_return, out int
win_x_return, out int win_y_return, out uint mask_return);
However, on multitouch devices it won't work. For some reason, the coordinates
won't be passed to the application as soon as you place two or more fingers on
the touchpad. I tested that temporarily in a silly loop.
Any idea how to approach for multitouch devices?
Thanks,
gilzad
-------- Original-Nachricht --------
> Datum: Tue, 05 Jun 2012 16:48:47 +0200
> Von: "Gilzad Hamuni" <[email protected]>
> An: [email protected]
> Betreff: [Vala] global mouse pos / multitouch
> Hi all,
>
> I'm having a hard time finding out how to get the global mouse position in
> vala.
>
> Using Gtk, I was only able to get the coordinates inside a shown window.
> To use Xcb, I seem to be missing the knowledge about the required members.
> And using X11 bindings, I fail at the point, where I try to declare
> X.WindowAttributes, which I'd need to pass as a reference.
>
> Trying this..
>
> X.Display display = new X.Display();
> X.WindowAttributes windowAttributes;
> display.get_window_attributes(display.default_root_window(), out
> windowAttributes);
>
> .. the compiler (v0.17) says:
> mouse_position.vala.c:(.text+0x12e): undefined reference to
> `window_attributes_destroy'
>
> Ideally I'd use a library to receive many mouse positions at a time. I
> believe there should be a way as Gnome 2.30.2 already supports 2-finger
> scrolling. If not, my hope is that I'll be flooded with events for each
> finger.
> If I'm not totally wrong, uTouch would require a newer Gtk, so I can't use
> it.
>
> Thanks a bunch for any hint.
>
>
> gilzad
> --
> NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!
>
> Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a
> _______________________________________________
> vala-list mailing list
> [email protected]
> https://mail.gnome.org/mailman/listinfo/vala-list
--
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a
_______________________________________________
vala-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/vala-list