From d08c07b42a421ad468e2c5414f705939546bd8e5 Mon Sep 17 00:00:00 2001 From: Inori Date: Thu, 8 Aug 2019 09:40:50 -0400 Subject: [PATCH] Use own GetWindowRect instead of WinAPI's --- binding/miniffi-binding.cpp | 1 + src/fake-api.cpp | 18 ++++++++++++++++++ src/fake-api.h | 3 +++ 3 files changed, 22 insertions(+) diff --git a/binding/miniffi-binding.cpp b/binding/miniffi-binding.cpp index 084b9d96..138629c4 100644 --- a/binding/miniffi-binding.cpp +++ b/binding/miniffi-binding.cpp @@ -48,6 +48,7 @@ MiniFFI_GetFunctionHandle(void *lib, const char *func) CAPTURE(GetCursorPos); CAPTURE(ScreenToClient); CAPTURE(SetWindowPos); + CAPTURE(GetWindowRect); CAPTURE(RegisterHotKey); #endif return SDL_LoadFunction(lib, func); diff --git a/src/fake-api.cpp b/src/fake-api.cpp index 435f39a4..86e73df3 100644 --- a/src/fake-api.cpp +++ b/src/fake-api.cpp @@ -115,6 +115,24 @@ MKXP_SetWindowPos(HWND hWnd, return true; } + +// Games that use this to resize the window won't center +// themselves, but it's better than having the window sent +// so far into the corner that you can't even grab onto +// the title bar +BOOL __stdcall +MKXP_GetWindowRect(HWND hWnd, LPRECT lpRect) +{ + int cur_x, cur_y, cur_w, cur_h; + SDL_GetWindowPosition(shState->sdlWindow(), &cur_x, &cur_y); + SDL_GetWindowSize(shState->sdlWindow(), &cur_w, &cur_h); + lpRect->left = cur_x; + lpRect->right = cur_x + cur_w + 1; + lpRect->top = cur_y; + lpRect->bottom = cur_y + cur_h + 1; + return true; +} + BOOL __stdcall MKXP_RegisterHotKey(HWND hWnd, int id, diff --git a/src/fake-api.h b/src/fake-api.h index 8b30b17a..a9c79575 100644 --- a/src/fake-api.h +++ b/src/fake-api.h @@ -63,6 +63,9 @@ MKXP_SetWindowPos(HWND hWnd, int cy, UINT uFlags); +BOOL __stdcall +MKXP_GetWindowRect(HWND hWnd, LPRECT lpRect); + BOOL __stdcall MKXP_RegisterHotKey(HWND hWnd, int id,