Exemplo n.º 1
0
Bool
XkbWriteToServer(XkbFileInfo *result)
{
XkbDescPtr		xkb;
Display *		dpy;

    if ((result==NULL)||(result->xkb==NULL)||(result->xkb->dpy==NULL))
	return False;
    xkb= result->xkb;
    dpy= xkb->dpy;
    if (!XkbSetMap(dpy,XkbAllMapComponentsMask,xkb))
	return False;
    if (!XkbSetIndicatorMap(dpy,~0,xkb))
	return False;
#ifdef NOTYET
    if (!XkbSetControls(dpy,XkbAllControlsMask,xkb))
	return False;
#endif
    if (!XkbSetCompatMap(dpy,XkbAllCompatMask,xkb,True))
	return False;
    if (!XkbSetNames(dpy,XkbAllNamesMask,0,xkb->map->num_types,xkb))
	return False;
    if (xkb->geom) {
	if (XkbSetGeometry(dpy,xkb->device_spec,xkb->geom)!=Success)
	    return False;
    }
    return True;
#ifdef NOTYET
    switch (result->type) {
	case XkmSemanticsFile:
	    func= WriteCHdrSemantics;
	    break;
	case XkmLayoutFile:
	    func= WriteCHdrLayout;
	    break;
	case XkmKeymapFile:
	    func= WriteCHdrKeymap;
	    break;
	default:
	   _XkbLibError(_XkbErrIllegalContents,"XkbWriteToServer",result->type);
	   break;
    }
    return ok;
#endif
}
static gboolean
replace_map_keysym (DEControllerPrivateData *priv, KeyCode keycode, KeySym keysym)
{
#ifdef HAVE_XKB
  Display *dpy = spi_get_display ();
  XkbDescPtr desc;
  if (!(desc = XkbGetMap (dpy, XkbAllMapComponentsMask, XkbUseCoreKbd)))
    {
      fprintf (stderr, "ERROR getting map\n");
    }
  XFlush (dpy);
  XSync (dpy, False);
  if (desc && desc->map)
    {
      gint offset = desc->map->key_sym_map[keycode].offset;
      desc->map->syms[offset] = keysym; 
    }
  else
    {
      fprintf (stderr, "Error changing key map: empty server structure\n");
    }		
  XkbSetMap (dpy, XkbAllMapComponentsMask, desc);
  /**
   *  FIXME: the use of XkbChangeMap, and the reuse of the priv->xkb_desc structure, 
   * would be far preferable.
   * HOWEVER it does not seem to work using XFree 4.3. 
   **/
  /*	    XkbChangeMap (dpy, priv->xkb_desc, priv->changes); */
  XFlush (dpy);
  XSync (dpy, False);
  XkbFreeKeyboard (desc, 0, TRUE);

  return TRUE;
#else
  return FALSE;
#endif
}