Bug 75798

Summary: xkb_x11_keymap_new_from_device fails on XQuartz
Product: libxkbcommon Reporter: Gatis Paeglis <gatis.paeglis>
Component: GeneralAssignee: Daniel Stone <daniel>
Status: RESOLVED FIXED QA Contact: Ran Benita <ran234>
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: Mac OS X (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: 0001-x11-relax-XkbGetNames-requirements.patch

Description Gatis Paeglis 2014-03-05 14:24:41 UTC
Setup:

XQuartz downloaded from https://xquartz.macosforge.org/landing/ and installed on Mac OS X. 

1 - Start the XQuartz X server on Mac.
2 - ssh to Ubuntu with: ssh -X user@ip
3 - Run application, observe how xkb_x11_keymap_new_from_device returns NULL.

It fails in src/x11/x11-keymap.c in the following function:

static bool
get_names(struct xkb_keymap *keymap, xcb_connection_t *conn,
          uint16_t device_id)

at this place:

    if ((reply->which & required_names) != required_names) {
        goto fail;
    }

If I comment that out this check then the rest of the xkb calls in that function succeed and keyboard/keymap seem to work as expected. Also when doing keymap changes with "xmodmap".

Docs [1] of XkbGetNames states that "which" is a mask of names or map components to be updated, could it be that "required_names" is not expected to
be equal with "reply->which"? 

[1] http://www.x.org/archive/X11R7.5/doc/man/man3/XkbGetNames.3.html
Comment 1 Ran Benita 2014-03-05 19:43:59 UTC
I guess XQuartz simply doesn't have some components, so they are not reported in 'which' (this field reports which of the requested fields were actually filled). So that check is probably too strict, and we should relax it. I just need to check that we can handle all of the 'zero' cases correctly, and only leave the ones that are absolutely necessary (if there are any). However if when you remove the line it works correctly, then it's probably OK. (In fact we already have a test which compiles a quartz.xkb from a previous bug report).

The output of the following printf right before the failing line would help:
    printf("reply->which: %#x\n", reply->which);

I don't have a MacOS so I'll also need some help with testing.
Comment 2 Gatis Paeglis 2014-03-06 11:15:24 UTC
I have the setup ready, so I can help with a testing.

The output if printf("reply->which: %#x\n", reply->which) is :

reply->which: 0xbf5
Comment 3 Ran Benita 2014-03-06 11:54:34 UTC
Created attachment 95224 [details] [review]
0001-x11-relax-XkbGetNames-requirements.patch

Thanks. This means only the key aliases and group names are missing. So the attached patch should work, but it'd be nice if you can test it before I push.
Comment 4 Gatis Paeglis 2014-03-06 12:19:26 UTC
Yep, this works. xkb_x11_keymap_new_from_device retuns successfully, input works and things like "xmodmap -e "keycode 37 = r"" work as well.
Comment 5 Ran Benita 2014-03-06 12:25:12 UTC
OK, great. I've pushed it now.

BTW, since this is the only real issue that came up with 0.4.0 thus far, let me know when everything works out in your tests (if you plan on doing more) and I'll do a 0.4.1.
Comment 6 Gatis Paeglis 2014-03-06 12:30:59 UTC
I might be doing few more tests, I will let you know if there are any issues :)

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.