Author: hbelusca Date: Sun May 29 13:18:05 2016 New Revision: 71455
URL: http://svn.reactos.org/svn/reactos?rev=71455&view=rev Log: [WIN32K] - 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.
Modified: trunk/reactos/win32ss/user/ntuser/desktop.c
Modified: trunk/reactos/win32ss/user/ntuser/desktop.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/desktop... ============================================================================== --- trunk/reactos/win32ss/user/ntuser/desktop.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/desktop.c [iso-8859-1] Sun May 29 13:18:05 2016 @@ -246,30 +246,40 @@ return STATUS_SUCCESS; }
-static int GetSystemVersionString(LPWSTR buffer) -{ - int len; -#if 0 // Disabled until versioning in win32k gets correctly implemented (hbelusca). - RTL_OSVERSIONINFOEXW versionInfo; - - versionInfo.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW); - - if (!NT_SUCCESS(RtlGetVersion((PRTL_OSVERSIONINFOW)&versionInfo))) - return 0; - - if (versionInfo.dwMajorVersion <= 4) - len = swprintf(buffer, - L"ReactOS Version %lu.%lu %s Build %lu", - versionInfo.dwMajorVersion, versionInfo.dwMinorVersion, - versionInfo.szCSDVersion, versionInfo.dwBuildNumber & 0xFFFF); +static INT GetSystemVersionString(PWSTR* buffer) +{ + static WCHAR wszVersion[256] = L""; + int len = 0; + + if (!*wszVersion) + { +#if 0 // Disabled until versioning in win32k gets correctly implemented (hbelusca, r66750). + RTL_OSVERSIONINFOEXW versionInfo; + + versionInfo.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW); + + if (!NT_SUCCESS(RtlGetVersion((PRTL_OSVERSIONINFOW)&versionInfo))) + return 0; + + if (versionInfo.dwMajorVersion <= 4) + len = swprintf(wszVersion, + L"ReactOS Version %lu.%lu %s Build %lu", + versionInfo.dwMajorVersion, versionInfo.dwMinorVersion, + versionInfo.szCSDVersion, versionInfo.dwBuildNumber & 0xFFFF); + else + len = swprintf(wszVersion, + L"ReactOS %s (Build %lu)", + versionInfo.szCSDVersion, versionInfo.dwBuildNumber & 0xFFFF); +#else + len = swprintf(wszVersion, L"ReactOS Version %S %S", KERNEL_VERSION_STR, KERNEL_VERSION_BUILD_STR); +#endif + } else - len = swprintf(buffer, - L"ReactOS %s (Build %lu)", - versionInfo.szCSDVersion, versionInfo.dwBuildNumber & 0xFFFF); -#else - len = swprintf(buffer, L"ReactOS Version %S %S", KERNEL_VERSION_STR, KERNEL_VERSION_BUILD_STR); -#endif - + { + len = wcslen(wszVersion); + } + + *buffer = wszVersion; return len; }
@@ -1006,16 +1016,14 @@ BOOL FASTCALL IntPaintDesktop(HDC hDC) { + static WCHAR s_wszSafeMode[] = L"Safe Mode"; // FIXME: Localize! + RECTL Rect; HBRUSH DesktopBrush, PreviousBrush; HWND hWndDesktop; BOOL doPatBlt = TRUE; PWND WndDesktop; - static WCHAR s_wszSafeMode[] = L"Safe Mode"; - int len; - COLORREF color_old; - UINT align_old; - int mode_old; + BOOLEAN InSafeMode;
if (GdiGetClipBox(hDC, &Rect) == ERROR) return FALSE; @@ -1026,7 +1034,10 @@ if (!WndDesktop) return FALSE;
- if (!UserGetSystemMetrics(SM_CLEANBOOT)) + /* Retrieve the current SafeMode state */ + InSafeMode = (UserGetSystemMetrics(SM_CLEANBOOT) != 0); + + if (!InSafeMode) { DesktopBrush = (HBRUSH)WndDesktop->pcls->hbrBackground;
@@ -1149,60 +1160,75 @@ /* * Display the system version on the desktop background */ - - if (g_PaintDesktopVersion || UserGetSystemMetrics(SM_CLEANBOOT)) - { - static WCHAR s_wszVersion[256] = {0}; - RECTL rect; - - if (*s_wszVersion) - { - len = wcslen(s_wszVersion); - } - else - { - len = GetSystemVersionString(s_wszVersion); - } - + if (g_PaintDesktopVersion || InSafeMode) + { + PWSTR pwszVersion; + 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 (!UserSystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0)) + { + rect.right = UserGetSystemMetrics(SM_CXSCREEN); + rect.bottom = UserGetSystemMetrics(SM_CYSCREEN); + } + + /* 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 (!UserSystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0)) + if (!InSafeMode) { - rect.right = UserGetSystemMetrics(SM_CXSCREEN); - 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); + GreExtTextOutW(hDC, rect.right - 16, rect.bottom - 48, 0, NULL, pwszVersion, len, NULL, 0); } else { - /* Safe Mode */ - - /* Version information text in top center */ + /* Safe Mode: version information text in top center */ IntGdiSetTextAlign(hDC, TA_CENTER | TA_TOP); - GreExtTextOutW(hDC, (rect.right + rect.left)/2, rect.top + 3, 0, NULL, s_wszVersion, 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); + GreExtTextOutW(hDC, (rect.right + rect.left)/2, rect.top + 3, 0, NULL, pwszVersion, len, NULL, 0); } - - IntGdiSetBkMode(hDC, mode_old); - IntGdiSetTextAlign(hDC, align_old); - IntGdiSetTextColor(hDC, color_old); + } + + if (InSafeMode) + { + /* 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); } }