Rename window from event thread

This commit is contained in:
Inori 2019-08-31 01:41:04 -04:00 committed by Inori
parent 3c157daf34
commit 6f2a9d66cb
3 changed files with 16 additions and 1 deletions

View file

@ -83,6 +83,7 @@ enum
REQUEST_SETFULLSCREEN = 0,
REQUEST_WINRESIZE,
REQUEST_WINREPOSITION,
REQUEST_WINRENAME,
REQUEST_MESSAGEBOX,
REQUEST_SETCURSORVISIBLE,
@ -413,6 +414,11 @@ void EventThread::process(RGSSThreadData &rtData)
case REQUEST_WINREPOSITION :
SDL_SetWindowPosition(win, event.window.data1, event.window.data2);
break;
case REQUEST_WINRENAME :
rtData.config.windowTitle = (const char*)event.user.data1;
SDL_SetWindowTitle(win, rtData.config.windowTitle.c_str());
break;
case REQUEST_MESSAGEBOX :
@ -601,6 +607,14 @@ void EventThread::requestWindowReposition(int x, int y)
SDL_PushEvent(&event);
}
void EventThread::requestWindowRename(const char *title)
{
SDL_Event event;
event.type = usrIdStart + REQUEST_WINRENAME;
event.user.data1 = (void*)title;
SDL_PushEvent(&event);
}
void EventThread::requestShowCursor(bool mode)
{
SDL_Event event;

View file

@ -87,6 +87,7 @@ public:
void requestFullscreenMode(bool mode);
void requestWindowResize(int width, int height);
void requestWindowReposition(int x, int y);
void requestWindowRename(const char *title);
void requestShowCursor(bool mode);
void requestTerminate();

View file

@ -303,7 +303,7 @@ MKXP_SetWindowPos(HWND hWnd,
PREFABI BOOL
MKXP_SetWindowTextA(HWND hWnd, LPCSTR lpString)
{
SDL_SetWindowTitle(shState->sdlWindow(), (const char*)lpString);
shState->eThread().requestWindowRename((const char*)lpString);
return true;
}