Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

[SDL] Improve handling of IMEs #285

Merged
merged 6 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 21 additions & 1 deletion source/Irrlicht/CIrrDeviceSDL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,29 @@ int CIrrDeviceSDL::findCharToPassToIrrlicht(int assumedChar, EKEY_CODE key) {
void CIrrDeviceSDL::resetReceiveTextInputEvents() {
gui::IGUIElement *elem = GUIEnvironment->getFocus();
if (elem && elem->acceptsIME())
SDL_StartTextInput();
{
// IBus seems to have an issue where dead keys and compose keys do not
// work (specifically, the individual characters in the sequence are
// sent as text input events instead of the result) when
// SDL_StartTextInput() is called on the same input box.
core::rect<s32> pos = elem->getAbsolutePosition();
if (!lastElemPos || *lastElemPos != pos)
{
lastElemPos = pos;
SDL_Rect rect;
rect.x = pos.UpperLeftCorner.X;
rect.y = pos.UpperLeftCorner.Y;
rect.w = pos.getWidth();
rect.h = pos.getHeight();
SDL_SetTextInputRect(&rect);
SDL_StartTextInput();
}
}
else
{
lastElemPos.reset();
SDL_StopTextInput();
}
}

//! constructor
Expand Down
3 changes: 3 additions & 0 deletions source/Irrlicht/CIrrDeviceSDL.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <SDL_syswm.h>

#include <memory>
#include <optional>

namespace irr
{
Expand Down Expand Up @@ -303,6 +304,8 @@ namespace irr

bool Resizable;

std::optional<core::rect<s32>> lastElemPos;
y5nw marked this conversation as resolved.
Show resolved Hide resolved

struct SKeyMap
{
SKeyMap() {}
Expand Down