[Bf-blender-cvs] [b35e33317dd] master: Cleanup: update & correct comments for event handling

Campbell Barton noreply at git.blender.org
Thu Jul 14 08:13:56 CEST 2022


Commit: b35e33317dd3c1b0b4ceb3aa0b55f805661fdb05
Author: Campbell Barton
Date:   Thu Jul 14 16:10:13 2022 +1000
Branches: master
https://developer.blender.org/rBb35e33317dd3c1b0b4ceb3aa0b55f805661fdb05

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.

===================================================================

M	intern/ghost/GHOST_Types.h
M	source/blender/editors/interface/interface_region_menu_pie.cc
M	source/blender/makesdna/DNA_windowmanager_types.h
M	source/blender/windowmanager/intern/wm_event_system.cc
M	source/blender/windowmanager/wm_event_types.h

===================================================================

diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h
index fa74bfde866..495fb739978 100644
--- a/intern/ghost/GHOST_Types.h
+++ b/intern/ghost/GHOST_Types.h
@@ -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;
 
diff --git a/source/blender/editors/interface/interface_region_menu_pie.cc b/source/blender/editors/interface/interface_region_menu_pie.cc
index b11564f09c5..09902dd6c35 100644
--- a/source/blender/editors/interface/interface_region_menu_pie.cc
+++ b/source/blender/editors/interface/interface_region_menu_pie.cc
@@ -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 */
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index a3d9b5fc7b6..116ea4821cb 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -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)`
diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc
index a371fa7e185..757c3aae00c 100644
--- a/source/blender/windowmanager/intern/wm_event_system.cc
+++ b/source/blender/windowmanager/intern/wm_event_system.cc
@@ -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;
diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h
index 2d3624704d0..edac3ada73b 100644
--- a/source/blender/windowmanager/wm_event_types.h
+++ b/source/blender/windowmanager/wm_event_types.h
@@ -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) || \



More information about the Bf-blender-cvs mailing list