winex11.drv: Strip the _XXX from X11DRV_GetKeyNameText when approperate

Aric Stewart aric at codeweavers.com
Wed Jan 18 07:49:07 CST 2012


On 1/17/12 10:18 PM, Vitaliy Margolen wrote:
> On 01/17/2012 09:32 AM, Aric Stewart wrote:
>>
>> The problem is that there is no XK keycode for just Shift, Control or Menu
>> so X11DRV_MapVirtualKeyEx maps them to Shift_L, etc. As a result the string
>> XKeysymToString returns is a string with a _L or _R at the end, even if the
>> "don't care" bit is set.
>> +                char *new_name;
>> +                INT rc = 0;
>> +                new_name = HeapAlloc(GetProcessHeap(),0,(idx-name)+1);
>> +                lstrcpynA(new_name,name,(idx-name)+1);
>> +                new_name[idx-name] = 0;
>> +                TRACE("found scan=%04x keyc=%u keysym=%04x new_string=%s\n",
>> +                       scanCode, keyc, (int)keys, new_name);
>> +                if (lpBuffer&&  nSize)
>> +                    rc = MultiByteToWideChar(CP_UNIXCP, 0, new_name, -1, lpBuffer, nSize);
>> +                HeapFree(GetProcessHeap(),0,new_name);
>> +                return rc;
>
> I don't think you need an extra buffer. Just do something like:
> if (lpBuffer&&  nSize)
> {
>      rc = MultiByteToWideChar(CP_UNIXCP, 0, new_name, idx - name, lpBuffer, nSize);
>      if (nSize>  idx - name)
>          lpBuffer[idx - name] = 0;
> }
>
> Of course need to account for rc.
>
> Vitaliy

Can't really use idx after the MultiByteToWideChar but I could possibly 
use rc.

I will investigate quick.
-aric



More information about the wine-devel mailing list