On Saturday 05 July 2003 11:59, Shachar Shemesh wrote:
> I have also found the sources for xkbprint, which does just that. The
> problem I'm currently facing is of documentation. Where are the Xkb
> extensions documented?

Google for "xkb specification":
http://www.x-docs.org/XKB/XKBlib.pdf

As to your questions:
1. The keyboard language can be determined from the current group's name 
("Russian", "Israelian").
2. Just wondering -- why is it needed for WINE?
3. Here are some pointers:

3.1. Before you start messing with Xkb, make sure its available by invoking 
XkbQueryExtension. The third parameter to this function is int* xkb_eventbase 
-- store it. You'll need it later. (If XkbQueryExtension returns false, just 
give up the entire deal.)

3.2. Register for all events which may signify change of mapping. We'll be 
very selective as we want to minimize our X traffic.

const unsigned int events =
        XkbNewKeyboardNotifyMask |
        XkbMapNotifyMask;
const unsigned int stateEventDetails = XkbGroupStateMask;

XkbSelectEvents(appDpy, XkbUseCoreKbd, events, events);
XkbSelectEventDetails(
        appDpy,
        XkbUseCoreKbd,
        XkbStateNotify,
        stateEventDetails,
        stateEventDetails);

3.3. If you're interested keeping a copy of the keyboard mapping, this would 
be a good time to:

/* global */
XkbDescPtr my_xkb_desc;
int my_xkb_group;

XkbStateRec xkbState;
my_xkb_desc = XkbGetMap(appDpy, 0, XkbUseCoreKbd);
/* If you want things like group names to be present in my_xkb_desc, you'd 
want to also use XkbGetNames. */
XkbGetState(appDpy, XkbUseCoreKbd, &xkbState);
my_xkb_group = xkbState.group;

3.4. Handle those XkbEvents. In your X event handler, do:

if (xkb_initialized_allright && (event->type == my_xkb_eventbase))
{
        XkbEvent* xkb_ev = (XkbEvent*)event;
        switch (xkb_ev->any.xkb_type) {
                /* Those events signify remapping of the keyboard. */
                case XkbNewKeyboardNotify:
                case XkbMapNotify:
                        {
                                /* Mapping changed. If you fetch the entire mapping 
when needed, you might 
want to mark the current one you hold as "dirty". */
                                my_xkb_mapping_is_dirty = TRUE;
                        }
                        break;
                case XkbStateNotify:
                        if (xkb_ev->state.changed & XkbGroupStateMask)
                        {
                                /* this stores the effective group, not necessarily 
the currently locked 
group */
                                my_xkb_group = xkb_ev->state.group;
                        }
                        break;
        }
}

3.4. Whenever you want to make sure my_xkb_desc is updated:

bool make_sure_our_xkb_mapping_is_updated()
{
        if (my_xkb_mapping_is_dirty)
                bool success = true;
                success = success && (XkbGetUpdatedMap(appDpy, XkbKeySymsMask, 
qt_xkb_desc) 
== Success);
                /* if you also keep track of group names, do XkbGetNameChanges here */
                return success;
        else
                return true;
}

3.5. When cleaning up:

XkbFreeKeyboard(my_xkb_desc, 0, TRUE);

4. Use this:

XkbLockGroup( appDpy, XkbUseCoreKbd, my_group );



=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to