Remove `SDL_HINT_IME_SUPPORT_EXTENDED_TEXT` and use `SDL_GetEventState` to enable/disable it instead
Description
Removes the hint SDL_HINT_IME_SUPPORT_EXTENDED_TEXT.
Instead applications can use SDL_EventState(SDL_TEXTEDITING_EXT, SDL_ENABLE) to enable extended text editing events.
Keep in mind that SDL_EventState needs to be called after SDL_Init, as the default value is set during initialisation.
I find it a bit strange that defaults for events get set in SDL_StartEventLoop. I would expect them to be set in SDL_EventsInit.
Existing Issue(s)
- Discussed in https://github.com/libsdl-org/SDL/issues/6573#issuecomment-1325574683
Migration for those using SDL_HINT_IME_SUPPORT_EXTENDED_TEXT
- /* Enable extended text editing events */
- SDL_SetHint(SDL_HINT_IME_SUPPORT_EXTENDED_TEXT, "1");
/* Initialize SDL */
SDL_Init(...);
+ /* Enable extended text editing events */
+ SDL_EventState(SDL_TEXTEDITING_EXT, SDL_ENABLE);
Adding @icculus to review and make the appropriate change in sdl2-compat
Please add an entry to docs/README-migration.txt documenting the change and how applications should be updated for it.
Wouldn't it be better to just drop the non-extended version? I would argue that it isn't very useful (and changes behavior depending on the platform).
Yes, we should probably rethink how the original event works and just fix that.
Are string allocations a concern in SDL? SDL_TextEditingEvent has no allocation, the 32 byte buffer is plentiful for most usages.
Wouldn't it be better to just drop the non-extended version? I would argue that it isn't very useful (and changes behavior depending on the platform).
That could work too. But applications need to be careful to always SDL_Free the text, even if they're not handling / doing anything useful with the SDL_TextEditingEvents.
If this is the way forward, I would suggest that the regular SDL_TextInputEvent also be converted to use a dynamically allocated string, and not a fixed buffer. Currently it sends multiple events if the text is longer than 32 bytes thus breaking the expectation that one user input = one text event.
This hint is gone, so we don't need this PR anymore.