WM: warn when event's have repeat set for non keyboard events
Also add docs to event and keymap item flag.
This commit is contained in:
parent
88660d67a4
commit
8da5599003
|
@ -383,6 +383,19 @@ enum {
|
|||
KMI_EXPANDED = (1 << 1),
|
||||
KMI_USER_MODIFIED = (1 << 2),
|
||||
KMI_UPDATE = (1 << 3),
|
||||
/**
|
||||
* When set, ignore events with #wmEvent.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
|
||||
* flag makes sense.
|
||||
*
|
||||
* Only used when: `ISKEYBOARD(kmi->type) || (kmi->type == KM_TEXTINPUT)`
|
||||
* as mouse, 3d-mouse, timer... etc never repeat.
|
||||
*/
|
||||
KMI_REPEAT_IGNORE = (1 << 4),
|
||||
};
|
||||
|
||||
|
|
|
@ -559,7 +559,12 @@ typedef struct wmEvent {
|
|||
/** From ghost, fallback if utf8 isn't set. */
|
||||
char ascii;
|
||||
|
||||
/** Generated by auto-repeat. */
|
||||
/**
|
||||
* Generated by auto-repeat, note that this must only ever be set for keyboard events
|
||||
* where `ISKEYBOARD(event->type) == true`.
|
||||
*
|
||||
* See #KMI_REPEAT_IGNORE for details on how key-map handling uses this.
|
||||
*/
|
||||
char is_repeat;
|
||||
|
||||
/** Previous state, used for double click and the 'click'. */
|
||||
|
|
|
@ -155,6 +155,15 @@ wmEvent *WM_event_add_simulate(wmWindow *win, const wmEvent *event_to_add)
|
|||
|
||||
void wm_event_free(wmEvent *event)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
/* Don't use assert here because it's fairly harmless in most cases,
|
||||
* more an issue of correctness, something we should avoid in general. */
|
||||
if (event->is_repeat && !ISKEYBOARD(event->type)) {
|
||||
printf("%s: 'is_repeat=true' for non-keyboard event, this should not happen.\n", __func__);
|
||||
WM_event_print(event);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (event->customdata) {
|
||||
if (event->customdatafree) {
|
||||
/* Note: pointer to listbase struct elsewhere. */
|
||||
|
|
Loading…
Reference in New Issue