Beispiel #1
0
static void
upload_xkb_description (Display              *xdisplay,
                        const gchar          *rules_file_path,
                        XkbRF_VarDefsRec     *var_defs,
                        XkbComponentNamesRec *comp_names)
{
  XkbDescRec *xkb_desc;
  gchar *rules_file;

  /* Upload it to the X server using the same method as setxkbmap */
  xkb_desc = XkbGetKeyboardByName (xdisplay,
                                   XkbUseCoreKbd,
                                   comp_names,
                                   XkbGBN_AllComponentsMask,
                                   XkbGBN_AllComponentsMask &
                                   (~XkbGBN_GeometryMask), True);
  if (!xkb_desc)
    {
      g_warning ("Couldn't upload new XKB keyboard description");
      return;
    }

  XkbFreeKeyboard (xkb_desc, 0, True);

  rules_file = g_path_get_basename (rules_file_path);

  if (!XkbRF_SetNamesProp (xdisplay, rules_file, var_defs))
    g_warning ("Couldn't update the XKB root window property");

  g_free (rules_file);
}
void KeyboardLayoutWidget::setKeyboard(XkbComponentNamesPtr names)
{
    release();
    if (xkb)
        XkbFreeKeyboard(xkb, 0, TRUE);
    if (names) {
        xkb = XkbGetKeyboardByName (QX11Info::display(), XkbUseCoreKbd,
                      names, 0,
                      XkbGBN_GeometryMask |
                      XkbGBN_KeyNamesMask |
                      XkbGBN_OtherNamesMask |
                      XkbGBN_ClientSymbolsMask |
                      XkbGBN_IndicatorMapMask, FALSE);
        xkbOnDisplay = FALSE;
    } else {
        xkb = XkbGetKeyboard (QX11Info::display(),
                           XkbGBN_GeometryMask |
                           XkbGBN_KeyNamesMask |
                           XkbGBN_OtherNamesMask |
                           XkbGBN_SymbolsMask |
                           XkbGBN_IndicatorMapMask,
                           XkbUseCoreKbd);
        XkbGetNames (QX11Info::display(), XkbAllNamesMask, xkb);
        xkbOnDisplay = TRUE;
    }

    if (xkb == NULL)
        return;

    alloc ();
    init();
    initColors();
    generatePixmap(true);
    repaint();
}
Beispiel #3
0
Bool
applyComponentNames(void)
{
    if (!checkName(settings.types.value, "types"))
        return False;
    if (!checkName(settings.compat.value, "compat"))
        return False;
    if (!checkName(settings.symbols.value, "symbols"))
        return False;
    if (!checkName(settings.keycodes.value, "keycodes"))
        return False;
    if (!checkName(settings.geometry.value, "geometry"))
        return False;
    if (!checkName(settings.keymap.value, "keymap"))
        return False;

    if (verbose > 5)
    {
        MSG("Trying to build keymap using the following components:\n");
        dumpNames(False, True);
    }
    /* Upload the new description to the server. */
    if (dpy && !print && !query)
    {
        XkbComponentNamesRec cmdNames;
        cmdNames.types = settings.types.value;
        cmdNames.compat = settings.compat.value;
        cmdNames.symbols = settings.symbols.value;
        cmdNames.keycodes = settings.keycodes.value;
        cmdNames.geometry = settings.geometry.value;
        cmdNames.keymap = settings.keymap.value;
        xkb = XkbGetKeyboardByName(dpy, deviceSpec, &cmdNames,
                                   XkbGBN_AllComponentsMask,
                                   XkbGBN_AllComponentsMask &
                                   (~XkbGBN_GeometryMask), True);
        if (!xkb)
        {
            ERR("Error loading new keyboard description\n");
            return False;
        }
        /* update the XKB root property */
        if (settings.rules.value && (rdefs.model || rdefs.layout))
        {
            if (!XkbRF_SetNamesProp(dpy, settings.rules.value, &rdefs))
            {
                VMSG(0, "Error updating the XKB names property\n");
            }
        }
    }
    if (print)
    {
        printKeymap();
    }
    if (query)
    {
        dumpNames(True, False);
    }
    return True;
}
XkbDescPtr
XkbGetKeyboard(Display *dpy,unsigned which,unsigned deviceSpec)
{
    return XkbGetKeyboardByName(dpy,deviceSpec,NULL,which,which,False);
}