On Wed, Oct 31, 2012 at 11:29:07AM -0400, Kristian Høgsberg wrote:
> On Wed, Oct 31, 2012 at 12:13:09AM +0200, Ran Benita wrote:
> > In order to use XKB capabilities (as we do), the client must issue an
> > XkbUseExtension request:
> > http://www.x.org/releases/current/doc/kbproto/xkbproto.html#Initializing_the_X_Keyboard_Extension
> > 
> > The reason this succeeds currently is that XOpenDisplay from Xlib does
> > this for us. But it is better not to rely on that, but do it explicitly
> > in XCB with the rest of the XKB init sequence.
> > 
> > Signed-off-by: Ran Benita <[email protected]>
> > ---
> >  src/compositor-x11.c | 20 ++++++++++++++++++++
> >  1 file changed, 20 insertions(+)
> > 
> > diff --git a/src/compositor-x11.c b/src/compositor-x11.c
> > index c654aec..77e8600 100644
> > --- a/src/compositor-x11.c
> > +++ b/src/compositor-x11.c
> > @@ -191,6 +191,8 @@ x11_compositor_setup_xkb(struct x11_compositor *c)
> >     const xcb_query_extension_reply_t *ext;
> >     xcb_generic_error_t *error;
> >     xcb_void_cookie_t select;
> > +   xcb_xkb_use_extension_cookie_t use_ext;
> > +   xcb_xkb_use_extension_reply_t *use_ext_reply;
> >     xcb_xkb_per_client_flags_cookie_t pcf;
> >     xcb_xkb_per_client_flags_reply_t *pcf_reply;
> >     xcb_xkb_get_state_cookie_t state;
> > @@ -220,6 +222,24 @@ x11_compositor_setup_xkb(struct x11_compositor *c)
> >             return;
> >     }
> >  
> > +   use_ext = xcb_xkb_use_extension(c->conn,
> > +                                   XCB_XKB_MAJOR_VERSION,
> > +                                   XCB_XKB_MINOR_VERSION);
> > +   use_ext_reply = xcb_xkb_use_extension_reply(c->conn, use_ext, &error);
> > +   if (!use_ext_reply || error) {
> > +       weston_log("couldn't start using XKB extension (error code %d)\n",
> > +                  error->error_code);
> > +       return;
> > +   }
> > +
> > +   if (!use_ext_reply->supported) {
> > +       weston_log("XKB extension version on the server is too old "
> > +                  "(want %d.%d, has %d.%d)\n",
> > +                  XCB_XKB_MAJOR_VERSION, XCB_XKB_MINOR_VERSION,
> > +                  use_ext_reply->serverMajor, use_ext_reply->serverMinor);
> > +       return;
> > +   }
> 
> We need to free error and use_ext_reply.

Yes, I took this code from some other code I wrote, which uses
__attribute__((cleanup)) for that, and I forgot about it. It also has
some indentation mis-matches..
I found it useful BTW, to move each request to its own block, and then
the variables are just 'cookie' and 'reply' everywhere, and it's easier
to handle.
Anyway, since a couple other places need fixing as well, I'll split it
to a separate patch. Also another trivial change I saw when looking at
this.

> Kristian
> 
> > +
> >     pcf = xcb_xkb_per_client_flags(c->conn,
> >                                    XCB_XKB_ID_USE_CORE_KBD,
> >                                    
> > XCB_XKB_PER_CLIENT_FLAG_DETECTABLE_AUTO_REPEAT,
_______________________________________________
wayland-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to