diff --git a/inc/dd.h b/inc/dd.h index 0ece75c..1c2dfb8 100644 --- a/inc/dd.h +++ b/inc/dd.h @@ -12,7 +12,7 @@ ULONG dd_AddRef(); ULONG dd_Release(); HRESULT dd_EnumDisplayModes(DWORD dwFlags, LPDDSURFACEDESC lpDDSurfaceDesc, LPVOID lpContext, LPDDENUMMODESCALLBACK lpEnumModesCallback); HRESULT dd_WaitForVerticalBlank(DWORD dwFlags, HANDLE hEvent); -HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, BOOL setByGame); +HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFlags); HRESULT dd_SetCooperativeLevel(HWND hwnd, DWORD dwFlags); HRESULT dd_RestoreDisplayMode(); HRESULT dd_GetCaps(LPDDCAPS_DX1 lpDDDriverCaps, LPDDCAPS_DX1 lpDDEmulCaps); @@ -26,6 +26,10 @@ HRESULT dd_CreateEx(GUID* lpGuid, LPVOID* lplpDD, REFIID iid, IUnknown* pUnkOute #define RESLIST_MINI 1 #define RESLIST_FULL 2 +#define SDM_MODE_SET_BY_GAME 0x00000001l +#define SDM_LEAVE_WINDOWED 0x00000002l +#define SDM_LEAVE_FULLSCREEN 0x00000004l + typedef struct SPEEDLIMITER { DWORD tick_length; @@ -106,7 +110,6 @@ typedef struct CNCDDRAW BOOL noactivateapp; char shader[MAX_PATH]; BOOL wine; - BOOL altenter; HCURSOR old_cursor; int show_cursor_count; BOOL accurate_timers; diff --git a/src/IDirectDraw/IDirectDraw.c b/src/IDirectDraw/IDirectDraw.c index 07d91a4..1ab1ecc 100644 --- a/src/IDirectDraw/IDirectDraw.c +++ b/src/IDirectDraw/IDirectDraw.c @@ -393,7 +393,7 @@ HRESULT __stdcall IDirectDraw__SetCooperativeLevel(IDirectDrawImpl* This, HWND h HRESULT __stdcall IDirectDraw__SetDisplayMode(IDirectDrawImpl* This, DWORD dwWidth, DWORD dwHeight, DWORD dwBPP) { TRACE("-> %s(This=%p, dwWidth=%d, dwHeight=%d, dwBPP=%d)\n", __FUNCTION__, This, dwWidth, dwHeight, dwBPP); - HRESULT ret = dd_SetDisplayMode(dwWidth, dwHeight, dwBPP, TRUE); + HRESULT ret = dd_SetDisplayMode(dwWidth, dwHeight, dwBPP, SDM_MODE_SET_BY_GAME); TRACE("<- %s\n", __FUNCTION__); return ret; } @@ -416,7 +416,7 @@ HRESULT __stdcall IDirectDraw__SetDisplayModeX( dwRefreshRate, dwFlags); - HRESULT ret = dd_SetDisplayMode(dwWidth, dwHeight, dwBPP, TRUE); + HRESULT ret = dd_SetDisplayMode(dwWidth, dwHeight, dwBPP, SDM_MODE_SET_BY_GAME); TRACE("<- %s\n", __FUNCTION__); return ret; diff --git a/src/dd.c b/src/dd.c index 118ca0d..5006c63 100644 --- a/src/dd.c +++ b/src/dd.c @@ -380,7 +380,7 @@ HRESULT dd_RestoreDisplayMode() return DD_OK; } -HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, BOOL setByGame) +HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFlags) { if (dwBPP != 8 && dwBPP != 16 && dwBPP != 32) return DDERR_INVALIDMODE; @@ -419,10 +419,8 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, BOOL setBy } } - if (g_ddraw->altenter) + if (dwFlags & SDM_LEAVE_WINDOWED) { - g_ddraw->altenter = FALSE; - memset(&g_ddraw->render.mode, 0, sizeof(DEVMODE)); g_ddraw->render.mode.dmSize = sizeof(DEVMODE); @@ -735,7 +733,7 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, BOOL setBy { g_ddraw->render.run = FALSE; g_ddraw->windowed = TRUE; - return dd_SetDisplayMode(dwWidth, dwHeight, dwBPP, setByGame); + return dd_SetDisplayMode(dwWidth, dwHeight, dwBPP, dwFlags); } if (g_ddraw->wine) @@ -771,7 +769,7 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, BOOL setBy g_ddraw->render.thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)g_ddraw->renderer, NULL, 0, NULL); } - if (setByGame) + if (dwFlags & SDM_MODE_SET_BY_GAME) { real_SendMessageA(g_ddraw->hwnd, WM_SIZE_DDRAW, 0, MAKELPARAM(g_ddraw->width, g_ddraw->height)); real_SendMessageA(g_ddraw->hwnd, WM_MOVE_DDRAW, 0, MAKELPARAM(0, 0)); diff --git a/src/utils.c b/src/utils.c index 0ed4ce5..f9ffa94 100644 --- a/src/utils.c +++ b/src/utils.c @@ -290,8 +290,7 @@ void util_toggle_fullscreen() GWL_STYLE, style & ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU)); - g_ddraw->altenter = TRUE; - dd_SetDisplayMode(g_ddraw->width, g_ddraw->height, g_ddraw->bpp, FALSE); + dd_SetDisplayMode(g_ddraw->width, g_ddraw->height, g_ddraw->bpp, SDM_LEAVE_WINDOWED); util_update_bnet_pos(0, 0); mouse_lock(); @@ -310,7 +309,7 @@ void util_toggle_fullscreen() ChangeDisplaySettings(NULL, g_ddraw->bnet_active ? CDS_FULLSCREEN : 0); } - dd_SetDisplayMode(g_ddraw->width, g_ddraw->height, g_ddraw->bpp, FALSE); + dd_SetDisplayMode(g_ddraw->width, g_ddraw->height, g_ddraw->bpp, SDM_LEAVE_FULLSCREEN); mouse_lock(); } } @@ -360,7 +359,7 @@ void util_set_window_rect(int x, int y, int width, int height, UINT flags) g_config.window_rect.right = width; } - dd_SetDisplayMode(g_ddraw->width, g_ddraw->height, g_ddraw->bpp, FALSE); + dd_SetDisplayMode(g_ddraw->width, g_ddraw->height, g_ddraw->bpp, 0); } } diff --git a/src/wndproc.c b/src/wndproc.c index 1fffd1e..4fe730c 100644 --- a/src/wndproc.c +++ b/src/wndproc.c @@ -226,7 +226,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam in_size_move = FALSE; if (!g_ddraw->render.thread) - dd_SetDisplayMode(g_ddraw->width, g_ddraw->height, g_ddraw->bpp, FALSE); + dd_SetDisplayMode(g_ddraw->width, g_ddraw->height, g_ddraw->bpp, 0); } break; }