https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f0995dac581f7db5c70c8e6ae054b266f53a68e9
commit f0995dac581f7db5c70c8e6ae054b266f53a68e9 Author: Carl J. Bialorucki <cbia...@outlook.com> AuthorDate: Sun Sep 3 13:18:23 2023 -0600 Commit: GitHub <nore...@github.com> CommitDate: Sun Sep 3 21:18:23 2023 +0200 [LOGON] Several improvements for screensaver (#5641) - Currently the logo moves around every two seconds. This is not consistent with Windows Server 2003 (and other versions) and is very distracting. Increase the interval to every ten seconds, which matches Win2003. - There are currently two identical copies of the logo bitmap in the screensaver. Use only one copy of the logo bitmap. - Shrink the space around the logo bitmap. This should save some disk space but more importantly allow the logo to reach closer to the edges of the screen, similar to Win2003. - Remove unneeded includes. --- base/applications/screensavers/logon/logon.c | 164 ++++++++++--------------- base/applications/screensavers/logon/logon.rc | 5 +- base/applications/screensavers/logon/res/0.bmp | Bin 230454 -> 101078 bytes base/applications/screensavers/logon/res/1.bmp | Bin 230454 -> 0 bytes 4 files changed, 71 insertions(+), 98 deletions(-) diff --git a/base/applications/screensavers/logon/logon.c b/base/applications/screensavers/logon/logon.c index 20e66f2fb70..bf84b782723 100644 --- a/base/applications/screensavers/logon/logon.c +++ b/base/applications/screensavers/logon/logon.c @@ -18,127 +18,95 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include <stdarg.h> +#include <stdlib.h> #include <windef.h> #include <winbase.h> #include <wingdi.h> #include <winuser.h> #include <scrnsave.h> -#include <stdlib.h> -#include <tchar.h> #include "resource.h" -#define RANDOM( min, max ) ((rand() % (int)(((max)+1) - (min))) + (min)) +#define RANDOM(min, max) ((rand() % (int)(((max)+1) - (min))) + (min)) -#define APPNAME _T("Logon") #define APP_TIMER 1 -#define APP_TIMER_INTERVAL 2000 +#define APP_TIMER_INTERVAL 10000 +static HBITMAP GetScreenSaverBitmap(VOID) { - OSVERSIONINFOEX osvi; - - ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - GetVersionEx ((OSVERSIONINFO *) &osvi); - - switch(osvi.wProductType) - { - case VER_NT_WORKSTATION: - return LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_WORKSTATION), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); - break; - default: - return LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_SERVER), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); - break; - } + OSVERSIONINFOEX osvi = {0}; + osvi.dwOSVersionInfoSize = sizeof(osvi); + GetVersionEx((POSVERSIONINFO)&osvi); + + return LoadImageW(GetModuleHandle(NULL), + osvi.wProductType == VER_NT_WORKSTATION ? + MAKEINTRESOURCEW(IDB_WORKSTATION) : MAKEINTRESOURCEW(IDB_SERVER), + IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); } LRESULT CALLBACK -ScreenSaverProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +ScreenSaverProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - static RECT rect; static HBITMAP bitmap; - switch (message) + switch (uMsg) { case WM_CREATE: { - bitmap = GetScreenSaverBitmap (); + bitmap = GetScreenSaverBitmap(); if (bitmap == NULL) { - MessageBox(hWnd, - _T("Fatal Error: Could not load bitmap"), - _T("Error"), - MB_OK | MB_ICONEXCLAMATION); + /* Extremely unlikely, message not localized. */ + MessageBoxW(hWnd, + L"Fatal Error: Could not load bitmap", + L"Error", + MB_OK | MB_ICONEXCLAMATION); } - SetTimer(hWnd, - APP_TIMER, - APP_TIMER_INTERVAL, - NULL); - - break; + SetTimer(hWnd, APP_TIMER, APP_TIMER_INTERVAL, NULL); + break; } case WM_PAINT: { - BITMAP bm; /* Bitmap structure as seen in bmWidth & bmHeight */ - PAINTSTRUCT ps; - HDC hdc; - HDC hdcMem; - HBITMAP hbmOld; - - // Obtain window coordinates. - GetClientRect (hWnd, &rect); - - hdc = BeginPaint(hWnd, &ps); - hdcMem = CreateCompatibleDC(hdc); - hbmOld = SelectObject(hdcMem, bitmap); - - GetObject(bitmap, sizeof(bm), &bm); - - if (rect.right < bm.bmWidth || - rect.bottom < bm.bmHeight) - { - StretchBlt( - hdc, - RANDOM (0, rect.right - (bm.bmWidth /5)), - RANDOM (0, rect.bottom - (bm.bmHeight /5)), - bm.bmWidth /5, - bm.bmHeight /5, - hdcMem, - 0, - 0, - bm.bmWidth, - bm.bmHeight, - SRCCOPY); - } - else - { - BitBlt( - hdc, - RANDOM (0, rect.right - bm.bmWidth), - RANDOM (0, rect.bottom - bm.bmHeight), - bm.bmWidth, - bm.bmHeight, - hdcMem, - 0, - 0, - SRCCOPY); - } - - SelectObject(hdcMem, hbmOld); - DeleteDC(hdcMem); - - EndPaint(hWnd, &ps); - break; + BITMAP bm; + PAINTSTRUCT ps; + HDC hdc; + HDC hdcMem; + HBITMAP hbmOld; + RECT rect; + + hdc = BeginPaint(hWnd, &ps); + hdcMem = CreateCompatibleDC(hdc); + hbmOld = SelectObject(hdcMem, bitmap); + GetObjectW(bitmap, sizeof(bm), &bm); + + GetClientRect(hWnd, &rect); + if (rect.right < bm.bmWidth || rect.bottom < bm.bmHeight) + { + StretchBlt(hdc, RANDOM(0, rect.right - (bm.bmWidth / 5)), + RANDOM(0, rect.bottom - (bm.bmHeight / 5)), + bm.bmWidth / 5, bm.bmHeight / 5, hdcMem, 0, 0, + bm.bmWidth, bm.bmHeight, SRCCOPY); + } + else + { + BitBlt(hdc, RANDOM(0, rect.right - bm.bmWidth), + RANDOM(0, rect.bottom - bm.bmHeight), + bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY); + } + + SelectObject(hdcMem, hbmOld); + DeleteDC(hdcMem); + EndPaint(hWnd, &ps); + break; } case WM_TIMER: { - InvalidateRect(hWnd, NULL, 1); - break; + InvalidateRect(hWnd, NULL, TRUE); + break; } case WM_DESTROY: { @@ -147,10 +115,11 @@ ScreenSaverProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) PostQuitMessage(0); break; } - default: - // Pass Windows Messages to the default screensaver window procedure - return DefScreenSaverProc(hWnd, message, wParam, lParam); + { + /* Pass window messages to the default screensaver window procedure */ + return DefScreenSaverProc(hWnd, uMsg, wParam, lParam); + } } return 0; @@ -163,19 +132,20 @@ ScreenSaverConfigureDialog(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) return FALSE; } -// This function is only called one time before opening the configuration dialog. -// Use it to show a message that no configuration is necessary and return FALSE to indicate that no configuration dialog shall be opened. +/* This function is only called once before opening the configuration dialog. + * Use it to show a message that no configuration is necessary and return FALSE to indicate that no configuration dialog shall be opened. + */ BOOL WINAPI RegisterDialogClasses(HANDLE hInst) { - TCHAR szMessage[256]; - TCHAR szTitle[25]; + WCHAR szMessage[256]; + WCHAR szTitle[25]; - LoadString(hInst, IDS_TEXT, szMessage, sizeof(szMessage) / sizeof(TCHAR)); - LoadString(hInst, IDS_DESCRIPTION, szTitle, sizeof(szTitle) / sizeof(TCHAR)); + LoadStringW(hInst, IDS_TEXT, szMessage, _countof(szMessage)); + LoadStringW(hInst, IDS_DESCRIPTION, szTitle, _countof(szTitle)); - MessageBox(NULL, szMessage, szTitle, MB_OK | MB_ICONEXCLAMATION); + MessageBoxW(NULL, szMessage, szTitle, MB_OK | MB_ICONEXCLAMATION); return FALSE; } diff --git a/base/applications/screensavers/logon/logon.rc b/base/applications/screensavers/logon/logon.rc index 329adc901a1..710bb93ec0a 100644 --- a/base/applications/screensavers/logon/logon.rc +++ b/base/applications/screensavers/logon/logon.rc @@ -15,8 +15,11 @@ IDI_ICON ICON DISCARDABLE "res/icon_logon.ico" #include <reactos/version.rc> +/* To change the bitmap used for Workstation or Server + * versions, add the new bitmap and update the path below. + */ IDB_WORKSTATION BITMAP "res/0.bmp" -IDB_SERVER BITMAP "res/1.bmp" +IDB_SERVER BITMAP "res/0.bmp" #include <reactos/manifest_exe.rc> diff --git a/base/applications/screensavers/logon/res/0.bmp b/base/applications/screensavers/logon/res/0.bmp index 3f99e1d56ea..d692ced1ca5 100644 Binary files a/base/applications/screensavers/logon/res/0.bmp and b/base/applications/screensavers/logon/res/0.bmp differ diff --git a/base/applications/screensavers/logon/res/1.bmp b/base/applications/screensavers/logon/res/1.bmp deleted file mode 100644 index 3f99e1d56ea..00000000000 Binary files a/base/applications/screensavers/logon/res/1.bmp and /dev/null differ