Exemplo n.º 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);
}
Exemplo n.º 2
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;
}