Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-07-14 14:39:31 +0300
committerCampbell Barton <campbell@blender.org>2022-07-14 14:54:28 +0300
commitcdd8b96e3b476df38847121102c6a267b5522a85 (patch)
tree7581ecdbb1d7416f91a45401d3e0f82aeb40f834
parenteb3e56a36e18fd4d560a31c2b60ceb235fd0da09 (diff)
GHOST: remove redundant ascii argument to GHOST_EventKey
Now only the utf8 buffer is used there is no reason to pass both.
-rw-r--r--intern/ghost/intern/GHOST_EventKey.h14
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm23
-rw-r--r--intern/ghost/intern/GHOST_SystemSDL.cpp3
-rw-r--r--intern/ghost/intern/GHOST_SystemWayland.cpp9
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.cpp5
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp10
6 files changed, 21 insertions, 43 deletions
diff --git a/intern/ghost/intern/GHOST_EventKey.h b/intern/ghost/intern/GHOST_EventKey.h
index d3cfbbeddd7..f85a674be9f 100644
--- a/intern/ghost/intern/GHOST_EventKey.h
+++ b/intern/ghost/intern/GHOST_EventKey.h
@@ -22,6 +22,7 @@ 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 is_repeat: Enabled for key repeat events (only for press events).
*/
GHOST_EventKey(
uint64_t msec, GHOST_TEventType type, GHOST_IWindow *window, GHOST_TKey key, bool is_repeat)
@@ -38,15 +39,15 @@ 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 is_repeat: Enabled for key repeat events (only for press events).
+ * \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 +57,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..c247ef3daa0 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -1779,7 +1779,6 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
NSString *characters;
NSData *convertedCharacters;
GHOST_TKey keyCode;
- unsigned char ascii;
NSString *charsIgnoringModifiers;
window = m_windowManager->getWindowAssociatedWithOSWindow((void *)[event window]);
@@ -1789,7 +1788,6 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
}
char utf8_buf[6] = {'\0'};
- ascii = 0;
switch ([event type]) {
@@ -1809,7 +1807,6 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
kUCKeyActionUp);
}
- /* handling both unicode or ascii */
characters = [event characters];
if ([characters length] > 0) {
convertedCharacters = [characters dataUsingEncoding:NSUTF8StringEncoding];
@@ -1835,41 +1832,31 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
if ((keyCode == GHOST_kKeyQ) && (m_modifierMask & NSEventModifierFlagCommand))
break; // Cmd-Q is directly handled by Cocoa
- /* ascii is a subset of unicode */
- if (utf8_buf[0] && !utf8_buf[1]) {
- ascii = utf8_buf[0];
- }
-
if ([event type] == NSEventTypeKeyDown) {
pushEvent(new GHOST_EventKey([event timestamp] * 1000,
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]);
}
}