2006-11-26 11:13:41 -07:00
|
|
|
/************************************************************
|
|
|
|
Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
|
|
|
|
|
|
|
|
Permission to use, copy, modify, and distribute this
|
|
|
|
software and its documentation for any purpose and without
|
|
|
|
fee is hereby granted, provided that the above copyright
|
|
|
|
notice appear in all copies and that both that copyright
|
|
|
|
notice and this permission notice appear in supporting
|
2015-09-16 13:10:19 -06:00
|
|
|
documentation, and that the name of Silicon Graphics not be
|
|
|
|
used in advertising or publicity pertaining to distribution
|
2006-11-26 11:13:41 -07:00
|
|
|
of the software without specific prior written permission.
|
2015-09-16 13:10:19 -06:00
|
|
|
Silicon Graphics makes no representation about the suitability
|
2006-11-26 11:13:41 -07:00
|
|
|
of this software for any purpose. It is provided "as is"
|
|
|
|
without any express or implied warranty.
|
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
|
|
|
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
2006-11-26 11:13:41 -07:00
|
|
|
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
2015-09-16 13:10:19 -06:00
|
|
|
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
|
|
|
|
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
|
|
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
2006-11-26 11:13:41 -07:00
|
|
|
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
|
|
|
|
THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
|
|
|
********************************************************/
|
|
|
|
|
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <xkb-config.h>
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xproto.h>
|
|
|
|
#include <X11/keysym.h>
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include "misc.h"
|
|
|
|
#include "inputstr.h"
|
|
|
|
#include "opaque.h"
|
|
|
|
#include "property.h"
|
2010-12-05 08:36:02 -07:00
|
|
|
#include "scrnintstr.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
#define XKBSRV_NEED_FILE_FUNCS
|
2007-11-24 10:55:21 -07:00
|
|
|
#include <xkbsrv.h>
|
2008-11-02 08:26:08 -07:00
|
|
|
#include "xkbgeom.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
#include <X11/extensions/XKMformat.h>
|
2008-11-02 08:26:08 -07:00
|
|
|
#include "xkbfile.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
#include "xkb.h"
|
|
|
|
|
|
|
|
#define CREATE_ATOM(s) MakeAtom(s,sizeof(s)-1,1)
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
#if defined(__alpha) || defined(__alpha__)
|
2006-11-26 11:13:41 -07:00
|
|
|
#define LED_COMPOSE 2
|
|
|
|
#define LED_CAPS 3
|
|
|
|
#define LED_SCROLL 4
|
|
|
|
#define LED_NUM 5
|
|
|
|
#define PHYS_LEDS 0x1f
|
|
|
|
#else
|
2017-12-08 08:01:59 -07:00
|
|
|
#ifdef __sun
|
2006-11-26 11:13:41 -07:00
|
|
|
#define LED_NUM 1
|
|
|
|
#define LED_SCROLL 2
|
|
|
|
#define LED_COMPOSE 3
|
|
|
|
#define LED_CAPS 4
|
|
|
|
#define PHYS_LEDS 0x0f
|
|
|
|
#else
|
|
|
|
#define LED_CAPS 1
|
|
|
|
#define LED_NUM 2
|
|
|
|
#define LED_SCROLL 3
|
|
|
|
#define PHYS_LEDS 0x07
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define MAX_TOC 16
|
2012-06-10 07:21:05 -06:00
|
|
|
typedef struct _SrvXkmInfo {
|
|
|
|
DeviceIntPtr dev;
|
|
|
|
FILE *file;
|
|
|
|
XkbDescPtr xkb;
|
2006-11-26 11:13:41 -07:00
|
|
|
} SrvXkmInfo;
|
|
|
|
|
|
|
|
/***====================================================================***/
|
|
|
|
|
|
|
|
#ifndef XKB_DFLT_RULES_PROP
|
2010-07-27 13:02:24 -06:00
|
|
|
#define XKB_DFLT_RULES_PROP TRUE
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
const char *XkbBaseDirectory = XKB_BASE_DIRECTORY;
|
|
|
|
const char *XkbBinDirectory = XKB_BIN_DIRECTORY;
|
|
|
|
static int XkbWantAccessX = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static char *XkbRulesDflt = NULL;
|
|
|
|
static char *XkbModelDflt = NULL;
|
|
|
|
static char *XkbLayoutDflt = NULL;
|
|
|
|
static char *XkbVariantDflt = NULL;
|
|
|
|
static char *XkbOptionsDflt = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static char *XkbRulesUsed = NULL;
|
|
|
|
static char *XkbModelUsed = NULL;
|
|
|
|
static char *XkbLayoutUsed = NULL;
|
|
|
|
static char *XkbVariantUsed = NULL;
|
|
|
|
static char *XkbOptionsUsed = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static XkbDescPtr xkb_cached_map = NULL;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static Bool XkbWantRulesProp = XKB_DFLT_RULES_PROP;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/***====================================================================***/
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
/**
|
|
|
|
* Get the current default XKB rules.
|
|
|
|
* Caller must free the data in rmlvo.
|
|
|
|
*/
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbGetRulesDflts(XkbRMLVOSet * rmlvo)
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
rmlvo->rules = strdup(XkbRulesDflt ? XkbRulesDflt : XKB_DFLT_RULES);
|
|
|
|
rmlvo->model = strdup(XkbModelDflt ? XkbModelDflt : XKB_DFLT_MODEL);
|
|
|
|
rmlvo->layout = strdup(XkbLayoutDflt ? XkbLayoutDflt : XKB_DFLT_LAYOUT);
|
|
|
|
rmlvo->variant = strdup(XkbVariantDflt ? XkbVariantDflt : XKB_DFLT_VARIANT);
|
|
|
|
rmlvo->options = strdup(XkbOptionsDflt ? XkbOptionsDflt : XKB_DFLT_OPTIONS);
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbFreeRMLVOSet(XkbRMLVOSet * rmlvo, Bool freeRMLVO)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2010-07-27 13:02:24 -06:00
|
|
|
if (!rmlvo)
|
|
|
|
return;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
free(rmlvo->rules);
|
|
|
|
free(rmlvo->model);
|
|
|
|
free(rmlvo->layout);
|
|
|
|
free(rmlvo->variant);
|
|
|
|
free(rmlvo->options);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
if (freeRMLVO)
|
2010-12-05 08:36:02 -07:00
|
|
|
free(rmlvo);
|
2010-07-27 13:02:24 -06:00
|
|
|
else
|
|
|
|
memset(rmlvo, 0, sizeof(XkbRMLVOSet));
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static Bool
|
2014-09-27 11:52:59 -06:00
|
|
|
XkbWriteRulesProp(ClientPtr client, void *closure)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int len, out;
|
|
|
|
Atom name;
|
|
|
|
char *pval;
|
|
|
|
|
|
|
|
len = (XkbRulesUsed ? strlen(XkbRulesUsed) : 0);
|
|
|
|
len += (XkbModelUsed ? strlen(XkbModelUsed) : 0);
|
|
|
|
len += (XkbLayoutUsed ? strlen(XkbLayoutUsed) : 0);
|
|
|
|
len += (XkbVariantUsed ? strlen(XkbVariantUsed) : 0);
|
|
|
|
len += (XkbOptionsUsed ? strlen(XkbOptionsUsed) : 0);
|
|
|
|
if (len < 1)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
len += 5; /* trailing NULs */
|
|
|
|
|
|
|
|
name =
|
|
|
|
MakeAtom(_XKB_RF_NAMES_PROP_ATOM, strlen(_XKB_RF_NAMES_PROP_ATOM), 1);
|
|
|
|
if (name == None) {
|
|
|
|
ErrorF("[xkb] Atom error: %s not created\n", _XKB_RF_NAMES_PROP_ATOM);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
pval = (char *) malloc(len);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!pval) {
|
2012-06-10 07:21:05 -06:00
|
|
|
ErrorF("[xkb] Allocation error: %s proprerty not created\n",
|
|
|
|
_XKB_RF_NAMES_PROP_ATOM);
|
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
out = 0;
|
2010-07-27 13:02:24 -06:00
|
|
|
if (XkbRulesUsed) {
|
2012-06-10 07:21:05 -06:00
|
|
|
strcpy(&pval[out], XkbRulesUsed);
|
|
|
|
out += strlen(XkbRulesUsed);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
pval[out++] = '\0';
|
2006-11-26 11:13:41 -07:00
|
|
|
if (XkbModelUsed) {
|
2012-06-10 07:21:05 -06:00
|
|
|
strcpy(&pval[out], XkbModelUsed);
|
|
|
|
out += strlen(XkbModelUsed);
|
|
|
|
}
|
|
|
|
pval[out++] = '\0';
|
2006-11-26 11:13:41 -07:00
|
|
|
if (XkbLayoutUsed) {
|
2012-06-10 07:21:05 -06:00
|
|
|
strcpy(&pval[out], XkbLayoutUsed);
|
|
|
|
out += strlen(XkbLayoutUsed);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
pval[out++] = '\0';
|
2006-11-26 11:13:41 -07:00
|
|
|
if (XkbVariantUsed) {
|
2012-06-10 07:21:05 -06:00
|
|
|
strcpy(&pval[out], XkbVariantUsed);
|
|
|
|
out += strlen(XkbVariantUsed);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
pval[out++] = '\0';
|
2006-11-26 11:13:41 -07:00
|
|
|
if (XkbOptionsUsed) {
|
2012-06-10 07:21:05 -06:00
|
|
|
strcpy(&pval[out], XkbOptionsUsed);
|
|
|
|
out += strlen(XkbOptionsUsed);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
pval[out++] = '\0';
|
|
|
|
if (out != len) {
|
|
|
|
ErrorF("[xkb] Internal Error! bad size (%d!=%d) for _XKB_RULES_NAMES\n",
|
|
|
|
out, len);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
dixChangeWindowProperty(serverClient, screenInfo.screens[0]->root, name,
|
|
|
|
XA_STRING, 8, PropModeReplace, len, pval, TRUE);
|
2010-12-05 08:36:02 -07:00
|
|
|
free(pval);
|
2010-07-27 13:02:24 -06:00
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
void
|
|
|
|
XkbInitRules(XkbRMLVOSet *rmlvo,
|
|
|
|
const char *rules,
|
|
|
|
const char *model,
|
|
|
|
const char *layout,
|
|
|
|
const char *variant,
|
|
|
|
const char *options)
|
|
|
|
{
|
|
|
|
rmlvo->rules = rules ? xnfstrdup(rules) : NULL;
|
|
|
|
rmlvo->model = model ? xnfstrdup(model) : NULL;
|
|
|
|
rmlvo->layout = layout ? xnfstrdup(layout) : NULL;
|
|
|
|
rmlvo->variant = variant ? xnfstrdup(variant) : NULL;
|
|
|
|
rmlvo->options = options ? xnfstrdup(options) : NULL;
|
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbSetRulesUsed(XkbRMLVOSet * rmlvo)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2010-12-05 08:36:02 -07:00
|
|
|
free(XkbRulesUsed);
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbRulesUsed = (rmlvo->rules ? Xstrdup(rmlvo->rules) : NULL);
|
2010-12-05 08:36:02 -07:00
|
|
|
free(XkbModelUsed);
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbModelUsed = (rmlvo->model ? Xstrdup(rmlvo->model) : NULL);
|
2010-12-05 08:36:02 -07:00
|
|
|
free(XkbLayoutUsed);
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbLayoutUsed = (rmlvo->layout ? Xstrdup(rmlvo->layout) : NULL);
|
2010-12-05 08:36:02 -07:00
|
|
|
free(XkbVariantUsed);
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbVariantUsed = (rmlvo->variant ? Xstrdup(rmlvo->variant) : NULL);
|
2010-12-05 08:36:02 -07:00
|
|
|
free(XkbOptionsUsed);
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbOptionsUsed = (rmlvo->options ? Xstrdup(rmlvo->options) : NULL);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (XkbWantRulesProp)
|
2012-06-10 07:21:05 -06:00
|
|
|
QueueWorkProc(XkbWriteRulesProp, NULL, NULL);
|
2006-11-26 11:13:41 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbSetRulesDflts(XkbRMLVOSet * rmlvo)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2010-07-27 13:02:24 -06:00
|
|
|
if (rmlvo->rules) {
|
2010-12-05 08:36:02 -07:00
|
|
|
free(XkbRulesDflt);
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbRulesDflt = Xstrdup(rmlvo->rules);
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
if (rmlvo->model) {
|
2012-06-10 07:21:05 -06:00
|
|
|
free(XkbModelDflt);
|
|
|
|
XkbModelDflt = Xstrdup(rmlvo->model);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
if (rmlvo->layout) {
|
2012-06-10 07:21:05 -06:00
|
|
|
free(XkbLayoutDflt);
|
|
|
|
XkbLayoutDflt = Xstrdup(rmlvo->layout);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
if (rmlvo->variant) {
|
2012-06-10 07:21:05 -06:00
|
|
|
free(XkbVariantDflt);
|
|
|
|
XkbVariantDflt = Xstrdup(rmlvo->variant);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
if (rmlvo->options) {
|
2012-06-10 07:21:05 -06:00
|
|
|
free(XkbOptionsDflt);
|
|
|
|
XkbOptionsDflt = Xstrdup(rmlvo->options);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:27:46 -06:00
|
|
|
void
|
|
|
|
XkbDeleteRulesUsed(void)
|
|
|
|
{
|
|
|
|
free(XkbRulesUsed);
|
|
|
|
XkbRulesUsed = NULL;
|
|
|
|
free(XkbModelUsed);
|
|
|
|
XkbModelUsed = NULL;
|
|
|
|
free(XkbLayoutUsed);
|
|
|
|
XkbLayoutUsed = NULL;
|
|
|
|
free(XkbVariantUsed);
|
|
|
|
XkbVariantUsed = NULL;
|
|
|
|
free(XkbOptionsUsed);
|
|
|
|
XkbOptionsUsed = NULL;
|
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
void
|
2010-07-27 13:02:24 -06:00
|
|
|
XkbDeleteRulesDflts(void)
|
2009-09-06 13:44:18 -06:00
|
|
|
{
|
2010-12-05 08:36:02 -07:00
|
|
|
free(XkbRulesDflt);
|
2010-07-27 13:02:24 -06:00
|
|
|
XkbRulesDflt = NULL;
|
2010-12-05 08:36:02 -07:00
|
|
|
free(XkbModelDflt);
|
2009-09-06 13:44:18 -06:00
|
|
|
XkbModelDflt = NULL;
|
2010-12-05 08:36:02 -07:00
|
|
|
free(XkbLayoutDflt);
|
2009-09-06 13:44:18 -06:00
|
|
|
XkbLayoutDflt = NULL;
|
2010-12-05 08:36:02 -07:00
|
|
|
free(XkbVariantDflt);
|
2009-09-06 13:44:18 -06:00
|
|
|
XkbVariantDflt = NULL;
|
2010-12-05 08:36:02 -07:00
|
|
|
free(XkbOptionsDflt);
|
2009-09-06 13:44:18 -06:00
|
|
|
XkbOptionsDflt = NULL;
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
XkbFreeKeyboard(xkb_cached_map, XkbAllComponentsMask, TRUE);
|
2009-09-06 13:44:18 -06:00
|
|
|
xkb_cached_map = NULL;
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
#define DIFFERS(a, b) (strcmp((a) ? (a) : "", (b) ? (b) : "") != 0)
|
|
|
|
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbCompareUsedRMLVO(XkbRMLVOSet * rmlvo)
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
|
|
|
if (DIFFERS(rmlvo->rules, XkbRulesUsed) ||
|
|
|
|
DIFFERS(rmlvo->model, XkbModelUsed) ||
|
|
|
|
DIFFERS(rmlvo->layout, XkbLayoutUsed) ||
|
|
|
|
DIFFERS(rmlvo->variant, XkbVariantUsed) ||
|
|
|
|
DIFFERS(rmlvo->options, XkbOptionsUsed))
|
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef DIFFERS
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/***====================================================================***/
|
|
|
|
|
|
|
|
#include "xkbDflts.h"
|
|
|
|
|
|
|
|
static Bool
|
2008-11-02 08:26:08 -07:00
|
|
|
XkbInitKeyTypes(XkbDescPtr xkb)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2008-11-02 08:26:08 -07:00
|
|
|
if (xkb->defined & XkmTypesMask)
|
2010-07-27 13:02:24 -06:00
|
|
|
return TRUE;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
initTypeNames(NULL);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (XkbAllocClientMap(xkb, XkbKeyTypesMask, num_dflt_types) != Success)
|
|
|
|
return FALSE;
|
|
|
|
if (XkbCopyKeyTypes(dflt_types, xkb->map->types, num_dflt_types) != Success) {
|
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
xkb->map->size_types = xkb->map->num_types = num_dflt_types;
|
2010-07-27 13:02:24 -06:00
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-11-02 08:26:08 -07:00
|
|
|
XkbInitRadioGroups(XkbSrvInfoPtr xkbi)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
xkbi->nRadioGroups = 0;
|
|
|
|
xkbi->radioGroups = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Status
|
2008-11-02 08:26:08 -07:00
|
|
|
XkbInitCompatStructs(XkbDescPtr xkb)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
register int i;
|
|
|
|
XkbCompatMapPtr compat;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
if (xkb->defined & XkmCompatMapMask)
|
2010-07-27 13:02:24 -06:00
|
|
|
return TRUE;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (XkbAllocCompatMap(xkb, XkbAllCompatMask, num_dfltSI) != Success)
|
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
compat = xkb->compat;
|
|
|
|
if (compat->sym_interpret) {
|
2012-06-10 07:21:05 -06:00
|
|
|
compat->num_si = num_dfltSI;
|
|
|
|
memcpy((char *) compat->sym_interpret, (char *) dfltSI, sizeof(dfltSI));
|
|
|
|
}
|
|
|
|
for (i = 0; i < XkbNumKbdGroups; i++) {
|
|
|
|
compat->groups[i] = compatMap.groups[i];
|
|
|
|
if (compat->groups[i].vmods != 0) {
|
|
|
|
unsigned mask;
|
|
|
|
|
|
|
|
mask = XkbMaskForVMask(xkb, compat->groups[i].vmods);
|
|
|
|
compat->groups[i].mask = compat->groups[i].real_mods | mask;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
compat->groups[i].mask = compat->groups[i].real_mods;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-11-02 08:26:08 -07:00
|
|
|
XkbInitSemantics(XkbDescPtr xkb)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2008-11-02 08:26:08 -07:00
|
|
|
XkbInitKeyTypes(xkb);
|
|
|
|
XkbInitCompatStructs(xkb);
|
2006-11-26 11:13:41 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***====================================================================***/
|
|
|
|
|
|
|
|
static Status
|
2008-11-02 08:26:08 -07:00
|
|
|
XkbInitNames(XkbSrvInfoPtr xkbi)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbDescPtr xkb;
|
|
|
|
XkbNamesPtr names;
|
|
|
|
Status rtrn;
|
|
|
|
Atom unknown;
|
|
|
|
|
|
|
|
xkb = xkbi->desc;
|
|
|
|
if ((rtrn = XkbAllocNames(xkb, XkbAllNamesMask, 0, 0)) != Success)
|
|
|
|
return rtrn;
|
|
|
|
unknown = CREATE_ATOM("unknown");
|
2006-11-26 11:13:41 -07:00
|
|
|
names = xkb->names;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (names->keycodes == None)
|
|
|
|
names->keycodes = unknown;
|
|
|
|
if (names->geometry == None)
|
|
|
|
names->geometry = unknown;
|
|
|
|
if (names->phys_symbols == None)
|
|
|
|
names->phys_symbols = unknown;
|
|
|
|
if (names->symbols == None)
|
|
|
|
names->symbols = unknown;
|
|
|
|
if (names->types == None)
|
|
|
|
names->types = unknown;
|
|
|
|
if (names->compat == None)
|
|
|
|
names->compat = unknown;
|
2008-11-02 08:26:08 -07:00
|
|
|
if (!(xkb->defined & XkmVirtualModsMask)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (names->vmods[vmod_NumLock] == None)
|
|
|
|
names->vmods[vmod_NumLock] = CREATE_ATOM("NumLock");
|
|
|
|
if (names->vmods[vmod_Alt] == None)
|
|
|
|
names->vmods[vmod_Alt] = CREATE_ATOM("Alt");
|
|
|
|
if (names->vmods[vmod_AltGr] == None)
|
|
|
|
names->vmods[vmod_AltGr] = CREATE_ATOM("ModeSwitch");
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
if (!(xkb->defined & XkmIndicatorsMask) ||
|
|
|
|
!(xkb->defined & XkmGeometryMask)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
initIndicatorNames(NULL, xkb);
|
|
|
|
if (names->indicators[LED_CAPS - 1] == None)
|
|
|
|
names->indicators[LED_CAPS - 1] = CREATE_ATOM("Caps Lock");
|
|
|
|
if (names->indicators[LED_NUM - 1] == None)
|
|
|
|
names->indicators[LED_NUM - 1] = CREATE_ATOM("Num Lock");
|
|
|
|
if (names->indicators[LED_SCROLL - 1] == None)
|
|
|
|
names->indicators[LED_SCROLL - 1] = CREATE_ATOM("Scroll Lock");
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef LED_COMPOSE
|
2012-06-10 07:21:05 -06:00
|
|
|
if (names->indicators[LED_COMPOSE - 1] == None)
|
|
|
|
names->indicators[LED_COMPOSE - 1] = CREATE_ATOM("Compose");
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (xkb->geom != NULL)
|
|
|
|
names->geometry = xkb->geom->name;
|
|
|
|
else
|
|
|
|
names->geometry = unknown;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Status
|
2008-11-02 08:26:08 -07:00
|
|
|
XkbInitIndicatorMap(XkbSrvInfoPtr xkbi)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbDescPtr xkb;
|
|
|
|
XkbIndicatorPtr map;
|
|
|
|
XkbSrvLedInfoPtr sli;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
xkb = xkbi->desc;
|
|
|
|
if (XkbAllocIndicatorMaps(xkb) != Success)
|
|
|
|
return BadAlloc;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
if (!(xkb->defined & XkmIndicatorsMask)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
map = xkb->indicators;
|
2008-11-02 08:26:08 -07:00
|
|
|
map->phys_indicators = PHYS_LEDS;
|
2012-06-10 07:21:05 -06:00
|
|
|
map->maps[LED_CAPS - 1].flags = XkbIM_NoExplicit;
|
|
|
|
map->maps[LED_CAPS - 1].which_mods = XkbIM_UseLocked;
|
|
|
|
map->maps[LED_CAPS - 1].mods.mask = LockMask;
|
|
|
|
map->maps[LED_CAPS - 1].mods.real_mods = LockMask;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
map->maps[LED_NUM - 1].flags = XkbIM_NoExplicit;
|
|
|
|
map->maps[LED_NUM - 1].which_mods = XkbIM_UseLocked;
|
|
|
|
map->maps[LED_NUM - 1].mods.mask = 0;
|
|
|
|
map->maps[LED_NUM - 1].mods.real_mods = 0;
|
|
|
|
map->maps[LED_NUM - 1].mods.vmods = vmod_NumLockMask;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
map->maps[LED_SCROLL - 1].flags = XkbIM_NoExplicit;
|
|
|
|
map->maps[LED_SCROLL - 1].which_mods = XkbIM_UseLocked;
|
|
|
|
map->maps[LED_SCROLL - 1].mods.mask = Mod3Mask;
|
|
|
|
map->maps[LED_SCROLL - 1].mods.real_mods = Mod3Mask;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
sli = XkbFindSrvLedInfo(xkbi->device, XkbDfltXIClass, XkbDfltXIId, 0);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (sli)
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbCheckIndicatorMaps(xkbi->device, sli, XkbAllIndicatorsMask);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Status
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbInitControls(DeviceIntPtr pXDev, XkbSrvInfoPtr xkbi)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbDescPtr xkb;
|
|
|
|
XkbControlsPtr ctrls;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
xkb = xkbi->desc;
|
2006-11-26 11:13:41 -07:00
|
|
|
/* 12/31/94 (ef) -- XXX! Should check if controls loaded from file */
|
2012-06-10 07:21:05 -06:00
|
|
|
if (XkbAllocControls(xkb, XkbAllControlsMask) != Success)
|
|
|
|
FatalError("Couldn't allocate keyboard controls\n");
|
|
|
|
ctrls = xkb->ctrls;
|
2008-11-02 08:26:08 -07:00
|
|
|
if (!(xkb->defined & XkmSymbolsMask))
|
|
|
|
ctrls->num_groups = 1;
|
2012-06-10 07:21:05 -06:00
|
|
|
ctrls->groups_wrap = XkbSetGroupInfo(1, XkbWrapIntoRange, 0);
|
2006-11-26 11:13:41 -07:00
|
|
|
ctrls->internal.mask = 0;
|
|
|
|
ctrls->internal.real_mods = 0;
|
|
|
|
ctrls->internal.vmods = 0;
|
|
|
|
ctrls->ignore_lock.mask = 0;
|
|
|
|
ctrls->ignore_lock.real_mods = 0;
|
|
|
|
ctrls->ignore_lock.vmods = 0;
|
2012-06-10 07:21:05 -06:00
|
|
|
ctrls->enabled_ctrls = XkbAccessXTimeoutMask | XkbRepeatKeysMask |
|
|
|
|
XkbMouseKeysAccelMask | XkbAudibleBellMask | XkbIgnoreGroupLockMask;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (XkbWantAccessX)
|
2012-06-10 07:21:05 -06:00
|
|
|
ctrls->enabled_ctrls |= XkbAccessXKeysMask;
|
2006-11-26 11:13:41 -07:00
|
|
|
AccessXInit(pXDev);
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
static Bool
|
|
|
|
InitKeyboardDeviceStructInternal(DeviceIntPtr dev, XkbRMLVOSet * rmlvo,
|
|
|
|
const char *keymap, int keymap_length,
|
|
|
|
BellProcPtr bell_func, KbdCtrlProcPtr ctrl_func)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int i;
|
2010-07-27 13:02:24 -06:00
|
|
|
unsigned int check;
|
|
|
|
XkbSrvInfoPtr xkbi;
|
|
|
|
XkbDescPtr xkb;
|
|
|
|
XkbSrvLedInfoPtr sli;
|
|
|
|
XkbChangesRec changes;
|
|
|
|
XkbEventCauseRec cause;
|
|
|
|
XkbRMLVOSet rmlvo_dflts = { NULL };
|
|
|
|
|
2014-05-02 13:27:46 -06:00
|
|
|
BUG_RETURN_VAL(dev == NULL, FALSE);
|
|
|
|
BUG_RETURN_VAL(dev->key != NULL, FALSE);
|
|
|
|
BUG_RETURN_VAL(dev->kbdfeed != NULL, FALSE);
|
2014-09-27 11:52:59 -06:00
|
|
|
BUG_RETURN_VAL(rmlvo && keymap, FALSE);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
if (!rmlvo && !keymap) {
|
2010-07-27 13:02:24 -06:00
|
|
|
rmlvo = &rmlvo_dflts;
|
|
|
|
XkbGetRulesDflts(rmlvo);
|
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
memset(&changes, 0, sizeof(changes));
|
|
|
|
XkbSetCauseUnknown(&cause);
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
dev->key = calloc(1, sizeof(*dev->key));
|
2010-07-27 13:02:24 -06:00
|
|
|
if (!dev->key) {
|
|
|
|
ErrorF("XKB: Failed to allocate key class\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
dev->key->sourceid = dev->id;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
dev->kbdfeed = calloc(1, sizeof(*dev->kbdfeed));
|
2010-07-27 13:02:24 -06:00
|
|
|
if (!dev->kbdfeed) {
|
|
|
|
ErrorF("XKB: Failed to allocate key feedback class\n");
|
|
|
|
goto unwind_key;
|
|
|
|
}
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
xkbi = calloc(1, sizeof(*xkbi));
|
2010-07-27 13:02:24 -06:00
|
|
|
if (!xkbi) {
|
|
|
|
ErrorF("XKB: Failed to allocate XKB info\n");
|
|
|
|
goto unwind_kbdfeed;
|
|
|
|
}
|
|
|
|
dev->key->xkbInfo = xkbi;
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
if (xkb_cached_map && (keymap || (rmlvo && !XkbCompareUsedRMLVO(rmlvo)))) {
|
2010-07-27 13:02:24 -06:00
|
|
|
XkbFreeKeyboard(xkb_cached_map, XkbAllComponentsMask, TRUE);
|
|
|
|
xkb_cached_map = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xkb_cached_map)
|
|
|
|
LogMessageVerb(X_INFO, 4, "XKB: Reusing cached keymap\n");
|
|
|
|
else {
|
2014-09-27 11:52:59 -06:00
|
|
|
if (rmlvo)
|
|
|
|
xkb_cached_map = XkbCompileKeymap(dev, rmlvo);
|
|
|
|
else
|
|
|
|
xkb_cached_map = XkbCompileKeymapFromString(dev, keymap, keymap_length);
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
if (!xkb_cached_map) {
|
|
|
|
ErrorF("XKB: Failed to compile keymap\n");
|
|
|
|
goto unwind_info;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
xkb = XkbAllocKeyboard();
|
|
|
|
if (!xkb) {
|
|
|
|
ErrorF("XKB: Failed to allocate keyboard description\n");
|
|
|
|
goto unwind_info;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
if (!XkbCopyKeymap(xkb, xkb_cached_map)) {
|
|
|
|
ErrorF("XKB: Failed to copy keymap\n");
|
|
|
|
goto unwind_desc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
xkb->defined = xkb_cached_map->defined;
|
|
|
|
xkb->flags = xkb_cached_map->flags;
|
|
|
|
xkb->device_spec = xkb_cached_map->device_spec;
|
|
|
|
xkbi->desc = xkb;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
if (xkb->min_key_code == 0)
|
|
|
|
xkb->min_key_code = 8;
|
|
|
|
if (xkb->max_key_code == 0)
|
|
|
|
xkb->max_key_code = 255;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
i = XkbNumKeys(xkb) / 3 + 1;
|
|
|
|
if (XkbAllocClientMap(xkb, XkbAllClientInfoMask, 0) != Success)
|
|
|
|
goto unwind_desc;
|
|
|
|
if (XkbAllocServerMap(xkb, XkbAllServerInfoMask, i) != Success)
|
|
|
|
goto unwind_desc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
xkbi->dfltPtrDelta = 1;
|
|
|
|
xkbi->device = dev;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
XkbInitSemantics(xkb);
|
|
|
|
XkbInitNames(xkbi);
|
|
|
|
XkbInitRadioGroups(xkbi);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
XkbInitControls(dev, xkbi);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
XkbInitIndicatorMap(xkbi);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
XkbUpdateActions(dev, xkb->min_key_code, XkbNumKeys(xkb), &changes,
|
|
|
|
&check, &cause);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2013-08-24 13:44:25 -06:00
|
|
|
if (!dev->focus)
|
|
|
|
InitFocusClassDeviceStruct(dev);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
xkbi->kbdProc = ctrl_func;
|
|
|
|
dev->kbdfeed->BellProc = bell_func;
|
|
|
|
dev->kbdfeed->CtrlProc = XkbDDXKeybdCtrlProc;
|
|
|
|
|
|
|
|
dev->kbdfeed->ctrl = defaultKeyboardControl;
|
|
|
|
if (dev->kbdfeed->ctrl.autoRepeat)
|
|
|
|
xkb->ctrls->enabled_ctrls |= XkbRepeatKeysMask;
|
|
|
|
|
|
|
|
memcpy(dev->kbdfeed->ctrl.autoRepeats, xkb->ctrls->per_key_repeat,
|
|
|
|
XkbPerKeyBitArraySize);
|
|
|
|
|
|
|
|
sli = XkbFindSrvLedInfo(dev, XkbDfltXIClass, XkbDfltXIId, 0);
|
|
|
|
if (sli)
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbCheckIndicatorMaps(dev, sli, XkbAllIndicatorsMask);
|
2010-07-27 13:02:24 -06:00
|
|
|
else
|
|
|
|
DebugF("XKB: No indicator feedback in XkbFinishInit!\n");
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
dev->kbdfeed->CtrlProc(dev, &dev->kbdfeed->ctrl);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
if (rmlvo) {
|
|
|
|
XkbSetRulesDflts(rmlvo);
|
|
|
|
XkbSetRulesUsed(rmlvo);
|
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
XkbFreeRMLVOSet(&rmlvo_dflts, FALSE);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
unwind_desc:
|
2010-07-27 13:02:24 -06:00
|
|
|
XkbFreeKeyboard(xkb, 0, TRUE);
|
2012-06-10 07:21:05 -06:00
|
|
|
unwind_info:
|
2010-12-05 08:36:02 -07:00
|
|
|
free(xkbi);
|
2010-07-27 13:02:24 -06:00
|
|
|
dev->key->xkbInfo = NULL;
|
2012-06-10 07:21:05 -06:00
|
|
|
unwind_kbdfeed:
|
2010-12-05 08:36:02 -07:00
|
|
|
free(dev->kbdfeed);
|
2010-07-27 13:02:24 -06:00
|
|
|
dev->kbdfeed = NULL;
|
2012-06-10 07:21:05 -06:00
|
|
|
unwind_key:
|
2010-12-05 08:36:02 -07:00
|
|
|
free(dev->key);
|
2010-07-27 13:02:24 -06:00
|
|
|
dev->key = NULL;
|
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
_X_EXPORT Bool
|
|
|
|
InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet * rmlvo,
|
|
|
|
BellProcPtr bell_func, KbdCtrlProcPtr ctrl_func)
|
|
|
|
{
|
|
|
|
return InitKeyboardDeviceStructInternal(dev, rmlvo,
|
|
|
|
NULL, 0, bell_func, ctrl_func);
|
|
|
|
}
|
|
|
|
|
|
|
|
_X_EXPORT Bool
|
|
|
|
InitKeyboardDeviceStructFromString(DeviceIntPtr dev,
|
|
|
|
const char *keymap, int keymap_length,
|
|
|
|
BellProcPtr bell_func, KbdCtrlProcPtr ctrl_func)
|
|
|
|
{
|
|
|
|
return InitKeyboardDeviceStructInternal(dev, NULL,
|
|
|
|
keymap, keymap_length,
|
|
|
|
bell_func, ctrl_func);
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
/***====================================================================***/
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/*
|
2015-09-16 13:10:19 -06:00
|
|
|
* Be very careful about what does and doesn't get freed by this
|
|
|
|
* function. To reduce fragmentation, XkbInitDevice allocates a
|
|
|
|
* single huge block per device and divides it up into most of the
|
2012-06-10 07:21:05 -06:00
|
|
|
* fixed-size structures for the device. Don't free anything that
|
|
|
|
* is part of this larger block.
|
|
|
|
*/
|
2006-11-26 11:13:41 -07:00
|
|
|
void
|
|
|
|
XkbFreeInfo(XkbSrvInfoPtr xkbi)
|
|
|
|
{
|
2010-12-05 08:36:02 -07:00
|
|
|
free(xkbi->radioGroups);
|
|
|
|
xkbi->radioGroups = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (xkbi->mouseKeyTimer) {
|
2012-06-10 07:21:05 -06:00
|
|
|
TimerFree(xkbi->mouseKeyTimer);
|
|
|
|
xkbi->mouseKeyTimer = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (xkbi->slowKeysTimer) {
|
2012-06-10 07:21:05 -06:00
|
|
|
TimerFree(xkbi->slowKeysTimer);
|
|
|
|
xkbi->slowKeysTimer = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (xkbi->bounceKeysTimer) {
|
2012-06-10 07:21:05 -06:00
|
|
|
TimerFree(xkbi->bounceKeysTimer);
|
|
|
|
xkbi->bounceKeysTimer = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (xkbi->repeatKeyTimer) {
|
2012-06-10 07:21:05 -06:00
|
|
|
TimerFree(xkbi->repeatKeyTimer);
|
|
|
|
xkbi->repeatKeyTimer = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (xkbi->krgTimer) {
|
2012-06-10 07:21:05 -06:00
|
|
|
TimerFree(xkbi->krgTimer);
|
|
|
|
xkbi->krgTimer = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
xkbi->beepType = _BEEP_NONE;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (xkbi->beepTimer) {
|
2012-06-10 07:21:05 -06:00
|
|
|
TimerFree(xkbi->beepTimer);
|
|
|
|
xkbi->beepTimer = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (xkbi->desc) {
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbFreeKeyboard(xkbi->desc, XkbAllComponentsMask, TRUE);
|
|
|
|
xkbi->desc = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
free(xkbi);
|
2006-11-26 11:13:41 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***====================================================================***/
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
extern int XkbDfltRepeatDelay;
|
|
|
|
extern int XkbDfltRepeatInterval;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
extern unsigned short XkbDfltAccessXTimeout;
|
|
|
|
extern unsigned int XkbDfltAccessXTimeoutMask;
|
|
|
|
extern unsigned int XkbDfltAccessXFeedback;
|
|
|
|
extern unsigned char XkbDfltAccessXOptions;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbProcessArguments(int argc, char *argv[], int i)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2010-07-27 13:02:24 -06:00
|
|
|
if (strncmp(argv[i], "-xkbdir", 7) == 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (++i < argc) {
|
2007-11-24 10:55:21 -07:00
|
|
|
#if !defined(WIN32) && !defined(__CYGWIN__)
|
2012-06-10 07:21:05 -06:00
|
|
|
if (getuid() != geteuid()) {
|
|
|
|
LogMessage(X_WARNING,
|
|
|
|
"-xkbdir is not available for setuid X servers\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
{
|
|
|
|
if (strlen(argv[i]) < PATH_MAX) {
|
|
|
|
XkbBaseDirectory = argv[i];
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
LogMessage(X_ERROR, "-xkbdir pathname too long\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((strncmp(argv[i], "-accessx", 8) == 0) ||
|
|
|
|
(strncmp(argv[i], "+accessx", 8) == 0)) {
|
|
|
|
int j = 1;
|
|
|
|
|
|
|
|
if (argv[i][0] == '-')
|
|
|
|
XkbWantAccessX = 0;
|
|
|
|
else {
|
|
|
|
XkbWantAccessX = 1;
|
|
|
|
|
|
|
|
if (((i + 1) < argc) && (isdigit(argv[i + 1][0]))) {
|
|
|
|
XkbDfltAccessXTimeout = atoi(argv[++i]);
|
|
|
|
j++;
|
|
|
|
|
|
|
|
if (((i + 1) < argc) && (isdigit(argv[i + 1][0]))) {
|
|
|
|
/*
|
|
|
|
* presumption that the reasonably useful range of
|
|
|
|
* values fits in 0..MAXINT since SunOS 4 doesn't
|
|
|
|
* have strtoul.
|
|
|
|
*/
|
|
|
|
XkbDfltAccessXTimeoutMask = (unsigned int)
|
|
|
|
strtol(argv[++i], NULL, 16);
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
if (((i + 1) < argc) && (isdigit(argv[i + 1][0]))) {
|
|
|
|
if (argv[++i][0] == '1')
|
|
|
|
XkbDfltAccessXFeedback = XkbAccessXFeedbackMask;
|
|
|
|
else
|
|
|
|
XkbDfltAccessXFeedback = 0;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
if (((i + 1) < argc) && (isdigit(argv[i + 1][0]))) {
|
|
|
|
XkbDfltAccessXOptions = (unsigned char)
|
|
|
|
strtol(argv[++i], NULL, 16);
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return j;
|
|
|
|
}
|
|
|
|
if ((strcmp(argv[i], "-ardelay") == 0) || (strcmp(argv[i], "-ar1") == 0)) { /* -ardelay int */
|
|
|
|
if (++i >= argc)
|
|
|
|
UseMsg();
|
2014-05-02 13:27:46 -06:00
|
|
|
else
|
|
|
|
XkbDfltRepeatDelay = (long) atoi(argv[i]);
|
2012-06-10 07:21:05 -06:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
if ((strcmp(argv[i], "-arinterval") == 0) || (strcmp(argv[i], "-ar2") == 0)) { /* -arinterval int */
|
|
|
|
if (++i >= argc)
|
|
|
|
UseMsg();
|
2014-05-02 13:27:46 -06:00
|
|
|
else
|
|
|
|
XkbDfltRepeatInterval = (long) atoi(argv[i]);
|
2012-06-10 07:21:05 -06:00
|
|
|
return 2;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
XkbUseMsg(void)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ErrorF
|
|
|
|
("[+-]accessx [ timeout [ timeout_mask [ feedback [ options_mask] ] ] ]\n");
|
2006-11-26 11:13:41 -07:00
|
|
|
ErrorF(" enable/disable accessx key sequences\n");
|
|
|
|
ErrorF("-ardelay set XKB autorepeat delay\n");
|
|
|
|
ErrorF("-arinterval set XKB autorepeat interval\n");
|
|
|
|
}
|