[PATCH 01/16] xkb: split effectiveGroup calculation into separate utility function.
Peter Hutterer
peter.hutterer at who-t.net
Wed Sep 9 23:54:07 PDT 2009
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
include/xkbsrv.h | 5 +++++
xkb/xkbActions.c | 29 +++++------------------------
xkb/xkbUtils.c | 35 +++++++++++++++++++++++++++++++++++
3 files changed, 45 insertions(+), 24 deletions(-)
diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index 2c7d86a..ebc7cdb 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -945,6 +945,11 @@ extern void XkbFilterEvents(
int /* nEvents */,
xEvent* /* xE */);
+extern int XkbGetEffectiveGroup(
+ XkbSrvInfoPtr /* xkbi */,
+ XkbStatePtr /* xkbstate */,
+ CARD8 /* keycode */);
+
#include "xkbfile.h"
#include "xkbrules.h"
diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index 9c3184a..b0ab427 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -124,30 +124,11 @@ static XkbAction fake;
}
pActs= XkbKeyActionsPtr(xkb,key);
col= 0;
- effectiveGroup= xkbState->group;
- if (effectiveGroup!=XkbGroup1Index) {
- if (XkbKeyNumGroups(xkb,key)>(unsigned)1) {
- if (effectiveGroup>=XkbKeyNumGroups(xkb,key)) {
- unsigned gi= XkbKeyGroupInfo(xkb,key);
- switch (XkbOutOfRangeGroupAction(gi)) {
- default:
- case XkbWrapIntoRange:
- effectiveGroup %= XkbKeyNumGroups(xkb,key);
- break;
- case XkbClampIntoRange:
- effectiveGroup = XkbKeyNumGroups(xkb,key)-1;
- break;
- case XkbRedirectIntoRange:
- effectiveGroup= XkbOutOfRangeGroupInfo(gi);
- if (effectiveGroup>=XkbKeyNumGroups(xkb,key))
- effectiveGroup= 0;
- break;
- }
- }
- }
- else effectiveGroup= XkbGroup1Index;
- col+= (effectiveGroup*XkbKeyGroupsWidth(xkb,key));
- }
+
+ effectiveGroup = XkbGetEffectiveGroup(xkbi, xkbState, key);
+ if (effectiveGroup != XkbGroup1Index)
+ col += (effectiveGroup * XkbKeyGroupsWidth(xkb, key));
+
type= XkbKeyKeyType(xkb,key,effectiveGroup);
if (type->map!=NULL) {
register unsigned i,mods;
diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 63b1e31..75e243c 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -2118,3 +2118,38 @@ XkbCopyDeviceKeymap(DeviceIntPtr dst, DeviceIntPtr src)
return ret;
}
+int
+XkbGetEffectiveGroup(XkbSrvInfoPtr xkbi, XkbStatePtr xkbState, CARD8 keycode)
+{
+ XkbDescPtr xkb = xkbi->desc;
+ int effectiveGroup = xkbState->group;
+
+ if (!XkbKeycodeInRange(xkb, keycode))
+ return -1;
+
+ if (effectiveGroup == XkbGroup1Index)
+ return effectiveGroup;
+
+ if (XkbKeyNumGroups(xkb,keycode) > 1U) {
+ if (effectiveGroup >= XkbKeyNumGroups(xkb,keycode)) {
+ unsigned int gi = XkbKeyGroupInfo(xkb,keycode);
+ switch (XkbOutOfRangeGroupAction(gi)) {
+ default:
+ case XkbWrapIntoRange:
+ effectiveGroup %= XkbKeyNumGroups(xkb, keycode);
+ break;
+ case XkbClampIntoRange:
+ effectiveGroup = XkbKeyNumGroups(xkb, keycode) - 1;
+ break;
+ case XkbRedirectIntoRange:
+ effectiveGroup = XkbOutOfRangeGroupInfo(gi);
+ if (effectiveGroup >= XkbKeyNumGroups(xkb, keycode))
+ effectiveGroup = 0;
+ break;
+ }
+ }
+ }
+ else effectiveGroup = XkbGroup1Index;
+
+ return effectiveGroup;
+}
--
1.6.3.rc1.2.g0164.dirty
More information about the xorg-devel
mailing list