summaryrefslogtreecommitdiff
path: root/xserver/xkb
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2014-09-27 17:53:06 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2014-09-27 17:53:06 +0000
commit4a4018aabb79405f1b50809f76e4bff4d0ead33c (patch)
treebbe31c32ce7b90f7ca8124d215cd1bc28516a259 /xserver/xkb
parent340ecc70b63a19bbc23b3ffc950d5beb49220505 (diff)
Update to xserver 1.16.1.
Tested by naddy@, jsg@ & kettenis@
Diffstat (limited to 'xserver/xkb')
-rw-r--r--xserver/xkb/Makefile.in14
-rw-r--r--xserver/xkb/ddxBeep.c10
-rw-r--r--xserver/xkb/ddxLoad.c246
-rw-r--r--xserver/xkb/maprules.c73
-rw-r--r--xserver/xkb/xkb.c26
-rw-r--r--xserver/xkb/xkbAccessX.c26
-rw-r--r--xserver/xkb/xkbActions.c108
-rw-r--r--xserver/xkb/xkbEvents.c4
-rw-r--r--xserver/xkb/xkbInit.c59
-rw-r--r--xserver/xkb/xkbUtils.c43
-rw-r--r--xserver/xkb/xkbtext.c90
-rw-r--r--xserver/xkb/xkmread.c6
12 files changed, 479 insertions, 226 deletions
diff --git a/xserver/xkb/Makefile.in b/xserver/xkb/Makefile.in
index b6995ee14..ddf9a4b40 100644
--- a/xserver/xkb/Makefile.in
+++ b/xserver/xkb/Makefile.in
@@ -202,6 +202,8 @@ DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
DEFAULT_LOGDIR = @DEFAULT_LOGDIR@
DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
+DEFAULT_XDG_DATA_HOME = @DEFAULT_XDG_DATA_HOME@
+DEFAULT_XDG_DATA_HOME_LOGDIR = @DEFAULT_XDG_DATA_HOME_LOGDIR@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DGA_CFLAGS = @DGA_CFLAGS@
@@ -246,6 +248,10 @@ FONTROOTDIR = @FONTROOTDIR@
FONTTTFDIR = @FONTTTFDIR@
FONTTYPE1DIR = @FONTTYPE1DIR@
FOP = @FOP@
+GBM_CFLAGS = @GBM_CFLAGS@
+GBM_LIBS = @GBM_LIBS@
+GLAMOR_CFLAGS = @GLAMOR_CFLAGS@
+GLAMOR_LIBS = @GLAMOR_LIBS@
GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
GLX_DEFINES = @GLX_DEFINES@
GLX_SYS_LIBS = @GLX_SYS_LIBS@
@@ -348,7 +354,10 @@ SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@
STRICT_CFLAGS = @STRICT_CFLAGS@
STRIP = @STRIP@
STYLESHEET_SRCDIR = @STYLESHEET_SRCDIR@
+SUID_WRAPPER_DIR = @SUID_WRAPPER_DIR@
SYSCONFDIR = @SYSCONFDIR@
+SYSTEMD_DAEMON_CFLAGS = @SYSTEMD_DAEMON_CFLAGS@
+SYSTEMD_DAEMON_LIBS = @SYSTEMD_DAEMON_LIBS@
TRADITIONALCPPFLAGS = @TRADITIONALCPPFLAGS@
TSLIB_CFLAGS = @TSLIB_CFLAGS@
TSLIB_LIBS = @TSLIB_LIBS@
@@ -357,6 +366,7 @@ UDEV_LIBS = @UDEV_LIBS@
UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
VERSION = @VERSION@
+WAYLAND_SCANNER = @WAYLAND_SCANNER@
WINDOWSWM_CFLAGS = @WINDOWSWM_CFLAGS@
WINDOWSWM_LIBS = @WINDOWSWM_LIBS@
WINDRES = @WINDRES@
@@ -423,6 +433,10 @@ XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@
XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@
XVFB_LIBS = @XVFB_LIBS@
XVFB_SYS_LIBS = @XVFB_SYS_LIBS@
+XWAYLANDMODULES_CFLAGS = @XWAYLANDMODULES_CFLAGS@
+XWAYLANDMODULES_LIBS = @XWAYLANDMODULES_LIBS@
+XWAYLAND_LIBS = @XWAYLAND_LIBS@
+XWAYLAND_SYS_LIBS = @XWAYLAND_SYS_LIBS@
XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@
XWINMODULES_LIBS = @XWINMODULES_LIBS@
XWIN_LIBS = @XWIN_LIBS@
diff --git a/xserver/xkb/ddxBeep.c b/xserver/xkb/ddxBeep.c
index f95d0ee81..caf78c94d 100644
--- a/xserver/xkb/ddxBeep.c
+++ b/xserver/xkb/ddxBeep.c
@@ -113,7 +113,7 @@ _XkbDDXBeepInitAtoms(void)
}
static CARD32
-_XkbDDXBeepExpire(OsTimerPtr timer, CARD32 now, pointer arg)
+_XkbDDXBeepExpire(OsTimerPtr timer, CARD32 now, void *arg)
{
DeviceIntPtr dev = (DeviceIntPtr) arg;
KbdFeedbackPtr feed;
@@ -300,11 +300,11 @@ _XkbDDXBeepExpire(OsTimerPtr timer, CARD32 now, pointer arg)
ctrl->bell_duration = duration;
ctrl->bell_pitch = pitch;
if (xkbInfo->beepCount == 0) {
- XkbHandleBell(0, 0, dev, ctrl->bell, (pointer) ctrl,
+ XkbHandleBell(0, 0, dev, ctrl->bell, (void *) ctrl,
KbdFeedbackClass, name, None, NULL);
}
else if (xkbInfo->desc->ctrls->enabled_ctrls & XkbAudibleBellMask) {
- (*dev->kbdfeed->BellProc) (ctrl->bell, dev, (pointer) ctrl,
+ (*dev->kbdfeed->BellProc) (ctrl->bell, dev, (void *) ctrl,
KbdFeedbackClass);
}
ctrl->bell_duration = oldDuration;
@@ -340,11 +340,11 @@ XkbDDXAccessXBeep(DeviceIntPtr dev, unsigned what, unsigned which)
xkbInfo->beepType = what;
xkbInfo->beepCount = 0;
- next = _XkbDDXBeepExpire(NULL, 0, (pointer) dev);
+ next = _XkbDDXBeepExpire(NULL, 0, (void *) dev);
if (next > 0) {
xkbInfo->beepTimer = TimerSet(xkbInfo->beepTimer,
0, next,
- _XkbDDXBeepExpire, (pointer) dev);
+ _XkbDDXBeepExpire, (void *) dev);
}
return 1;
}
diff --git a/xserver/xkb/ddxLoad.c b/xserver/xkb/ddxLoad.c
index d462957f4..1dc0e4eee 100644
--- a/xserver/xkb/ddxLoad.c
+++ b/xserver/xkb/ddxLoad.c
@@ -68,6 +68,9 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define PATHSEPARATOR "/"
#endif
+static unsigned
+LoadXKM(unsigned want, unsigned need, const char *keymap, XkbDescPtr *xkbRtrn);
+
static void
OutputDirectory(char *outdir, size_t size)
{
@@ -90,11 +93,17 @@ OutputDirectory(char *outdir, size_t size)
}
}
-static Bool
-XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
- XkbComponentNamesPtr names,
- unsigned want,
- unsigned need, char *nameRtrn, int nameRtrnLen)
+/**
+ * Callback invoked by XkbRunXkbComp. Write to out to talk to xkbcomp.
+ */
+typedef void (*xkbcomp_buffer_callback)(FILE *out, void *userdata);
+
+/**
+ * Start xkbcomp, let the callback write into xkbcomp's stdin. When done,
+ * return a strdup'd copy of the file name we've written to.
+ */
+static char *
+RunXkbComp(xkbcomp_buffer_callback callback, void *userdata)
{
FILE *out;
char *buf = NULL, keymap[PATH_MAX], xkm_output_dir[PATH_MAX];
@@ -155,7 +164,7 @@ XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
if (!buf) {
LogMessage(X_ERROR,
"XKB: Could not invoke xkbcomp: not enough memory\n");
- return FALSE;
+ return NULL;
}
#ifndef WIN32
@@ -165,13 +174,9 @@ XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
#endif
if (out != NULL) {
-#ifdef DEBUG
- if (xkbDebugFlags) {
- ErrorF("[xkb] XkbDDXCompileKeymapByNames compiling keymap:\n");
- XkbWriteXKBKeymapForNames(stderr, names, xkb, want, need);
- }
-#endif
- XkbWriteXKBKeymapForNames(out, names, xkb, want, need);
+ /* Now write to xkbcomp */
+ (*callback)(out, userdata);
+
#ifndef WIN32
if (Pclose(out) == 0)
#else
@@ -180,14 +185,11 @@ XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
{
if (xkbDebugFlags)
DebugF("[xkb] xkb executes: %s\n", buf);
- if (nameRtrn) {
- strlcpy(nameRtrn, keymap, nameRtrnLen);
- }
free(buf);
#ifdef WIN32
unlink(tmpname);
#endif
- return TRUE;
+ return xnfstrdup(keymap);
}
else
LogMessage(X_ERROR, "Error compiling keymap (%s)\n", keymap);
@@ -203,14 +205,101 @@ XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
LogMessage(X_ERROR, "Could not open file %s\n", tmpname);
#endif
}
- if (nameRtrn)
- nameRtrn[0] = '\0';
free(buf);
- return FALSE;
+ return NULL;
+}
+
+typedef struct {
+ XkbDescPtr xkb;
+ XkbComponentNamesPtr names;
+ unsigned int want;
+ unsigned int need;
+} XkbKeymapNamesCtx;
+
+static void
+xkb_write_keymap_for_names_cb(FILE *out, void *userdata)
+{
+ XkbKeymapNamesCtx *ctx = userdata;
+#ifdef DEBUG
+ if (xkbDebugFlags) {
+ ErrorF("[xkb] XkbDDXCompileKeymapByNames compiling keymap:\n");
+ XkbWriteXKBKeymapForNames(stderr, ctx->names, ctx->xkb, ctx->want, ctx->need);
+ }
+#endif
+ XkbWriteXKBKeymapForNames(out, ctx->names, ctx->xkb, ctx->want, ctx->need);
+}
+
+static Bool
+XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
+ XkbComponentNamesPtr names,
+ unsigned want,
+ unsigned need, char *nameRtrn, int nameRtrnLen)
+{
+ char *keymap;
+ Bool rc = FALSE;
+ XkbKeymapNamesCtx ctx = {
+ .xkb = xkb,
+ .names = names,
+ .want = want,
+ .need = need
+ };
+
+ keymap = RunXkbComp(xkb_write_keymap_for_names_cb, &ctx);
+
+ if (keymap) {
+ if(nameRtrn)
+ strlcpy(nameRtrn, keymap, nameRtrnLen);
+
+ free(keymap);
+ rc = TRUE;
+ } else if (nameRtrn)
+ *nameRtrn = '\0';
+
+ return rc;
+}
+
+typedef struct {
+ const char *keymap;
+ size_t len;
+} XkbKeymapString;
+
+static void
+xkb_write_keymap_string_cb(FILE *out, void *userdata)
+{
+ XkbKeymapString *s = userdata;
+ fwrite(s->keymap, s->len, 1, out);
+}
+
+static unsigned int
+XkbDDXLoadKeymapFromString(DeviceIntPtr keybd,
+ const char *keymap, int keymap_length,
+ unsigned int want,
+ unsigned int need,
+ XkbDescPtr *xkbRtrn)
+{
+ unsigned int have;
+ char *map_name;
+ XkbKeymapString map = {
+ .keymap = keymap,
+ .len = keymap_length
+ };
+
+ *xkbRtrn = NULL;
+
+ map_name = RunXkbComp(xkb_write_keymap_string_cb, &map);
+ if (!map_name) {
+ LogMessage(X_ERROR, "XKB: Couldn't compile keymap\n");
+ return 0;
+ }
+
+ have = LoadXKM(want, need, map_name, xkbRtrn);
+ free(map_name);
+
+ return have;
}
static FILE *
-XkbDDXOpenConfigFile(char *mapName, char *fileNameRtrn, int fileNameRtrnLen)
+XkbDDXOpenConfigFile(const char *mapName, char *fileNameRtrn, int fileNameRtrnLen)
{
char buf[PATH_MAX], xkm_output_dir[PATH_MAX];
FILE *file;
@@ -245,6 +334,35 @@ XkbDDXOpenConfigFile(char *mapName, char *fileNameRtrn, int fileNameRtrnLen)
return file;
}
+static unsigned
+LoadXKM(unsigned want, unsigned need, const char *keymap, XkbDescPtr *xkbRtrn)
+{
+ FILE *file;
+ char fileName[PATH_MAX];
+ unsigned missing;
+
+ file = XkbDDXOpenConfigFile(keymap, fileName, PATH_MAX);
+ if (file == NULL) {
+ LogMessage(X_ERROR, "Couldn't open compiled keymap file %s\n",
+ fileName);
+ return 0;
+ }
+ missing = XkmReadFile(file, need, want, xkbRtrn);
+ if (*xkbRtrn == NULL) {
+ LogMessage(X_ERROR, "Error loading keymap %s\n", fileName);
+ fclose(file);
+ (void) unlink(fileName);
+ return 0;
+ }
+ else {
+ DebugF("Loaded XKB keymap %s, defined=0x%x\n", fileName,
+ (*xkbRtrn)->defined);
+ }
+ fclose(file);
+ (void) unlink(fileName);
+ return (need | want) & (~missing);
+}
+
unsigned
XkbDDXLoadKeymapByNames(DeviceIntPtr keybd,
XkbComponentNamesPtr names,
@@ -253,9 +371,6 @@ XkbDDXLoadKeymapByNames(DeviceIntPtr keybd,
XkbDescPtr *xkbRtrn, char *nameRtrn, int nameRtrnLen)
{
XkbDescPtr xkb;
- FILE *file;
- char fileName[PATH_MAX];
- unsigned missing;
*xkbRtrn = NULL;
if ((keybd == NULL) || (keybd->key == NULL) ||
@@ -275,31 +390,13 @@ XkbDDXLoadKeymapByNames(DeviceIntPtr keybd,
LogMessage(X_ERROR, "XKB: Couldn't compile keymap\n");
return 0;
}
- file = XkbDDXOpenConfigFile(nameRtrn, fileName, PATH_MAX);
- if (file == NULL) {
- LogMessage(X_ERROR, "Couldn't open compiled keymap file %s\n",
- fileName);
- return 0;
- }
- missing = XkmReadFile(file, need, want, xkbRtrn);
- if (*xkbRtrn == NULL) {
- LogMessage(X_ERROR, "Error loading keymap %s\n", fileName);
- fclose(file);
- (void) unlink(fileName);
- return 0;
- }
- else {
- DebugF("Loaded XKB keymap %s, defined=0x%x\n", fileName,
- (*xkbRtrn)->defined);
- }
- fclose(file);
- (void) unlink(fileName);
- return (need | want) & (~missing);
+
+ return LoadXKM(want, need, nameRtrn, xkbRtrn);
}
Bool
XkbDDXNamesFromRules(DeviceIntPtr keybd,
- char *rules_name,
+ const char *rules_name,
XkbRF_VarDefsPtr defs, XkbComponentNamesPtr names)
{
char buf[PATH_MAX];
@@ -390,6 +487,29 @@ XkbCompileKeymapForDevice(DeviceIntPtr dev, XkbRMLVOSet * rmlvo, int need)
return xkb;
}
+static XkbDescPtr
+KeymapOrDefaults(DeviceIntPtr dev, XkbDescPtr xkb)
+{
+ XkbRMLVOSet dflts;
+
+ if (xkb)
+ return xkb;
+
+ /* we didn't get what we really needed. And that will likely leave
+ * us with a keyboard that doesn't work. Use the defaults instead */
+ LogMessage(X_ERROR, "XKB: Failed to load keymap. Loading default "
+ "keymap instead.\n");
+
+ XkbGetRulesDflts(&dflts);
+
+ xkb = XkbCompileKeymapForDevice(dev, &dflts, 0);
+
+ XkbFreeRMLVOSet(&dflts, FALSE);
+
+ return xkb;
+}
+
+
XkbDescPtr
XkbCompileKeymap(DeviceIntPtr dev, XkbRMLVOSet * rmlvo)
{
@@ -407,20 +527,34 @@ XkbCompileKeymap(DeviceIntPtr dev, XkbRMLVOSet * rmlvo)
xkb = XkbCompileKeymapForDevice(dev, rmlvo, need);
- if (!xkb) {
- XkbRMLVOSet dflts;
-
- /* we didn't get what we really needed. And that will likely leave
- * us with a keyboard that doesn't work. Use the defaults instead */
- LogMessage(X_ERROR, "XKB: Failed to load keymap. Loading default "
- "keymap instead.\n");
+ return KeymapOrDefaults(dev, xkb);
+}
- XkbGetRulesDflts(&dflts);
+XkbDescPtr
+XkbCompileKeymapFromString(DeviceIntPtr dev,
+ const char *keymap, int keymap_length)
+{
+ XkbDescPtr xkb;
+ unsigned int need, provided;
- xkb = XkbCompileKeymapForDevice(dev, &dflts, 0);
+ if (!dev || !keymap) {
+ LogMessage(X_ERROR, "XKB: No device or keymap specified\n");
+ return NULL;
+ }
- XkbFreeRMLVOSet(&dflts, FALSE);
+ /* These are the components we really really need */
+ need = XkmSymbolsMask | XkmCompatMapMask | XkmTypesMask |
+ XkmKeyNamesMask | XkmVirtualModsMask;
+
+ provided =
+ XkbDDXLoadKeymapFromString(dev, keymap, keymap_length,
+ XkmAllIndicesMask, need, &xkb);
+ if ((need & provided) != need) {
+ if (xkb) {
+ XkbFreeKeyboard(xkb, 0, TRUE);
+ xkb = NULL;
+ }
}
- return xkb;
+ return KeymapOrDefaults(dev, xkb);
}
diff --git a/xserver/xkb/maprules.c b/xserver/xkb/maprules.c
index 5462763d1..6f5f8ccf3 100644
--- a/xserver/xkb/maprules.c
+++ b/xserver/xkb/maprules.c
@@ -218,10 +218,10 @@ typedef struct _FileSpec {
} FileSpec;
typedef struct {
- char *model;
- char *layout[XkbNumKbdGroups + 1];
- char *variant[XkbNumKbdGroups + 1];
- char *options;
+ const char *model;
+ const char *layout[XkbNumKbdGroups + 1];
+ const char *variant[XkbNumKbdGroups + 1];
+ const char *options;
} XkbRF_MultiDefsRec, *XkbRF_MultiDefsPtr;
#define NDX_BUFF_SIZE 4
@@ -343,9 +343,9 @@ SetUpRemap(InputLine * line, RemapSpec * remap)
}
static Bool
-MatchOneOf(char *wanted, char *vals_defined)
+MatchOneOf(const char *wanted, const char *vals_defined)
{
- char *str, *next;
+ const char *str, *next;
int want_len = strlen(wanted);
for (str = vals_defined, next = NULL; str != NULL; str = next) {
@@ -469,7 +469,7 @@ CheckLine(InputLine * line,
}
static char *
-_Concat(char *str1, char *str2)
+_Concat(char *str1, const char *str2)
{
int len;
@@ -498,12 +498,13 @@ squeeze_spaces(char *p1)
static Bool
MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
{
-
+ char *options;
memset((char *) mdefs, 0, sizeof(XkbRF_MultiDefsRec));
mdefs->model = defs->model;
- mdefs->options = Xstrdup(defs->options);
- if (mdefs->options)
- squeeze_spaces(mdefs->options);
+ options = Xstrdup(defs->options);
+ if (options)
+ squeeze_spaces(options);
+ mdefs->options = options;
if (defs->layout) {
if (!strchr(defs->layout, ',')) {
@@ -511,13 +512,15 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
}
else {
char *p;
+ char *layout;
int i;
- mdefs->layout[1] = Xstrdup(defs->layout);
- if (mdefs->layout[1] == NULL)
+ layout = Xstrdup(defs->layout);
+ if (layout == NULL)
return FALSE;
- squeeze_spaces(mdefs->layout[1]);
- p = mdefs->layout[1];
+ squeeze_spaces(layout);
+ mdefs->layout[1] = layout;
+ p = layout;
for (i = 2; i <= XkbNumKbdGroups; i++) {
if ((p = strchr(p, ','))) {
*p++ = '\0';
@@ -538,13 +541,15 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
}
else {
char *p;
+ char *variant;
int i;
- mdefs->variant[1] = Xstrdup(defs->variant);
- if (mdefs->variant[1] == NULL)
+ variant = Xstrdup(defs->variant);
+ if (variant == NULL)
return FALSE;
- squeeze_spaces(mdefs->variant[1]);
- p = mdefs->variant[1];
+ squeeze_spaces(variant);
+ mdefs->variant[1] = variant;
+ p = variant;
for (i = 2; i <= XkbNumKbdGroups; i++) {
if ((p = strchr(p, ','))) {
*p++ = '\0';
@@ -564,13 +569,13 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
static void
FreeMultiDefs(XkbRF_MultiDefsPtr defs)
{
- free(defs->options);
- free(defs->layout[1]);
- free(defs->variant[1]);
+ free((void *) defs->options);
+ free((void *) defs->layout[1]);
+ free((void *) defs->variant[1]);
}
static void
-Apply(char *src, char **dst)
+Apply(const char *src, char **dst)
{
if (src) {
if (*src == '+' || *src == '!') {
@@ -596,7 +601,7 @@ XkbRF_ApplyRule(XkbRF_RulePtr rule, XkbComponentNamesPtr names)
}
static Bool
-CheckGroup(XkbRF_RulesPtr rules, char *group_name, char *name)
+CheckGroup(XkbRF_RulesPtr rules, const char *group_name, const char *name)
{
int i;
char *p;
@@ -1013,15 +1018,15 @@ XkbRF_Free(XkbRF_RulesPtr rules, Bool freeRules)
return;
if (rules->rules) {
for (i = 0, rule = rules->rules; i < rules->num_rules; i++, rule++) {
- free(rule->model);
- free(rule->layout);
- free(rule->variant);
- free(rule->option);
- free(rule->keycodes);
- free(rule->symbols);
- free(rule->types);
- free(rule->compat);
- free(rule->geometry);
+ free((void *) rule->model);
+ free((void *) rule->layout);
+ free((void *) rule->variant);
+ free((void *) rule->option);
+ free((void *) rule->keycodes);
+ free((void *) rule->symbols);
+ free((void *) rule->types);
+ free((void *) rule->compat);
+ free((void *) rule->geometry);
memset((char *) rule, 0, sizeof(XkbRF_RuleRec));
}
free(rules->rules);
@@ -1031,7 +1036,7 @@ XkbRF_Free(XkbRF_RulesPtr rules, Bool freeRules)
if (rules->groups) {
for (i = 0, group = rules->groups; i < rules->num_groups; i++, group++) {
- free(group->name);
+ free((void *) group->name);
free(group->words);
}
free(rules->groups);
diff --git a/xserver/xkb/xkb.c b/xserver/xkb/xkb.c
index c78aceb78..dc570f0e5 100644
--- a/xserver/xkb/xkb.c
+++ b/xserver/xkb/xkb.c
@@ -370,7 +370,7 @@ _XkbBell(ClientPtr client, DeviceIntPtr dev, WindowPtr pWin,
int percent, int forceSound, int eventOnly, Atom name)
{
int base;
- pointer ctrl;
+ void *ctrl;
int oldPitch, oldDuration;
int newPercent;
@@ -390,7 +390,7 @@ _XkbBell(ClientPtr client, DeviceIntPtr dev, WindowPtr pWin,
return BadValue;
}
base = k->ctrl.bell;
- ctrl = (pointer) &(k->ctrl);
+ ctrl = (void *) &(k->ctrl);
oldPitch = k->ctrl.bell_pitch;
oldDuration = k->ctrl.bell_duration;
if (pitch != 0) {
@@ -422,7 +422,7 @@ _XkbBell(ClientPtr client, DeviceIntPtr dev, WindowPtr pWin,
return BadValue;
}
base = b->ctrl.percent;
- ctrl = (pointer) &(b->ctrl);
+ ctrl = (void *) &(b->ctrl);
oldPitch = b->ctrl.pitch;
oldDuration = b->ctrl.duration;
if (pitch != 0) {
@@ -4419,7 +4419,7 @@ ProcXkbSetNames(ClientPtr client)
* (swapped) 16 bit string length, non-zero terminated.
*/
static char *
-XkbWriteCountedString(char *wire, char *str, Bool swap)
+XkbWriteCountedString(char *wire, const char *str, Bool swap)
{
CARD16 len, *pLen, paddedLen;
@@ -5950,25 +5950,13 @@ ProcXkbGetKbdByName(ClientPtr client)
if (rep.loaded) {
XkbDescPtr old_xkb;
xkbNewKeyboardNotify nkn;
- int i, nG, nTG;
old_xkb = xkb;
xkb = new;
dev->key->xkbInfo->desc = xkb;
new = old_xkb; /* so it'll get freed automatically */
- *xkb->ctrls = *old_xkb->ctrls;
- for (nG = nTG = 0, i = xkb->min_key_code; i <= xkb->max_key_code; i++) {
- nG = XkbKeyNumGroups(xkb, i);
- if (nG >= XkbNumKbdGroups) {
- nTG = XkbNumKbdGroups;
- break;
- }
- if (nG > nTG) {
- nTG = nG;
- }
- }
- xkb->ctrls->num_groups = nTG;
+ XkbCopyControls(xkb, old_xkb);
nkn.deviceID = nkn.oldDeviceID = dev->id;
nkn.minKeyCode = new->min_key_code;
@@ -5991,7 +5979,7 @@ ProcXkbGetKbdByName(ClientPtr client)
continue;
if (tmpd != dev)
- XkbCopyDeviceKeymap(tmpd, dev);
+ XkbDeviceApplyKeymap(tmpd, xkb);
if (tmpd->kbdfeed && tmpd->kbdfeed->xkb_sli) {
old_sli = tmpd->kbdfeed->xkb_sli;
@@ -6820,7 +6808,7 @@ ProcXkbDispatch(ClientPtr client)
}
static int
-XkbClientGone(pointer data, XID id)
+XkbClientGone(void *data, XID id)
{
DevicePtr pXDev = (DevicePtr) data;
diff --git a/xserver/xkb/xkbAccessX.c b/xserver/xkb/xkbAccessX.c
index 13051e034..5f3de0d9e 100644
--- a/xserver/xkb/xkbAccessX.c
+++ b/xserver/xkb/xkbAccessX.c
@@ -279,7 +279,7 @@ AccessXStickyKeysTurnOff(DeviceIntPtr dev, xkbControlsNotify * pCN)
} /* AccessXStickyKeysTurnOff */
static CARD32
-AccessXKRGExpire(OsTimerPtr timer, CARD32 now, pointer arg)
+AccessXKRGExpire(OsTimerPtr timer, CARD32 now, void *arg)
{
xkbControlsNotify cn;
DeviceIntPtr dev = arg;
@@ -309,7 +309,7 @@ AccessXKRGExpire(OsTimerPtr timer, CARD32 now, pointer arg)
}
static CARD32
-AccessXRepeatKeyExpire(OsTimerPtr timer, CARD32 now, pointer arg)
+AccessXRepeatKeyExpire(OsTimerPtr timer, CARD32 now, void *arg)
{
DeviceIntPtr dev = (DeviceIntPtr) arg;
XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
@@ -331,7 +331,7 @@ AccessXCancelRepeatKey(XkbSrvInfoPtr xkbi, KeyCode key)
}
static CARD32
-AccessXSlowKeyExpire(OsTimerPtr timer, CARD32 now, pointer arg)
+AccessXSlowKeyExpire(OsTimerPtr timer, CARD32 now, void *arg)
{
DeviceIntPtr keybd;
XkbSrvInfoPtr xkbi;
@@ -370,7 +370,7 @@ AccessXSlowKeyExpire(OsTimerPtr timer, CARD32 now, pointer arg)
xkbi->repeatKeyTimer = TimerSet(xkbi->repeatKeyTimer,
0, ctrls->repeat_delay,
AccessXRepeatKeyExpire,
- (pointer) keybd);
+ (void *) keybd);
}
}
}
@@ -378,7 +378,7 @@ AccessXSlowKeyExpire(OsTimerPtr timer, CARD32 now, pointer arg)
}
static CARD32
-AccessXBounceKeyExpire(OsTimerPtr timer, CARD32 now, pointer arg)
+AccessXBounceKeyExpire(OsTimerPtr timer, CARD32 now, void *arg)
{
XkbSrvInfoPtr xkbi = ((DeviceIntPtr) arg)->key->xkbInfo;
@@ -387,7 +387,7 @@ AccessXBounceKeyExpire(OsTimerPtr timer, CARD32 now, pointer arg)
}
static CARD32
-AccessXTimeoutExpire(OsTimerPtr timer, CARD32 now, pointer arg)
+AccessXTimeoutExpire(OsTimerPtr timer, CARD32 now, void *arg)
{
DeviceIntPtr dev = (DeviceIntPtr) arg;
XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
@@ -467,12 +467,12 @@ AccessXFilterPressEvent(DeviceEvent *event, DeviceIntPtr keybd)
if (XkbAX_NeedFeedback(ctrls, XkbAX_SlowWarnFBMask)) {
xkbi->krgTimerActive = _KRG_WARN_TIMER;
xkbi->krgTimer = TimerSet(xkbi->krgTimer, 0, 4000,
- AccessXKRGExpire, (pointer) keybd);
+ AccessXKRGExpire, (void *) keybd);
}
else {
xkbi->krgTimerActive = _KRG_TIMER;
xkbi->krgTimer = TimerSet(xkbi->krgTimer, 0, 8000,
- AccessXKRGExpire, (pointer) keybd);
+ AccessXKRGExpire, (void *) keybd);
}
if (!(ctrls->enabled_ctrls & XkbSlowKeysMask)) {
CARD32 now = GetTimeInMillis();
@@ -514,7 +514,7 @@ AccessXFilterPressEvent(DeviceEvent *event, DeviceIntPtr keybd)
xkbi->slowKey = key;
xkbi->slowKeysTimer = TimerSet(xkbi->slowKeysTimer,
0, ctrls->slow_keys_delay,
- AccessXSlowKeyExpire, (pointer) keybd);
+ AccessXSlowKeyExpire, (void *) keybd);
ignoreKeyEvent = TRUE;
}
@@ -546,7 +546,7 @@ AccessXFilterPressEvent(DeviceEvent *event, DeviceIntPtr keybd)
xkbi->repeatKeyTimer = TimerSet(xkbi->repeatKeyTimer,
0, ctrls->repeat_delay,
AccessXRepeatKeyExpire,
- (pointer) keybd);
+ (void *) keybd);
}
}
}
@@ -608,7 +608,7 @@ AccessXFilterReleaseEvent(DeviceEvent *event, DeviceIntPtr keybd)
xkbi->bounceKeysTimer = TimerSet(xkbi->bounceKeysTimer, 0,
ctrls->debounce_delay,
AccessXBounceKeyExpire,
- (pointer) keybd);
+ (void *) keybd);
}
/* Don't transmit the KeyRelease if SlowKeys is turned on and
@@ -651,7 +651,7 @@ AccessXFilterReleaseEvent(DeviceEvent *event, DeviceIntPtr keybd)
xkbi->lastPtrEventTime = 0;
xkbi->krgTimer = TimerSet(xkbi->krgTimer, 0,
ctrls->ax_timeout * 1000,
- AccessXTimeoutExpire, (pointer) keybd);
+ AccessXTimeoutExpire, (void *) keybd);
xkbi->krgTimerActive = _ALL_TIMEOUT_TIMER;
}
else if (xkbi->krgTimerActive != _OFF_TIMER) {
@@ -711,7 +711,7 @@ ProcessPointerEvent(InternalEvent *ev, DeviceIntPtr mouse)
xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(mouse);
DeviceEvent *event = &ev->device_event;
- dev = (IsMaster(mouse) || IsFloating(mouse)) ? mouse : GetMaster(mouse, MASTER_KEYBOARD);
+ dev = IsFloating(mouse) ? mouse : GetMaster(mouse, MASTER_KEYBOARD);
if (dev && dev->key) {
xkbi = dev->key->xkbInfo;
diff --git a/xserver/xkb/xkbActions.c b/xserver/xkb/xkbActions.c
index e32005cf6..c44f44bc1 100644
--- a/xserver/xkb/xkbActions.c
+++ b/xserver/xkb/xkbActions.c
@@ -51,7 +51,7 @@ static void XkbFakePointerMotion(DeviceIntPtr dev, unsigned flags, int x,
int y);
void
-xkbUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc, pointer data)
+xkbUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc, void *data)
{
xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(device);
ProcessInputProc backupproc;
@@ -470,7 +470,7 @@ _XkbFilterISOLock(XkbSrvInfoPtr xkbi,
}
static CARD32
-_XkbPtrAccelExpire(OsTimerPtr timer, CARD32 now, pointer arg)
+_XkbPtrAccelExpire(OsTimerPtr timer, CARD32 now, void *arg)
{
XkbSrvInfoPtr xkbi = (XkbSrvInfoPtr) arg;
XkbControlsPtr ctrls = xkbi->desc->ctrls;
@@ -540,7 +540,7 @@ _XkbFilterPointerMove(XkbSrvInfoPtr xkbi,
xkbi->mouseKeysDY = XkbPtrActionY(&pAction->ptr);
xkbi->mouseKeyTimer = TimerSet(xkbi->mouseKeyTimer, 0,
xkbi->desc->ctrls->mk_delay,
- _XkbPtrAccelExpire, (pointer) xkbi);
+ _XkbPtrAccelExpire, (void *) xkbi);
}
else if (filter->keycode == keycode) {
filter->active = 0;
@@ -1127,13 +1127,78 @@ _XkbApplyFilters(XkbSrvInfoPtr xkbi, unsigned kc, XkbAction *pAction)
return send;
}
+static int
+_XkbEnsureStateChange(XkbSrvInfoPtr xkbi)
+{
+ Bool genStateNotify = FALSE;
+
+ /* The state may change, so if we're not in the middle of sending a state
+ * notify, prepare for it */
+ if ((xkbi->flags & _XkbStateNotifyInProgress) == 0) {
+ xkbi->prev_state = xkbi->state;
+ xkbi->flags |= _XkbStateNotifyInProgress;
+ genStateNotify = TRUE;
+ }
+
+ return genStateNotify;
+}
+
+static void
+_XkbApplyState(DeviceIntPtr dev, Bool genStateNotify, int evtype, int key)
+{
+ XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
+ int changed;
+
+ XkbComputeDerivedState(xkbi);
+
+ changed = XkbStateChangedFlags(&xkbi->prev_state, &xkbi->state);
+ if (genStateNotify) {
+ if (changed) {
+ xkbStateNotify sn;
+
+ sn.keycode = key;
+ sn.eventType = evtype;
+ sn.requestMajor = sn.requestMinor = 0;
+ sn.changed = changed;
+ XkbSendStateNotify(dev, &sn);
+ }
+ xkbi->flags &= ~_XkbStateNotifyInProgress;
+ }
+
+ changed = XkbIndicatorsToUpdate(dev, changed, FALSE);
+ if (changed) {
+ XkbEventCauseRec cause;
+ XkbSetCauseKey(&cause, key, evtype);
+ XkbUpdateIndicators(dev, changed, FALSE, NULL, &cause);
+ }
+}
+
+void
+XkbPushLockedStateToSlaves(DeviceIntPtr master, int evtype, int key)
+{
+ DeviceIntPtr dev;
+ Bool genStateNotify;
+
+ nt_list_for_each_entry(dev, inputInfo.devices, next) {
+ if (!dev->key || GetMaster(dev, MASTER_KEYBOARD) != master)
+ continue;
+
+ genStateNotify = _XkbEnsureStateChange(dev->key->xkbInfo);
+
+ dev->key->xkbInfo->state.locked_mods =
+ master->key->xkbInfo->state.locked_mods;
+
+ _XkbApplyState(dev, genStateNotify, evtype, key);
+ }
+}
+
void
XkbHandleActions(DeviceIntPtr dev, DeviceIntPtr kbd, DeviceEvent *event)
{
int key, bit, i;
XkbSrvInfoPtr xkbi;
KeyClassPtr keyc;
- int changed, sendEvent;
+ int sendEvent;
Bool genStateNotify;
XkbAction act;
XkbFilterPtr filter;
@@ -1146,15 +1211,8 @@ XkbHandleActions(DeviceIntPtr dev, DeviceIntPtr kbd, DeviceEvent *event)
keyc = kbd->key;
xkbi = keyc->xkbInfo;
key = event->detail.key;
- /* The state may change, so if we're not in the middle of sending a state
- * notify, prepare for it */
- if ((xkbi->flags & _XkbStateNotifyInProgress) == 0) {
- xkbi->prev_state = xkbi->state;
- xkbi->flags |= _XkbStateNotifyInProgress;
- genStateNotify = TRUE;
- }
- else
- genStateNotify = FALSE;
+
+ genStateNotify = _XkbEnsureStateChange(xkbi);
xkbi->clearMods = xkbi->setMods = 0;
xkbi->groupChange = 0;
@@ -1287,28 +1345,8 @@ XkbHandleActions(DeviceIntPtr dev, DeviceIntPtr kbd, DeviceEvent *event)
FixKeyState(event, dev);
}
- XkbComputeDerivedState(xkbi);
- changed = XkbStateChangedFlags(&xkbi->prev_state, &xkbi->state);
- if (genStateNotify) {
- if (changed) {
- xkbStateNotify sn;
-
- sn.keycode = key;
- sn.eventType = event->type;
- sn.requestMajor = sn.requestMinor = 0;
- sn.changed = changed;
- XkbSendStateNotify(dev, &sn);
- }
- xkbi->flags &= ~_XkbStateNotifyInProgress;
- }
- changed = XkbIndicatorsToUpdate(dev, changed, FALSE);
- if (changed) {
- XkbEventCauseRec cause;
-
- XkbSetCauseKey(&cause, key, event->type);
- XkbUpdateIndicators(dev, changed, FALSE, NULL, &cause);
- }
- return;
+ _XkbApplyState(dev, genStateNotify, event->type, key);
+ XkbPushLockedStateToSlaves(dev, event->type, key);
}
int
diff --git a/xserver/xkb/xkbEvents.c b/xserver/xkb/xkbEvents.c
index 87a4485eb..210d8ebe4 100644
--- a/xserver/xkb/xkbEvents.c
+++ b/xserver/xkb/xkbEvents.c
@@ -482,7 +482,7 @@ XkbHandleBell(BOOL force,
BOOL eventOnly,
DeviceIntPtr kbd,
CARD8 percent,
- pointer pCtrl,
+ void *pCtrl,
CARD8 class, Atom name, WindowPtr pWin, ClientPtr pClient)
{
xkbBellNotify bn;
@@ -502,7 +502,7 @@ XkbHandleBell(BOOL force,
if ((force || (xkbi->desc->ctrls->enabled_ctrls & XkbAudibleBellMask)) &&
(!eventOnly)) {
if (kbd->kbdfeed->BellProc)
- (*kbd->kbdfeed->BellProc) (percent, kbd, (pointer) pCtrl, class);
+ (*kbd->kbdfeed->BellProc) (percent, kbd, (void *) pCtrl, class);
}
interest = kbd->xkb_interest;
if ((!interest) || (force))
diff --git a/xserver/xkb/xkbInit.c b/xserver/xkb/xkbInit.c
index f72655fc3..06ec46e81 100644
--- a/xserver/xkb/xkbInit.c
+++ b/xserver/xkb/xkbInit.c
@@ -142,7 +142,7 @@ XkbFreeRMLVOSet(XkbRMLVOSet * rmlvo, Bool freeRMLVO)
}
static Bool
-XkbWriteRulesProp(ClientPtr client, pointer closure)
+XkbWriteRulesProp(ClientPtr client, void *closure)
{
int len, out;
Atom name;
@@ -206,6 +206,21 @@ XkbWriteRulesProp(ClientPtr client, pointer closure)
return TRUE;
}
+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;
+}
+
static void
XkbSetRulesUsed(XkbRMLVOSet * rmlvo)
{
@@ -490,9 +505,10 @@ XkbInitControls(DeviceIntPtr pXDev, XkbSrvInfoPtr xkbi)
return Success;
}
-_X_EXPORT Bool
-InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet * rmlvo,
- BellProcPtr bell_func, KbdCtrlProcPtr ctrl_func)
+static Bool
+InitKeyboardDeviceStructInternal(DeviceIntPtr dev, XkbRMLVOSet * rmlvo,
+ const char *keymap, int keymap_length,
+ BellProcPtr bell_func, KbdCtrlProcPtr ctrl_func)
{
int i;
unsigned int check;
@@ -506,8 +522,9 @@ InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet * rmlvo,
BUG_RETURN_VAL(dev == NULL, FALSE);
BUG_RETURN_VAL(dev->key != NULL, FALSE);
BUG_RETURN_VAL(dev->kbdfeed != NULL, FALSE);
+ BUG_RETURN_VAL(rmlvo && keymap, FALSE);
- if (!rmlvo) {
+ if (!rmlvo && !keymap) {
rmlvo = &rmlvo_dflts;
XkbGetRulesDflts(rmlvo);
}
@@ -535,7 +552,7 @@ InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet * rmlvo,
}
dev->key->xkbInfo = xkbi;
- if (xkb_cached_map && !XkbCompareUsedRMLVO(rmlvo)) {
+ if (xkb_cached_map && (keymap || (rmlvo && !XkbCompareUsedRMLVO(rmlvo)))) {
XkbFreeKeyboard(xkb_cached_map, XkbAllComponentsMask, TRUE);
xkb_cached_map = NULL;
}
@@ -543,7 +560,11 @@ InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet * rmlvo,
if (xkb_cached_map)
LogMessageVerb(X_INFO, 4, "XKB: Reusing cached keymap\n");
else {
- xkb_cached_map = XkbCompileKeymap(dev, rmlvo);
+ if (rmlvo)
+ xkb_cached_map = XkbCompileKeymap(dev, rmlvo);
+ else
+ xkb_cached_map = XkbCompileKeymapFromString(dev, keymap, keymap_length);
+
if (!xkb_cached_map) {
ErrorF("XKB: Failed to compile keymap\n");
goto unwind_info;
@@ -612,8 +633,10 @@ InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet * rmlvo,
dev->kbdfeed->CtrlProc(dev, &dev->kbdfeed->ctrl);
- XkbSetRulesDflts(rmlvo);
- XkbSetRulesUsed(rmlvo);
+ if (rmlvo) {
+ XkbSetRulesDflts(rmlvo);
+ XkbSetRulesUsed(rmlvo);
+ }
XkbFreeRMLVOSet(&rmlvo_dflts, FALSE);
return TRUE;
@@ -632,6 +655,24 @@ InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet * rmlvo,
return FALSE;
}
+_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);
+}
+
/***====================================================================***/
/*
diff --git a/xserver/xkb/xkbUtils.c b/xserver/xkb/xkbUtils.c
index 6c6af60f0..c14a790df 100644
--- a/xserver/xkb/xkbUtils.c
+++ b/xserver/xkb/xkbUtils.c
@@ -1999,34 +1999,40 @@ XkbCopyKeymap(XkbDescPtr dst, XkbDescPtr src)
}
Bool
-XkbCopyDeviceKeymap(DeviceIntPtr dst, DeviceIntPtr src)
+XkbDeviceApplyKeymap(DeviceIntPtr dst, XkbDescPtr desc)
{
xkbNewKeyboardNotify nkn;
Bool ret;
- if (!dst->key || !src->key)
+ if (!dst->key || !desc)
return FALSE;
memset(&nkn, 0, sizeof(xkbNewKeyboardNotify));
nkn.oldMinKeyCode = dst->key->xkbInfo->desc->min_key_code;
nkn.oldMaxKeyCode = dst->key->xkbInfo->desc->max_key_code;
nkn.deviceID = dst->id;
- nkn.oldDeviceID = dst->id; /* maybe src->id? */
- nkn.minKeyCode = src->key->xkbInfo->desc->min_key_code;
- nkn.maxKeyCode = src->key->xkbInfo->desc->max_key_code;
+ nkn.oldDeviceID = dst->id;
+ nkn.minKeyCode = desc->min_key_code;
+ nkn.maxKeyCode = desc->max_key_code;
nkn.requestMajor = XkbReqCode;
nkn.requestMinor = X_kbSetMap; /* Near enough's good enough. */
nkn.changed = XkbNKN_KeycodesMask;
- if (src->key->xkbInfo->desc->geom)
+ if (desc->geom)
nkn.changed |= XkbNKN_GeometryMask;
- ret = XkbCopyKeymap(dst->key->xkbInfo->desc, src->key->xkbInfo->desc);
+ ret = XkbCopyKeymap(dst->key->xkbInfo->desc, desc);
if (ret)
XkbSendNewKeyboardNotify(dst, &nkn);
return ret;
}
+Bool
+XkbCopyDeviceKeymap(DeviceIntPtr dst, DeviceIntPtr src)
+{
+ return XkbDeviceApplyKeymap(dst, src->key->xkbInfo->desc);
+}
+
int
XkbGetEffectiveGroup(XkbSrvInfoPtr xkbi, XkbStatePtr xkbState, CARD8 keycode)
{
@@ -2090,3 +2096,26 @@ XkbMergeLockedPtrBtns(DeviceIntPtr master)
xkbi->lockedPtrButtons |= d->key->xkbInfo->lockedPtrButtons;
}
}
+
+void
+XkbCopyControls(XkbDescPtr dst, XkbDescPtr src)
+{
+ int i, nG, nTG;
+
+ if (!dst || !src)
+ return;
+
+ *dst->ctrls = *src->ctrls;
+
+ for (nG = nTG = 0, i = dst->min_key_code; i <= dst->max_key_code; i++) {
+ nG = XkbKeyNumGroups(dst, i);
+ if (nG >= XkbNumKbdGroups) {
+ nTG = XkbNumKbdGroups;
+ break;
+ }
+ if (nG > nTG) {
+ nTG = nG;
+ }
+ }
+ dst->ctrls->num_groups = nTG;
+}
diff --git a/xserver/xkb/xkbtext.c b/xserver/xkb/xkbtext.c
index 08b129fe6..308e119f5 100644
--- a/xserver/xkb/xkbtext.c
+++ b/xserver/xkb/xkbtext.c
@@ -6,19 +6,19 @@
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
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
+ documentation, and that the name of Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
+ Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is"
without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- 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
+ 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
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -144,18 +144,18 @@ char *
XkbVModMaskText(XkbDescPtr xkb,
unsigned modMask, unsigned mask, unsigned format)
{
-register int i,bit;
-int len;
-char *mm,*rtrn;
-char *str,buf[BUFFER_SIZE];
+ register int i, bit;
+ int len;
+ char *mm, *rtrn;
+ char *str, buf[BUFFER_SIZE];
-if ((modMask == 0) && (mask == 0)) {
- rtrn = tbGetBuffer(5);
- if (format == XkbCFile)
- snprintf(rtrn, 5, "0");
- else
- snprintf(rtrn, 5, "none");
- return rtrn;
+ if ((modMask == 0) && (mask == 0)) {
+ rtrn = tbGetBuffer(5);
+ if (format == XkbCFile)
+ snprintf(rtrn, 5, "0");
+ else
+ snprintf(rtrn, 5, "none");
+ return rtrn;
}
if (modMask != 0)
mm = XkbModMaskText(modMask, format);
@@ -165,36 +165,38 @@ if ((modMask == 0) && (mask == 0)) {
str = buf;
buf[0] = '\0';
if (mask) {
- char *tmp;
- for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
- if (mask&bit) {
- tmp = XkbVModIndexText(xkb, i, format);
- len = strlen(tmp) + 1 + (str == buf ? 0 : 1);
- if (format == XkbCFile)
- len += 4;
- if ((str - (buf + len)) <= BUFFER_SIZE) {
- if (str != buf) {
- if (format == XkbCFile)
+ char *tmp;
+
+ for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
+ if (mask & bit) {
+ tmp = XkbVModIndexText(xkb, i, format);
+ len = strlen(tmp) + 1 + (str == buf ? 0 : 1);
+ if (format == XkbCFile)
+ len += 4;
+ if ((str - (buf + len)) <= BUFFER_SIZE) {
+ if (str != buf) {
+ if (format == XkbCFile)
*str++ = '|';
- else
+ else
*str++ = '+';
- len--;
- }
- }
- if (format == XkbCFile)
- snprintf(str, BUFFER_SIZE - len, "%sMask", tmp);
- else
+ len--;
+ }
+ }
+ if (format == XkbCFile)
+ snprintf(str, BUFFER_SIZE - len, "%sMask", tmp);
+ else
strcpy(str, tmp);
- str = &str[len-1];
- }
- }
- str = buf;
+ str = &str[len - 1];
+ }
+ }
+ str = buf;
}
- else str = NULL;
+ else
+ str = NULL;
if (mm)
- len = strlen(mm);
+ len = strlen(mm);
else
- len= 0;
+ len = 0;
if (str)
len += strlen(str) + (mm == NULL ? 0 : 1);
if (len >= BUFFER_SIZE)
diff --git a/xserver/xkb/xkmread.c b/xserver/xkb/xkmread.c
index 258bb91b5..b6241b5c7 100644
--- a/xserver/xkb/xkmread.c
+++ b/xserver/xkb/xkmread.c
@@ -1204,7 +1204,8 @@ XkmReadTOC(FILE * file, xkmFileInfo * file_info, int max_toc,
}
return 0;
}
- fread(file_info, SIZEOF(xkmFileInfo), 1, file);
+ if (fread(file_info, SIZEOF(xkmFileInfo), 1, file) != 1)
+ return 0;
size_toc = file_info->num_toc;
if (size_toc > max_toc) {
DebugF("Warning! Too many TOC entries; last %d ignored\n",
@@ -1212,7 +1213,8 @@ XkmReadTOC(FILE * file, xkmFileInfo * file_info, int max_toc,
size_toc = max_toc;
}
for (i = 0; i < size_toc; i++) {
- fread(&toc[i], SIZEOF(xkmSectionInfo), 1, file);
+ if (fread(&toc[i], SIZEOF(xkmSectionInfo), 1, file) != 1)
+ return 0;
}
return 1;
}