- Write the desktop version string using user-defined font (the same as the one used for window caption titles).
- Reorganize a bit the code of IntPaintDesktop.

svn path=/trunk/; revision=71455
This commit is contained in:
Hermès Bélusca-Maïto 2016-05-29 13:18:05 +00:00
parent a8ebfc7774
commit 411cee2f02

View file

@ -246,30 +246,40 @@ InitDesktopImpl(VOID)
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
static int GetSystemVersionString(LPWSTR buffer) static INT GetSystemVersionString(PWSTR* buffer)
{ {
int len; static WCHAR wszVersion[256] = L"";
#if 0 // Disabled until versioning in win32k gets correctly implemented (hbelusca). int len = 0;
RTL_OSVERSIONINFOEXW versionInfo;
versionInfo.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW); if (!*wszVersion)
{
#if 0 // Disabled until versioning in win32k gets correctly implemented (hbelusca, r66750).
RTL_OSVERSIONINFOEXW versionInfo;
if (!NT_SUCCESS(RtlGetVersion((PRTL_OSVERSIONINFOW)&versionInfo))) versionInfo.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
return 0;
if (versionInfo.dwMajorVersion <= 4) if (!NT_SUCCESS(RtlGetVersion((PRTL_OSVERSIONINFOW)&versionInfo)))
len = swprintf(buffer, return 0;
L"ReactOS Version %lu.%lu %s Build %lu",
versionInfo.dwMajorVersion, versionInfo.dwMinorVersion, if (versionInfo.dwMajorVersion <= 4)
versionInfo.szCSDVersion, versionInfo.dwBuildNumber & 0xFFFF); len = swprintf(wszVersion,
else L"ReactOS Version %lu.%lu %s Build %lu",
len = swprintf(buffer, versionInfo.dwMajorVersion, versionInfo.dwMinorVersion,
L"ReactOS %s (Build %lu)", versionInfo.szCSDVersion, versionInfo.dwBuildNumber & 0xFFFF);
versionInfo.szCSDVersion, versionInfo.dwBuildNumber & 0xFFFF); else
len = swprintf(wszVersion,
L"ReactOS %s (Build %lu)",
versionInfo.szCSDVersion, versionInfo.dwBuildNumber & 0xFFFF);
#else #else
len = swprintf(buffer, L"ReactOS Version %S %S", KERNEL_VERSION_STR, KERNEL_VERSION_BUILD_STR); len = swprintf(wszVersion, L"ReactOS Version %S %S", KERNEL_VERSION_STR, KERNEL_VERSION_BUILD_STR);
#endif #endif
}
else
{
len = wcslen(wszVersion);
}
*buffer = wszVersion;
return len; return len;
} }
@ -1006,16 +1016,14 @@ IntFreeDesktopHeap(IN OUT PDESKTOP Desktop)
BOOL FASTCALL BOOL FASTCALL
IntPaintDesktop(HDC hDC) IntPaintDesktop(HDC hDC)
{ {
static WCHAR s_wszSafeMode[] = L"Safe Mode"; // FIXME: Localize!
RECTL Rect; RECTL Rect;
HBRUSH DesktopBrush, PreviousBrush; HBRUSH DesktopBrush, PreviousBrush;
HWND hWndDesktop; HWND hWndDesktop;
BOOL doPatBlt = TRUE; BOOL doPatBlt = TRUE;
PWND WndDesktop; PWND WndDesktop;
static WCHAR s_wszSafeMode[] = L"Safe Mode"; BOOLEAN InSafeMode;
int len;
COLORREF color_old;
UINT align_old;
int mode_old;
if (GdiGetClipBox(hDC, &Rect) == ERROR) if (GdiGetClipBox(hDC, &Rect) == ERROR)
return FALSE; return FALSE;
@ -1026,7 +1034,10 @@ IntPaintDesktop(HDC hDC)
if (!WndDesktop) if (!WndDesktop)
return FALSE; return FALSE;
if (!UserGetSystemMetrics(SM_CLEANBOOT)) /* Retrieve the current SafeMode state */
InSafeMode = (UserGetSystemMetrics(SM_CLEANBOOT) != 0);
if (!InSafeMode)
{ {
DesktopBrush = (HBRUSH)WndDesktop->pcls->hbrBackground; DesktopBrush = (HBRUSH)WndDesktop->pcls->hbrBackground;
@ -1149,60 +1160,75 @@ IntPaintDesktop(HDC hDC)
/* /*
* Display the system version on the desktop background * Display the system version on the desktop background
*/ */
if (g_PaintDesktopVersion || InSafeMode)
if (g_PaintDesktopVersion || UserGetSystemMetrics(SM_CLEANBOOT))
{ {
static WCHAR s_wszVersion[256] = {0}; PWSTR pwszVersion;
RECTL rect; INT len;
NONCLIENTMETRICSW ncm;
HFONT hFont = NULL, hOldFont = NULL; // TODO: Cache it??
RECTL rect; // FIXME: Use 'Rect' instead of defining yet another var!
COLORREF color_old;
UINT align_old;
int mode_old;
if (*s_wszVersion) if (!UserSystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0))
{ {
len = wcslen(s_wszVersion); rect.right = UserGetSystemMetrics(SM_CXSCREEN);
} rect.bottom = UserGetSystemMetrics(SM_CYSCREEN);
else
{
len = GetSystemVersionString(s_wszVersion);
} }
/* Set up the font (use default otherwise) */
ncm.cbSize = sizeof(ncm);
if (UserSystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0))
{
hFont = GreCreateFontIndirectW(&ncm.lfCaptionFont);
if (hFont)
hOldFont = NtGdiSelectFont(hDC, hFont);
}
color_old = IntGdiSetTextColor(hDC, RGB(255,255,255));
align_old = IntGdiSetTextAlign(hDC, TA_RIGHT);
mode_old = IntGdiSetBkMode(hDC, TRANSPARENT);
/* Display the system version information */
// FIXME: We need different strings for Safe Mode and regular mode.
len = GetSystemVersionString(&pwszVersion); // , InSafeMode);
if (len) if (len)
{ {
if (!UserSystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0)) if (!InSafeMode)
{ {
rect.right = UserGetSystemMetrics(SM_CXSCREEN); GreExtTextOutW(hDC, rect.right - 16, rect.bottom - 48, 0, NULL, pwszVersion, len, NULL, 0);
rect.bottom = UserGetSystemMetrics(SM_CYSCREEN);
}
color_old = IntGdiSetTextColor(hDC, RGB(255,255,255));
align_old = IntGdiSetTextAlign(hDC, TA_RIGHT);
mode_old = IntGdiSetBkMode(hDC, TRANSPARENT);
if (!UserGetSystemMetrics(SM_CLEANBOOT))
{
GreExtTextOutW(hDC, rect.right - 16, rect.bottom - 48, 0, NULL, s_wszVersion, len, NULL, 0);
} }
else else
{ {
/* Safe Mode */ /* Safe Mode: version information text in top center */
/* Version information text in top center */
IntGdiSetTextAlign(hDC, TA_CENTER | TA_TOP); IntGdiSetTextAlign(hDC, TA_CENTER | TA_TOP);
GreExtTextOutW(hDC, (rect.right + rect.left)/2, rect.top + 3, 0, NULL, s_wszVersion, len, NULL, 0); GreExtTextOutW(hDC, (rect.right + rect.left)/2, rect.top + 3, 0, NULL, pwszVersion, len, NULL, 0);
/* Safe Mode text in corners */
len = wcslen(s_wszSafeMode);
IntGdiSetTextAlign(hDC, TA_LEFT | TA_TOP);
GreExtTextOutW(hDC, rect.left, rect.top + 3, 0, NULL, s_wszSafeMode, len, NULL, 0);
IntGdiSetTextAlign(hDC, TA_RIGHT | TA_TOP);
GreExtTextOutW(hDC, rect.right, rect.top + 3, 0, NULL, s_wszSafeMode, len, NULL, 0);
IntGdiSetTextAlign(hDC, TA_LEFT | TA_BASELINE);
GreExtTextOutW(hDC, rect.left, rect.bottom - 5, 0, NULL, s_wszSafeMode, len, NULL, 0);
IntGdiSetTextAlign(hDC, TA_RIGHT | TA_BASELINE);
GreExtTextOutW(hDC, rect.right, rect.bottom - 5, 0, NULL, s_wszSafeMode, len, NULL, 0);
} }
}
IntGdiSetBkMode(hDC, mode_old); if (InSafeMode)
IntGdiSetTextAlign(hDC, align_old); {
IntGdiSetTextColor(hDC, color_old); /* Print Safe Mode text in corners */
len = wcslen(s_wszSafeMode);
IntGdiSetTextAlign(hDC, TA_LEFT | TA_TOP);
GreExtTextOutW(hDC, rect.left, rect.top + 3, 0, NULL, s_wszSafeMode, len, NULL, 0);
IntGdiSetTextAlign(hDC, TA_RIGHT | TA_TOP);
GreExtTextOutW(hDC, rect.right, rect.top + 3, 0, NULL, s_wszSafeMode, len, NULL, 0);
IntGdiSetTextAlign(hDC, TA_LEFT | TA_BASELINE);
GreExtTextOutW(hDC, rect.left, rect.bottom - 5, 0, NULL, s_wszSafeMode, len, NULL, 0);
IntGdiSetTextAlign(hDC, TA_RIGHT | TA_BASELINE);
GreExtTextOutW(hDC, rect.right, rect.bottom - 5, 0, NULL, s_wszSafeMode, len, NULL, 0);
}
IntGdiSetBkMode(hDC, mode_old);
IntGdiSetTextAlign(hDC, align_old);
IntGdiSetTextColor(hDC, color_old);
if (hFont)
{
NtGdiSelectFont(hDC, hOldFont);
GreDeleteObject(hFont);
} }
} }