mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-09-10 12:02:53 +02:00
Reposition window from event thread
This commit is contained in:
parent
8954a5892f
commit
f4e2524a24
4 changed files with 22 additions and 14 deletions
|
@ -82,6 +82,7 @@ enum
|
|||
{
|
||||
REQUEST_SETFULLSCREEN = 0,
|
||||
REQUEST_WINRESIZE,
|
||||
REQUEST_WINREPOSITION,
|
||||
REQUEST_MESSAGEBOX,
|
||||
REQUEST_SETCURSORVISIBLE,
|
||||
|
||||
|
@ -409,6 +410,10 @@ void EventThread::process(RGSSThreadData &rtData)
|
|||
case REQUEST_WINRESIZE :
|
||||
SDL_SetWindowSize(win, event.window.data1, event.window.data2);
|
||||
break;
|
||||
|
||||
case REQUEST_WINREPOSITION :
|
||||
SDL_SetWindowPosition(win, event.window.data1, event.window.data2);
|
||||
break;
|
||||
|
||||
case REQUEST_MESSAGEBOX :
|
||||
SDL_ShowSimpleMessageBox(event.user.code,
|
||||
|
@ -587,6 +592,15 @@ void EventThread::requestWindowResize(int width, int height)
|
|||
SDL_PushEvent(&event);
|
||||
}
|
||||
|
||||
void EventThread::requestWindowReposition(int x, int y)
|
||||
{
|
||||
SDL_Event event;
|
||||
event.type = usrIdStart + REQUEST_WINREPOSITION;
|
||||
event.window.data1 = x;
|
||||
event.window.data2 = y;
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
|
||||
void EventThread::requestShowCursor(bool mode)
|
||||
{
|
||||
SDL_Event event;
|
||||
|
|
|
@ -86,6 +86,7 @@ public:
|
|||
/* Called from RGSS thread */
|
||||
void requestFullscreenMode(bool mode);
|
||||
void requestWindowResize(int width, int height);
|
||||
void requestWindowReposition(int x, int y);
|
||||
void requestShowCursor(bool mode);
|
||||
|
||||
void requestTerminate();
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "sharedstate.h"
|
||||
#include "eventthread.h"
|
||||
#include "filesystem.h"
|
||||
#include "graphics.h"
|
||||
#include "input.h"
|
||||
#include "fake-api.h"
|
||||
|
||||
|
@ -293,16 +292,11 @@ MKXP_SetWindowPos(HWND hWnd,
|
|||
int cy,
|
||||
UINT uFlags)
|
||||
{
|
||||
// Setting window position still doesn't work with
|
||||
// SetWindowPos, but it still needs to be called
|
||||
// because Win32API.restoreScreen is picky about its
|
||||
// metrics
|
||||
#ifdef __WIN32__
|
||||
SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags);
|
||||
#else
|
||||
//SDL_SetWindowSize(shState->sdlWindow(), cx, cy);
|
||||
#endif
|
||||
SDL_SetWindowPosition(shState->sdlWindow(), X, Y);
|
||||
// The game calls resize_screen which will automatically
|
||||
// ... well, resize the screen
|
||||
//shState->eThread().requestWindowResize(cx, cy);
|
||||
|
||||
shState->eThread().requestWindowReposition(X, Y);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -344,11 +338,11 @@ MKXP_SetWindowLong(HWND hWnd, int nIndex, LONG dwNewLong)
|
|||
{
|
||||
if (dwNewLong == 0)
|
||||
{
|
||||
shState->graphics().setFullscreen(true);
|
||||
shState->eThread().requestFullscreenMode(true);
|
||||
}
|
||||
else if (dwNewLong == 0x14ca0000)
|
||||
{
|
||||
shState->graphics().setFullscreen(false);
|
||||
shState->eThread().requestFullscreenMode(false);
|
||||
}
|
||||
}
|
||||
return DUMMY_VAL;
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include "binding.h"
|
||||
#include "debugwriter.h"
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL_video.h>
|
||||
#include <SDL_timer.h>
|
||||
#include <SDL_image.h>
|
||||
|
|
Loading…
Add table
Reference in a new issue