Fix input method candidates being aligned wrong in some cases

Namely when the main window is resizeable and its size isn't the same as it would be with the active scale mode with resizing disabled.

Also fix window position not being restored when the main window is resizeable.
This commit is contained in:
Tamás Bálint Misius 2023-10-05 20:08:17 +02:00
parent 0fb36012a2
commit 79760f5c89
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2
2 changed files with 11 additions and 9 deletions

View File

@ -42,11 +42,15 @@ void StopTextInput()
void SetTextInputRect(int x, int y, int w, int h) void SetTextInputRect(int x, int y, int w, int h)
{ {
// Why does SDL_SetTextInputRect not take logical coordinates???
int wx, wy, wwx, why;
SDL_RenderLogicalToWindow(sdl_renderer, x, y, &wx, &wy);
SDL_RenderLogicalToWindow(sdl_renderer, x + w, y + h, &wwx, &why);
SDL_Rect rect; SDL_Rect rect;
rect.x = x; rect.x = wx;
rect.y = y; rect.y = wy;
rect.w = w; rect.w = wwx - wx;
rect.h = h; rect.h = why - wy;
SDL_SetTextInputRect(&rect); SDL_SetTextInputRect(&rect);
} }
@ -241,13 +245,12 @@ void SDLSetScreen()
//Uncomment this to enable resizing //Uncomment this to enable resizing
//SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); //SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
//SDL_SetWindowResizable(sdl_window, SDL_TRUE); //SDL_SetWindowResizable(sdl_window, SDL_TRUE);
LoadWindowPosition();
UpdateFpsLimit();
} }
SDL_SetWindowSize(sdl_window, size.X, size.Y); SDL_SetWindowSize(sdl_window, size.X, size.Y);
SDL_RenderSetIntegerScale(sdl_renderer, newFrameOpsNorm.forceIntegerScaling ? SDL_TRUE : SDL_FALSE); SDL_RenderSetIntegerScale(sdl_renderer, newFrameOpsNorm.forceIntegerScaling ? SDL_TRUE : SDL_FALSE);
LoadWindowPosition();
UpdateFpsLimit();
if (newFrameOpsNorm.fullscreen) if (newFrameOpsNorm.fullscreen)
{ {
SDL_RaiseWindow(sdl_window); SDL_RaiseWindow(sdl_window);

View File

@ -331,6 +331,5 @@ void Engine::StopTextInput()
void Engine::TextInputRect(Point position, Point size) void Engine::TextInputRect(Point position, Point size)
{ {
auto scale = windowFrameOps.scale; ::SetTextInputRect(position.X, position.Y, size.X, size.Y);
::SetTextInputRect(position.X * scale, position.Y * scale, size.X * scale, size.Y * scale);
} }