summaryrefslogtreecommitdiff
path: root/xkb
diff options
context:
space:
mode:
Diffstat (limited to 'xkb')
-rw-r--r--xkb/ddxLoad.c76
-rw-r--r--xkb/xkb.c26
-rw-r--r--xkb/xkbAccessX.c2
-rw-r--r--xkb/xkbActions.c8
4 files changed, 77 insertions, 35 deletions
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
index 9686ea85d..dc3c844c9 100644
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -426,35 +426,79 @@ XkbRF_RulesPtr rules;
return complete;
}
-XkbDescPtr
-XkbCompileKeymap(DeviceIntPtr dev, XkbRMLVOSet *rmlvo)
+static Bool
+XkbRMLVOtoKcCGST(DeviceIntPtr dev, XkbRMLVOSet *rmlvo, XkbComponentNamesPtr kccgst)
{
- XkbComponentNamesRec kccgst;
XkbRF_VarDefsRec mlvo;
- XkbDescPtr xkb;
- char name[PATH_MAX];
-
- if (!dev || !rmlvo) {
- LogMessage(X_ERROR, "XKB: No device or RMLVO specified\n");
- return NULL;
- }
mlvo.model = rmlvo->model;
mlvo.layout = rmlvo->layout;
mlvo.variant = rmlvo->variant;
mlvo.options = rmlvo->options;
- /* XDNFR already logs for us. */
- if (!XkbDDXNamesFromRules(dev, rmlvo->rules, &mlvo, &kccgst))
+ return XkbDDXNamesFromRules(dev, rmlvo->rules, &mlvo, kccgst);
+}
+
+/**
+ * Compile the given RMLVO keymap and return it. Returns the XkbDescPtr on
+ * success or NULL on failure. If the components compiled are not a superset
+ * or equal to need, the compiliation is treated as failure.
+ */
+static XkbDescPtr
+XkbCompileKeymapForDevice(DeviceIntPtr dev, XkbRMLVOSet *rmlvo, int need)
+{
+ XkbDescPtr xkb;
+ unsigned int provided;
+ XkbComponentNamesRec kccgst;
+ char name[PATH_MAX];
+
+ if (!XkbRMLVOtoKcCGST(dev, rmlvo, &kccgst))
return NULL;
- /* XDLKBN too, but it might return 0 as well as allocating. */
- if (!XkbDDXLoadKeymapByNames(dev, &kccgst, XkmAllIndicesMask, 0, &xkb, name,
- PATH_MAX)) {
- if (xkb)
+ provided = XkbDDXLoadKeymapByNames(dev, &kccgst, XkmAllIndicesMask, need,
+ &xkb, name, PATH_MAX);
+ if ((need & provided) != need) {
+ if (xkb) {
XkbFreeKeyboard(xkb, 0, TRUE);
+ xkb = NULL;
+ }
+ }
+
+ return xkb;
+}
+
+XkbDescPtr
+XkbCompileKeymap(DeviceIntPtr dev, XkbRMLVOSet *rmlvo)
+{
+ XkbDescPtr xkb;
+ unsigned int need;
+
+ if (!dev || !rmlvo) {
+ LogMessage(X_ERROR, "XKB: No device or RMLVO specified\n");
return NULL;
}
+ /* These are the components we really really need */
+ need = XkmSymbolsMask | XkmCompatMapMask | XkmTypesMask |
+ XkmKeyNamesMask | XkmVirtualModsMask;
+
+
+ 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");
+
+ XkbGetRulesDflts(&dflts);
+
+ xkb = XkbCompileKeymapForDevice(dev, &dflts, 0);
+
+ XkbFreeRMLVOSet(&dflts, FALSE);
+ }
+
return xkb;
}
diff --git a/xkb/xkb.c b/xkb/xkb.c
index d98e35296..d701ea13c 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -3644,7 +3644,7 @@ register int n;
swapl(&rep->indicators,n);
}
- start = desc = malloc(length);
+ start = desc = calloc(1, length);
if ( !start )
return BadAlloc;
if (xkb->names) {
@@ -5569,13 +5569,13 @@ ProcXkbGetKbdByName(ClientPtr client)
{
DeviceIntPtr dev;
DeviceIntPtr tmpd;
- xkbGetKbdByNameReply rep;
- xkbGetMapReply mrep;
- xkbGetCompatMapReply crep;
- xkbGetIndicatorMapReply irep;
- xkbGetNamesReply nrep;
- xkbGetGeometryReply grep;
- XkbComponentNamesRec names;
+ xkbGetKbdByNameReply rep = {0};
+ xkbGetMapReply mrep = {0};
+ xkbGetCompatMapReply crep = {0};
+ xkbGetIndicatorMapReply irep = {0};
+ xkbGetNamesReply nrep = {0};
+ xkbGetGeometryReply grep = {0};
+ XkbComponentNamesRec names = {0};
XkbDescPtr xkb, new;
unsigned char * str;
char mapFile[PATH_MAX];
@@ -5883,12 +5883,10 @@ ProcXkbGetKbdByName(ClientPtr client)
nkn.changed|= XkbNKN_GeometryMask;
XkbSendNewKeyboardNotify(dev,&nkn);
- if (!IsMaster(dev) && dev->u.master)
- {
- DeviceIntPtr master = dev->u.master;
- if (master->u.lastSlave == dev)
- {
- XkbCopyDeviceKeymap(dev->u.master, dev);
+ if (!IsMaster(dev)) {
+ DeviceIntPtr master = GetMaster(dev, MASTER_KEYBOARD);
+ if (master && master->lastSlave == dev) {
+ XkbCopyDeviceKeymap(master, dev);
XkbSendNewKeyboardNotify(dev,&nkn);
}
}
diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c
index 10c38ca47..12fe2a1f5 100644
--- a/xkb/xkbAccessX.c
+++ b/xkb/xkbAccessX.c
@@ -694,7 +694,7 @@ ProcessInputProc backupproc;
xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(mouse);
DeviceEvent *event = &ev->device_event;
- dev = (IsMaster(mouse) || mouse->u.master) ? GetMaster(mouse, MASTER_KEYBOARD) : mouse;
+ dev = IsFloating(mouse) ? mouse : GetMaster(mouse, MASTER_KEYBOARD);
if (dev && dev->key)
{
diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index 8d7c124e8..65c678af8 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -1365,9 +1365,9 @@ InjectPointerKeyEvents(DeviceIntPtr dev, int type, int button, int flags, Valuat
if (IsMaster(dev)) {
mpointer = GetMaster(dev, MASTER_POINTER);
- lastSlave = mpointer->u.lastSlave;
+ lastSlave = mpointer->lastSlave;
ptr = GetXTestDevice(mpointer);
- } else if (!dev->u.master)
+ } else if (IsFloating(dev))
ptr = dev;
else
return;
@@ -1397,7 +1397,7 @@ XkbFakePointerMotion(DeviceIntPtr dev, unsigned flags,int x,int y)
int gpe_flags = 0;
/* ignore attached SDs */
- if (!IsMaster(dev) && GetMaster(dev, MASTER_POINTER) != NULL)
+ if (!IsMaster(dev) && !IsFloating(dev))
return;
if (flags & XkbSA_MoveAbsoluteX || flags & XkbSA_MoveAbsoluteY)
@@ -1427,7 +1427,7 @@ XkbFakeDeviceButton(DeviceIntPtr dev,Bool press,int button)
if (IsMaster(dev)) {
DeviceIntPtr mpointer = GetMaster(dev, MASTER_POINTER);
ptr = GetXTestDevice(mpointer);
- } else if (!dev->u.master)
+ } else if (IsFloating(dev))
ptr = dev;
else
return;