diff options
author | Peter Hutterer <peter@cs.unisa.edu.au> | 2008-04-13 08:27:31 +0930 |
---|---|---|
committer | Peter Hutterer <peter@cs.unisa.edu.au> | 2008-04-13 08:27:31 +0930 |
commit | 4219e94c2f7d431be433eceddfe79760a1ee31a1 (patch) | |
tree | 8ff0530948deb7e630aed5194c258fb927732c3e /xkb/xkbLEDs.c | |
parent | b4380d8030927c940ddaea83c4cf24e0b9eb7b96 (diff) |
xkb: Add XkbCopySrvLedInfo, deep-copies a XkbSrvLedInfoRec.
Diffstat (limited to 'xkb/xkbLEDs.c')
-rw-r--r-- | xkb/xkbLEDs.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/xkb/xkbLEDs.c b/xkb/xkbLEDs.c index 55ce12aad..d7ada5749 100644 --- a/xkb/xkbLEDs.c +++ b/xkb/xkbLEDs.c @@ -615,6 +615,45 @@ XkbFreeSrvLedInfo(XkbSrvLedInfoPtr sli) return; } +/* + * XkbSrvLedInfoPtr + * XkbCopySrvLedInfo(dev,src,kf,lf) + * + * Takes the given XkbSrvLedInfoPtr and duplicates it. A deep copy is made, + * thus the new copy behaves like the original one and can be freed with + * XkbFreeSrvLedInfo. + */ +XkbSrvLedInfoPtr +XkbCopySrvLedInfo( DeviceIntPtr from, + XkbSrvLedInfoPtr src, + KbdFeedbackPtr kf, + LedFeedbackPtr lf) +{ + XkbSrvLedInfoPtr sli_new; + + if (!src) + goto finish; + + sli_new = _XkbTypedCalloc(1, XkbSrvLedInfoRec); + if (!sli_new) + goto finish; + + memcpy(src, sli_new, sizeof(XkbSrvLedInfoRec)); + if (sli_new->class == KbdFeedbackClass) + sli_new->fb.kf = kf; + else + sli_new->fb.lf = lf; + + if (sli_new->flags & XkbSLI_IsDefault) { + sli_new->names= _XkbTypedCalloc(XkbNumIndicators,Atom); + sli_new->maps= _XkbTypedCalloc(XkbNumIndicators,XkbIndicatorMapRec); + } /* else sli_new->names/maps is pointing to + dev->key->xkbInfo->desc->names->indicators; + dev->key->xkbInfo->desc->names->indicators; */ + +finish: + return sli_new; +} /***====================================================================***/ |