[PATCH xserver 2/2] xkb: Make overlay_perkey_state a bitfield

Mihail Konev k.mvc at ya.ru
Sun Jan 1 23:45:05 UTC 2017


Signed-off-by: Mihail Konev <k.mvc at ya.ru>
---
 include/xkbsrv.h |  3 ++-
 xkb/xkbPrKeyEv.c | 10 +++++++---
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index c766284d9cf3..7a3e3a46d823 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -53,6 +53,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #define	XkbApplyVirtualModChanges	SrvXkbApplyVirtualModChanges
 
 #include <X11/extensions/XKBproto.h>
+#include <X11/extensions/xtrapbits.h>
 #include "xkbstr.h"
 #include "xkbrules.h"
 #include "inputstr.h"
@@ -196,7 +197,7 @@ typedef struct _XkbSrvInfo {
 
     XkbSrvCheckRepeatPtr checkRepeat;
 
-    char overlay_perkey_state[256];
+    char overlay_perkey_state[256/BitsInByte];
 } XkbSrvInfoRec, *XkbSrvInfoPtr;
 
 #define	XkbSLI_IsDefault	(1L<<0)
diff --git a/xkb/xkbPrKeyEv.c b/xkb/xkbPrKeyEv.c
index 6f93291f8304..8e453bca2a10 100644
--- a/xkb/xkbPrKeyEv.c
+++ b/xkb/xkbPrKeyEv.c
@@ -41,6 +41,10 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <ctype.h>
 #include "events.h"
 
+#define True 1
+#define False 0
+#include <X11/extensions/xtrapbits.h>
+
 /***====================================================================***/
 
 void
@@ -134,13 +138,13 @@ XkbProcessKeyboardEvent(DeviceEvent *event, DeviceIntPtr keybd)
             overlay_active_now = (xkbi->desc->ctrls->enabled_ctrls & which) ? 1 : 0;
 
             if ((unsigned char)key == key) {
-                key_was_overlaid = xkbi->overlay_perkey_state[key];
+                key_was_overlaid = BitValue(xkbi->overlay_perkey_state, key);
                 if (!is_keyrelease) {
                     if (overlay_active_now)
-                        xkbi->overlay_perkey_state[key] = 1;
+                        BitTrue(xkbi->overlay_perkey_state, key);
                 } else {
                     if (key_was_overlaid)
-                        xkbi->overlay_perkey_state[key] = 0;
+                        BitFalse(xkbi->overlay_perkey_state, key);
                 }
             }
 
-- 
2.9.2



More information about the xorg-devel mailing list