mirror of
https://github.com/minetest/irrlicht.git
synced 2025-07-04 17:20:25 +02:00
[SDL] Avoid unnecessarily "restarting" text input
This commit is contained in:
@ -219,17 +219,29 @@ void CIrrDeviceSDL::resetReceiveTextInputEvents() {
|
|||||||
gui::IGUIElement *elem = GUIEnvironment->getFocus();
|
gui::IGUIElement *elem = GUIEnvironment->getFocus();
|
||||||
if (elem && elem->acceptsIME())
|
if (elem && elem->acceptsIME())
|
||||||
{
|
{
|
||||||
core::rect<s32> pos = elem->getAbsolutePosition();
|
core::rect<s32> *pos = new core::rect<s32>(elem->getAbsolutePosition());
|
||||||
SDL_Rect rect;
|
if (lastElemPos == NULL || *lastElemPos != *pos)
|
||||||
rect.x = pos.UpperLeftCorner.X;
|
{
|
||||||
rect.y = pos.UpperLeftCorner.Y;
|
if (lastElemPos != NULL)
|
||||||
rect.w = pos.getWidth();
|
delete lastElemPos;
|
||||||
rect.h = pos.getHeight();
|
lastElemPos = pos;
|
||||||
SDL_SetTextInputRect(&rect);
|
SDL_Rect rect;
|
||||||
SDL_StartTextInput();
|
rect.x = pos->UpperLeftCorner.X;
|
||||||
|
rect.y = pos->UpperLeftCorner.Y;
|
||||||
|
rect.w = pos->getWidth();
|
||||||
|
rect.h = pos->getHeight();
|
||||||
|
SDL_SetTextInputRect(&rect);
|
||||||
|
SDL_StartTextInput();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete pos;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
delete lastElemPos;
|
||||||
|
lastElemPos = NULL;
|
||||||
SDL_StopTextInput();
|
SDL_StopTextInput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -310,6 +322,8 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
|
|||||||
createGUIAndScene();
|
createGUIAndScene();
|
||||||
VideoDriver->OnResize(core::dimension2d<u32>(Width, Height));
|
VideoDriver->OnResize(core::dimension2d<u32>(Width, Height));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastElemPos = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -323,6 +337,9 @@ CIrrDeviceSDL::~CIrrDeviceSDL()
|
|||||||
for (u32 i=0; i<numJoysticks; ++i)
|
for (u32 i=0; i<numJoysticks; ++i)
|
||||||
SDL_JoystickClose(Joysticks[i]);
|
SDL_JoystickClose(Joysticks[i]);
|
||||||
#endif
|
#endif
|
||||||
|
if (lastElemPos != NULL) {
|
||||||
|
delete lastElemPos;
|
||||||
|
}
|
||||||
if (Window)
|
if (Window)
|
||||||
{
|
{
|
||||||
SDL_GL_MakeCurrent(Window, NULL);
|
SDL_GL_MakeCurrent(Window, NULL);
|
||||||
|
@ -303,6 +303,8 @@ namespace irr
|
|||||||
|
|
||||||
bool Resizable;
|
bool Resizable;
|
||||||
|
|
||||||
|
core::rect<s32> *lastElemPos;
|
||||||
|
|
||||||
struct SKeyMap
|
struct SKeyMap
|
||||||
{
|
{
|
||||||
SKeyMap() {}
|
SKeyMap() {}
|
||||||
|
Reference in New Issue
Block a user