Add XKB_KEYSYM_MIN and XKB_KEYSYM_MAX
Keysyms are 32-bit integers with the 3 most significant bits always set to zero. See: Appendix A “KEYSYM Encoding” of the X Window System Protocol at https://www.x.org/releases/current/doc/xproto/x11protocol.html#keysym_encoding. Add a new constants XKB_KEYSYM_MIN and XKB_KEYSYM_MAX to make the interval of valid keysyms more obvious in the code.master
parent
0d01a933bb
commit
e811743ff2
|
@ -303,6 +303,15 @@ typedef uint32_t xkb_led_mask_t;
|
||||||
|
|
||||||
#define XKB_KEYCODE_MAX (0xffffffff - 1)
|
#define XKB_KEYCODE_MAX (0xffffffff - 1)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum keysym value
|
||||||
|
*
|
||||||
|
* @since 1.6.0
|
||||||
|
* @sa xkb_keysym_t
|
||||||
|
* @ingroup keysyms
|
||||||
|
*/
|
||||||
|
#define XKB_KEYSYM_MAX 0x1fffffff
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test whether a value is a valid extended keycode.
|
* Test whether a value is a valid extended keycode.
|
||||||
* @sa xkb_keycode_t
|
* @sa xkb_keycode_t
|
||||||
|
|
|
@ -64,7 +64,7 @@ get_name(const struct name_keysym *entry)
|
||||||
XKB_EXPORT int
|
XKB_EXPORT int
|
||||||
xkb_keysym_get_name(xkb_keysym_t ks, char *buffer, size_t size)
|
xkb_keysym_get_name(xkb_keysym_t ks, char *buffer, size_t size)
|
||||||
{
|
{
|
||||||
if ((ks & ((unsigned long) ~0x1fffffff)) != 0) {
|
if (ks > XKB_KEYSYM_MAX) {
|
||||||
snprintf(buffer, size, "Invalid");
|
snprintf(buffer, size, "Invalid");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,14 @@
|
||||||
#ifndef KEYSYM_H
|
#ifndef KEYSYM_H
|
||||||
#define KEYSYM_H
|
#define KEYSYM_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NOTE: this is not defined in xkbcommon.h, because if we did, it may add
|
||||||
|
* overhead for library user: when handling keysyms they would also need to
|
||||||
|
* check min keysym when previously there was no reason to.
|
||||||
|
*/
|
||||||
|
/** Minimum keysym value */
|
||||||
|
#define XKB_KEYSYM_MIN 0x00000000
|
||||||
|
|
||||||
bool
|
bool
|
||||||
xkb_keysym_is_lower(xkb_keysym_t keysym);
|
xkb_keysym_is_lower(xkb_keysym_t keysym);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue