Re: [Vala] [PATCH] add missing XStringToKeysym() function to x11.vapi



Am Montag, den 04.04.2011, 15:41 +0200 schrieb Luca Bruno:
What about [CCode (array_length = false)] ulong[] ?

Damn, I really should learn how to read!

XGetKeyboardMapping()'s manpage says:

        The X server arbitrarily chooses the keysyms_per_key‐
        code_return value to be large enough to report all requested
        symbols.  A special KeySym value of NoSymbol is used to fill
        in unused elements for individual KeyCodes.  To free the stor‐
        age returned by XGetKeyboardMapping, use XFree.

So the unowned keyword is actually the wrong part. Remove that ...

-               public unowned uint[] get_keyboard_mapping (uint first_keycode, int keycode_count, ref int 
keysyms_per_keycode_return);
+               public ulong[] get_keyboard_mapping (uchar first_keycode, int keycode_count, ref int 
keysyms_per_keycode_return);

... et voilà, no more segfaults when using an array:

        $ valac --vapidir=b --pkg=x11 Test.vala && ./Test 
        On this system sizeof(char) is 1 bytes, sizeof(int) is 4 bytes and sizeof(long) is 8 bytes.
        The minimal keycode is 8, the maximal keycode is 255 which makes a total of 248 keycodes.
        With this keyboard mapping there are 7 keysyms per keycode, detailed mapping follows:
           KeyCode   0 has KeySyms:        0h        0h        0h        0h        0h        0h        0h 
        [...]
           KeyCode 247 has KeySyms:        0h        0h        0h        0h        0h        0h        0h


I've attached updated versions of the patch and the test program.

Best regards

Alexander Kurtz

Attachment: fix-keycode-and-keysym-types.patch
Description: Text Data

Attachment: Test.vala
Description: Text Data

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]