[Bf-blender-cvs] [9d35fc5a134] temp-ghost-remove-ascii-arg: Remove ASCII arguemnt from ghost (temp branch for testing)

Campbell Barton noreply at git.blender.org
Thu Jul 14 13:39:24 CEST 2022


Commit: 9d35fc5a134c5332754ac978e75941f71db37397
Author: Campbell Barton
Date:   Thu Jul 14 21:39:31 2022 +1000
Branches: temp-ghost-remove-ascii-arg
https://developer.blender.org/rB9d35fc5a134c5332754ac978e75941f71db37397

Remove ASCII arguemnt from ghost (temp branch for testing)

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

M	intern/ghost/intern/GHOST_EventKey.h
M	intern/ghost/intern/GHOST_SystemCocoa.mm
M	intern/ghost/intern/GHOST_SystemSDL.cpp
M	intern/ghost/intern/GHOST_SystemWayland.cpp
M	intern/ghost/intern/GHOST_SystemWin32.cpp
M	intern/ghost/intern/GHOST_SystemX11.cpp

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

diff --git a/intern/ghost/intern/GHOST_EventKey.h b/intern/ghost/intern/GHOST_EventKey.h
index d3cfbbeddd7..a110e61778c 100644
--- a/intern/ghost/intern/GHOST_EventKey.h
+++ b/intern/ghost/intern/GHOST_EventKey.h
@@ -38,15 +38,14 @@ class GHOST_EventKey : public GHOST_Event {
    * \param msec: The time this event was generated.
    * \param type: The type of key event.
    * \param key: The key code of the key.
-   * \param ascii: The ascii code for the key event.
+   * \param utf8_buf: The text associated with this key event (only for press events).
    */
   GHOST_EventKey(uint64_t msec,
                  GHOST_TEventType type,
                  GHOST_IWindow *window,
                  GHOST_TKey key,
-                 char ascii,
-                 const char utf8_buf[6],
-                 bool is_repeat)
+                 bool is_repeat,
+                 const char utf8_buf[6])
       : GHOST_Event(msec, type, window)
   {
     m_keyEventData.key = key;
@@ -56,11 +55,6 @@ class GHOST_EventKey : public GHOST_Event {
     else {
       m_keyEventData.utf8_buf[0] = '\0';
     }
-    /* TODO(@campbellbarton): phase out `ascii` and always use `utf8_buf`, this needs to be done
-     * on all platforms though, so for now write the ascii into the utf8_buf. */
-    if (m_keyEventData.utf8_buf[0] == '\0' && ascii) {
-      m_keyEventData.utf8_buf[0] = ascii;
-    }
     m_keyEventData.is_repeat = is_repeat;
     m_data = &m_keyEventData;
   }
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 0a905f5093e..a15d60fb2cf 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -1845,31 +1845,26 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
                                      GHOST_kEventKeyDown,
                                      window,
                                      keyCode,
-                                     ascii,
-                                     utf8_buf,
-                                     [event isARepeat]));
+                                     [event isARepeat],
+                                     utf8_buf));
 #if 0
-        printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",
+        printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u utf8=%s\n",
                [event keyCode],
                [charsIgnoringModifiers length] > 0 ? [charsIgnoringModifiers characterAtIndex:0] :
                                                      ' ',
                keyCode,
-               ascii,
-               ascii,
                utf8_buf);
 #endif
       }
       else {
         pushEvent(new GHOST_EventKey(
-            [event timestamp] * 1000, GHOST_kEventKeyUp, window, keyCode, 0, NULL, false));
+            [event timestamp] * 1000, GHOST_kEventKeyUp, window, keyCode, false, NULL));
 #if 0
-        printf("Key up rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",
+        printf("Key up rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u utf8=%s\n",
                [event keyCode],
                [charsIgnoringModifiers length] > 0 ? [charsIgnoringModifiers characterAtIndex:0] :
                                                      ' ',
                keyCode,
-               ascii,
-               ascii,
                utf8_buf);
 #endif
       }
diff --git a/intern/ghost/intern/GHOST_SystemSDL.cpp b/intern/ghost/intern/GHOST_SystemSDL.cpp
index 55a15ae470e..d912b57f049 100644
--- a/intern/ghost/intern/GHOST_SystemSDL.cpp
+++ b/intern/ghost/intern/GHOST_SystemSDL.cpp
@@ -608,8 +608,7 @@ void GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
         utf8_buf[0] = convert_keyboard_event_to_ascii(sdl_sub_evt);
       }
 
-      g_event = new GHOST_EventKey(
-          getMilliSeconds(), type, window, gkey, '\0', utf8_buf, is_repeat);
+      g_event = new GHOST_EventKey(getMilliSeconds(), type, window, gkey, is_repeat, utf8_buf);
       break;
     }
   }
diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 876f77732c2..099792a4d06 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -2257,8 +2257,8 @@ static void keyboard_handle_key(void *data,
 
   if (wl_surface *focus_surface = input->keyboard.wl_surface) {
     GHOST_IWindow *win = ghost_wl_surface_user_data(focus_surface);
-    input->system->pushEvent(new GHOST_EventKey(
-        input->system->getMilliSeconds(), etype, win, gkey, '\0', utf8_buf, false));
+    input->system->pushEvent(
+        new GHOST_EventKey(input->system->getMilliSeconds(), etype, win, gkey, false, utf8_buf));
   }
 
   /* An existing payload means the key repeat timer is reset and will be added again. */
@@ -2290,9 +2290,8 @@ static void keyboard_handle_key(void *data,
                                              GHOST_kEventKeyDown,
                                              win,
                                              payload->key_data.gkey,
-                                             '\0',
-                                             utf8_buf,
-                                             true));
+                                             true,
+                                             utf8_buf));
       }
     };
     input->key_repeat.timer = input->system->installTimer(
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index 1365c281ab4..5a930209376 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -1256,9 +1256,8 @@ GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_WindowWin32 *window, RA
                                keyDown ? GHOST_kEventKeyDown : GHOST_kEventKeyUp,
                                window,
                                key,
-                               ascii,
-                               utf8_char,
-                               is_repeat);
+                               is_repeat,
+                               utf8_char);
 
     // GHOST_PRINTF("%c\n", ascii); // we already get this info via EventPrinter
   }
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 4145856ee16..70a9687672c 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -745,9 +745,8 @@ bool GHOST_SystemX11::processEvents(bool waitForEvent)
                                                GHOST_kEventKeyDown,
                                                window,
                                                ghost_key_from_keysym(modifiers[i]),
-                                               '\0',
-                                               nullptr,
-                                               false));
+                                               false,
+                                               nullptr));
                 }
               }
             }
@@ -1206,8 +1205,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
         }
       }
 
-      g_event = new GHOST_EventKey(
-          getMilliSeconds(), type, window, gkey, '\0', utf8_buf, is_repeat);
+      g_event = new GHOST_EventKey(getMilliSeconds(), type, window, gkey, is_repeat, utf8_buf);
 
 #if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
       /* when using IM for some languages such as Japanese,
@@ -1232,7 +1230,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
           pushEvent(g_event);
 
           g_event = new GHOST_EventKey(
-              getMilliSeconds(), type, window, gkey, '\0', &utf8_buf[i], is_repeat);
+              getMilliSeconds(), type, window, gkey, is_repeat, &utf8_buf[i]);
         }
       }



More information about the Bf-blender-cvs mailing list