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

Peter Hutterer peter.hutterer at who-t.net
Wed Jan 4 01:19:35 UTC 2017


On Mon, Jan 02, 2017 at 04:45:05AM +0500, Mihail Konev wrote:
> 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>

use the BitIsOn, SetBit, ClearBit from include/inputstr.h, they are the ones
we use elsewhere in the server and are a bit more obvious, imo. plus...

>  #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>
> +

.. they don't require you to define true/false :)

Please squash this patch in with the other one, there isn't really a need to
add the overlay state first then reduce it to a bitmask, we can just do this
directly. Otherwise this looks good, thanks.

Cheers,
   Peter

>  /***====================================================================***/
>  
>  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