diff --git a/Source/init.cpp b/Source/init.cpp index e60f19ce0..efac211da 100644 --- a/Source/init.cpp +++ b/Source/init.cpp @@ -2,6 +2,7 @@ #include "../3rdParty/Storm/Source/storm.h" #include "../DiabloUI/diabloui.h" +#include DEVILUTION_BEGIN_NAMESPACE @@ -14,7 +15,6 @@ WNDPROC CurrentProc; HANDLE diabdat_mpq; char diabdat_mpq_path[MAX_PATH]; HANDLE patch_rt_mpq; -BOOLEAN screensaver_enabled_prev; /* data */ @@ -24,7 +24,6 @@ char gszProductName[MAX_PATH] = "Diablo v1.09"; void init_cleanup(BOOL show_cursor) { pfile_flush_W(); - init_disable_screensaver(0); if (diabdat_mpq) { SFileCloseArchive(diabdat_mpq); @@ -50,38 +49,6 @@ void init_cleanup(BOOL show_cursor) ShowCursor(TRUE); } -void init_disable_screensaver(BOOLEAN disable) -{ - BOOLEAN enabled; - char Data[16]; - DWORD Type, cbData; - HKEY phkResult; - LRESULT success; - - // BUGFIX: this is probably the worst possible way to do this. Alternatives: ExtEscape() with SETPOWERMANAGEMENT, - // SystemParametersInfo() with SPI_SETSCREENSAVEACTIVE/SPI_SETPOWEROFFACTIVE/SPI_SETLOWPOWERACTIVE - - success = RegOpenKeyEx(HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, KEY_READ | KEY_WRITE, (PHKEY)&phkResult); - if (success != ERROR_SUCCESS) { - return; - } - - if (disable) { - cbData = 16; - success = RegQueryValueEx(phkResult, "ScreenSaveActive", 0, &Type, (LPBYTE)Data, &cbData); - if (success == ERROR_SUCCESS) - screensaver_enabled_prev = Data[0] != '0'; - enabled = FALSE; - } else { - enabled = screensaver_enabled_prev; - } - - Data[1] = 0; - Data[0] = enabled ? '1' : '0'; - RegSetValueEx(phkResult, "ScreenSaveActive", 0, REG_SZ, (const BYTE *)Data, 2); - RegCloseKey(phkResult); -} - void init_create_window(int nCmdShow) { int nWidth, nHeight; @@ -106,7 +73,7 @@ void init_create_window(int nCmdShow) BlackPalette(); snd_init(hWnd); init_archives(); - init_disable_screensaver(1); + SDL_DisableScreenSaver(); } void init_archives() @@ -227,18 +194,8 @@ LRESULT __stdcall MainWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) void init_activate_window(HWND hWnd, BOOL bActive) { - LONG dwNewLong; - gbActive = bActive; UiAppActivate(bActive); - dwNewLong = GetWindowLong(hWnd, GWL_STYLE); - - if (gbActive && fullscreen) - dwNewLong &= ~WS_SYSMENU; - else - dwNewLong |= WS_SYSMENU; - - SetWindowLong(hWnd, GWL_STYLE, dwNewLong); if (gbActive) { drawpanflag = 255; diff --git a/SourceS/miniwin/misc.h b/SourceS/miniwin/misc.h index d0570365b..79f929687 100644 --- a/SourceS/miniwin/misc.h +++ b/SourceS/miniwin/misc.h @@ -419,14 +419,8 @@ DWORD WINAPI GetPrivateProfileStringA(LPCSTR lpAppName, LPCSTR lpKeyName, LPCSTR int MessageBoxA(HWND hWnd, const char *Text, const char *Title, UINT Flags); typedef LONG LSTATUS, HKEY, REGSAM, PHKEY; -LSTATUS RegOpenKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult); -LSTATUS RegQueryValueExA(HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, BYTE *lpData, LPDWORD lpcbData); -LSTATUS RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, const BYTE *lpData, DWORD cbData); -LSTATUS RegCloseKeyA(HKEY hKey); void PostQuitMessage(int nExitCode); LRESULT DefWindowProcA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); -LONG GetWindowLongA(HWND hWnd, int nIndex); -LONG SetWindowLongA(HWND hWnd, int nIndex, LONG dwNewLong); WINBOOL WINAPI WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped); diff --git a/SourceS/miniwin/misc_macro.h b/SourceS/miniwin/misc_macro.h index 1dc0658e8..252cf6ef3 100644 --- a/SourceS/miniwin/misc_macro.h +++ b/SourceS/miniwin/misc_macro.h @@ -126,13 +126,7 @@ #define KEY_WRITE 0x20006 #define REG_SZ 1 -#define RegOpenKeyEx RegOpenKeyExA -#define RegQueryValueEx RegQueryValueExA -#define RegSetValueEx RegSetValueExA -#define RegCloseKey RegCloseKeyA #define DefWindowProc DefWindowProcA -#define GetWindowLong GetWindowLongA -#define SetWindowLong SetWindowLongA #define GetFileAttributes GetFileAttributesA #define SetFileAttributes SetFileAttributesA diff --git a/SourceS/sdl2_to_1_2_backports.h b/SourceS/sdl2_to_1_2_backports.h index 5ac74ae07..2d2ad42e5 100644 --- a/SourceS/sdl2_to_1_2_backports.h +++ b/SourceS/sdl2_to_1_2_backports.h @@ -6,6 +6,7 @@ #include #include #include +#include #include "../SourceX/stubs.h" @@ -73,6 +74,11 @@ inline SDL_bool SDL_PointInRect(const SDL_Point *p, const SDL_Rect *r) return ((p->x >= r->x) && (p->x < (r->x + r->w)) && (p->y >= r->y) && (p->y < (r->y + r->h))) ? SDL_TRUE : SDL_FALSE; } +inline void SDL_DisableScreenSaver() +{ + DUMMY(); +} + //= Messagebox (simply logged to stderr for now) typedef enum { diff --git a/SourceX/miniwin/misc.cpp b/SourceX/miniwin/misc.cpp index d42adf3f5..86e28b8d9 100644 --- a/SourceX/miniwin/misc.cpp +++ b/SourceX/miniwin/misc.cpp @@ -527,49 +527,6 @@ int MessageBoxA(HWND hWnd, const char *Text, const char *Title, UINT Flags) return 0; } -LSTATUS RegOpenKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult) -{ - return 1; -}; - -/** - * @brief This is only ever used to enable or disable the screen saver in a hackish way - * For all other settings operation SReg* from Storm is used instead. - */ -LSTATUS RegQueryValueExA(HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, BYTE *lpData, LPDWORD lpcbData) -{ - #ifndef USE_SDL1 - if (SDL_IsScreenSaverEnabled()) { - lpData[0] = '0'; - lpData[1] = '\0'; - } - #endif - - return 1; -}; - -/** - * @brief This is only ever used to enable or disable the screen saver in a hackish way - * For all other settings operation SReg* from Storm is used instead. - */ -LSTATUS RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, const BYTE *lpData, DWORD cbData) -{ - #ifndef USE_SDL1 - if (lpData[0] == '0') { - SDL_DisableScreenSaver(); - } else { - SDL_EnableScreenSaver(); - } - #endif - - return 1; -}; - -LSTATUS RegCloseKeyA(HKEY hKey) -{ - return 1; -}; - void PostQuitMessage(int nExitCode) { DUMMY(); @@ -584,16 +541,4 @@ LRESULT DefWindowProcA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) return 0; } - -LONG GetWindowLongA(HWND hWnd, int nIndex) -{ - DUMMY(); - return 0; -} - -LONG SetWindowLongA(HWND hWnd, int nIndex, LONG dwNewLong) -{ - DUMMY(); - return 0; -} }