Cleanup: update & correct comments for event handling
- Remove references to `ISTEXTINPUT` as any keyboard event with it's utf8_buf set can be handled as text input. - Update references to the key repeat flag.
This commit is contained in:
@@ -550,7 +550,12 @@ typedef struct {
|
||||
/** The unicode character. if the length is 6, not NULL terminated if all 6 are set. */
|
||||
char utf8_buf[6];
|
||||
|
||||
/** Generated by auto-repeat. */
|
||||
/**
|
||||
* Enabled when the key is held (auto-repeat).
|
||||
* In this case press events are sent without a corresponding release/up event.
|
||||
*
|
||||
* All back-ends must set this variable for correct behavior regarding repeatable keys.
|
||||
*/
|
||||
char is_repeat;
|
||||
} GHOST_TEventKeyData;
|
||||
|
||||
|
@@ -371,7 +371,7 @@ void ui_pie_menu_level_create(uiBlock *block,
|
||||
EnumPropertyItem *remaining = static_cast<EnumPropertyItem *>(
|
||||
MEM_mallocN(array_size + sizeof(EnumPropertyItem), "pie_level_item_array"));
|
||||
memcpy(remaining, items + totitem_parent, array_size);
|
||||
/* A nullptr terminating sentinel element is required. */
|
||||
/* A null terminating sentinel element is required. */
|
||||
memset(&remaining[totitem_remain], 0, sizeof(EnumPropertyItem));
|
||||
|
||||
/* yuk, static... issue is we can't reliably free this without doing dangerous changes */
|
||||
|
@@ -407,13 +407,13 @@ enum {
|
||||
KMI_USER_MODIFIED = (1 << 2),
|
||||
KMI_UPDATE = (1 << 3),
|
||||
/**
|
||||
* When set, ignore events with #wmEvent.is_repeat enabled.
|
||||
* When set, ignore events with `wmEvent.flag & WM_EVENT_IS_REPEAT` enabled.
|
||||
*
|
||||
* \note this flag isn't cleared when editing/loading the key-map items,
|
||||
* so it may be set in cases which don't make sense (modifier-keys or mouse-motion for example).
|
||||
*
|
||||
* Knowing if an event may repeat is something set at the operating-systems event handling level
|
||||
* so rely on #wmEvent.is_repeat being false non keyboard events instead of checking if this
|
||||
* so rely on #WM_EVENT_IS_REPEAT being false non keyboard events instead of checking if this
|
||||
* flag makes sense.
|
||||
*
|
||||
* Only used when: `ISKEYBOARD(kmi->type) || (kmi->type == KM_TEXTINPUT)`
|
||||
|
@@ -2086,8 +2086,6 @@ static bool wm_eventmatch(const wmEvent *winevent, const wmKeyMapItem *kmi)
|
||||
/* The matching rules. */
|
||||
if (kmitype == KM_TEXTINPUT) {
|
||||
if (winevent->val == KM_PRESS) { /* Prevent double clicks. */
|
||||
/* Not using #ISTEXTINPUT anymore because (at least on Windows) some key codes above 255
|
||||
* could have printable ascii keys, See T30479. */
|
||||
if (ISKEYBOARD(winevent->type) && winevent->utf8_buf[0]) {
|
||||
return true;
|
||||
}
|
||||
@@ -5328,7 +5326,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
|
||||
break;
|
||||
}
|
||||
|
||||
/* Might be not nullptr terminated. */
|
||||
/* Might be not null terminated. */
|
||||
memcpy(event.utf8_buf, kd->utf8_buf, sizeof(event.utf8_buf));
|
||||
if (kd->is_repeat) {
|
||||
event.flag |= WM_EVENT_IS_REPEAT;
|
||||
|
@@ -358,12 +358,6 @@ enum {
|
||||
/** Test whether the event is timer event. */
|
||||
#define ISTIMER(event_type) ((event_type) >= TIMER && (event_type) <= TIMERF)
|
||||
|
||||
/* for event checks */
|
||||
/* only used for KM_TEXTINPUT, so assume that we want all user-inputtable ascii codes included */
|
||||
/* Unused, see #wm_eventmatch, see: T30479. */
|
||||
// #define ISTEXTINPUT(event_type) ((event_type) >= ' ' && (event_type) <= 255)
|
||||
/* NOTE: an alternative could be to check `event->utf8_buf`. */
|
||||
|
||||
/** Test whether the event is a key on the keyboard (including modifier keys). */
|
||||
#define ISKEYBOARD(event_type) \
|
||||
(((event_type) >= _EVT_KEYBOARD_MIN && (event_type) <= _EVT_KEYBOARD_MAX) || \
|
||||
|
Reference in New Issue
Block a user