Am Donnerstag, den 31.03.2011, 08:10 +0200 schrieb Luca Bruno:
Looks ok to me as far as you tested those changes.
Ok, here we go: Looking at the header for the X11 protocol[1] reveals two things which are important for Vala's X11 bindings: a) Since x11.vapi is a client library it must not define _XSERVER64 (lines 59-61). As a consquence, XID is defined to be an unsigned long (line 66). Therefore KeySym is also defined to be an unsigned long (line 106). b) KeyCode is defined to be an unsigned char (line 108). This can easily be verified by a simple test program (source attached): $ uname -m; gcc -lX11 print_sizes.c -o print_sizes; ./print_sizes x86_64 sizeof(XID)=8, sizeof(KeySym)=8, sizeof(KeyCode)=1 $ The attached patch fixes x11.vapi which wrongly uses uint for KeySym and int for KeyCode. There aren't many changes since most functions specify the types of their parameters directly instead of using the aliases. The patch also fixes another bug: XGetKeyboardMapping() returns a pointer to an array whose size is determined by the parameters keycode_count and the (output parameter) keysyms_per_keycode_return. It doesn't return a valid Vala array. Trying to assign it's return value to such an array will result in a segfault. The attached test program will demonstrate that everything works correctly now. If you don't have any objections, please merge the patch into master. After that I will submit another patch adding all XFooToBar() functions. Best regards Alexander Kurtz [1] http://cgit.freedesktop.org/xorg/proto/xproto/tree/X.h [2] http://cgit.freedesktop.org/xorg/lib/libX11/tree/include/X11/Xlib.h
Attachment:
fix-keycode-and-keysym-types.patch
Description: Text Data
Attachment:
print_sizes.c
Description: Text Data
Attachment:
Test.vala
Description: Text Data
Attachment:
signature.asc
Description: This is a digitally signed message part