From b9eab728507ff8beb2e4cde6e8403ed6719e5700 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Thu, 9 Aug 2018 11:19:36 +0200 Subject: [PATCH] add temporary workaround for ubuntu alt+enter bug until we got a better solution --- inc/main.h | 1 + src/main.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/inc/main.h b/inc/main.h index 28a3378..d44ef4f 100644 --- a/inc/main.h +++ b/inc/main.h @@ -96,6 +96,7 @@ typedef struct IDirectDrawImpl BOOL noactivateapp; char shader[MAX_PATH]; BOOL autorenderer; + BOOL wine; } IDirectDrawImpl; diff --git a/src/main.c b/src/main.c index 6bb9bcb..4ca4505 100644 --- a/src/main.c +++ b/src/main.c @@ -486,6 +486,9 @@ LRESULT CALLBACK dummy_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara return DefWindowProc(hWnd, uMsg, wParam, lParam); } +// LastSetWindowPosTick = Workaround for a wine+gnome bug where each SetWindowPos call triggers a WA_INACTIVE message +DWORD LastSetWindowPosTick; + void ToggleFullscreen() { if (ddraw->windowed) @@ -497,6 +500,7 @@ void ToggleFullscreen() SetWindowLong(ddraw->hWnd, GWL_STYLE, GetWindowLong(ddraw->hWnd, GWL_STYLE) & ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU)); SetWindowPos(ddraw->hWnd, HWND_TOPMOST, 0, 0, ddraw->render.width, ddraw->render.height, SWP_SHOWWINDOW); + LastSetWindowPosTick = timeGetTime(); } mouse_lock(); } @@ -583,6 +587,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) } else if (wParam == WA_INACTIVE) { + if (ddraw->wine && LastSetWindowPosTick + 500 > timeGetTime()) + { + LastSetWindowPosTick = 0; + return 0; + } + mouse_unlock(); /* minimize our window on defocus when in fullscreen */ @@ -985,6 +995,8 @@ HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnk This->render.ev = CreateEvent(NULL, TRUE, FALSE, NULL); This->render.sem = CreateSemaphore(NULL, 0, 1, NULL); + This->wine = GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_version") != 0; + /* load configuration options from ddraw.ini */ char cwd[MAX_PATH]; char tmp[256];