00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
#include "precomp.h"
00013
#pragma hdrstop
00014
00015
00016
00017
00018 #define MAXPAL 256
00019 #define MAXSTATIC 20
00020 #define TILE_XMINSIZE 2
00021 #define TILE_YMINSIZE 4
00022
00023
void xxxInvalidateDesktopOnPaletteChange(
PWND pwnd);
00024
00025 __inline
void
00026 SetBestStretchMode(HDC hdc, UINT bpp, BOOL fHT)
00027 {
00028 GreSetStretchBltMode(
00029 hdc,
00030 ((fHT) ?
00031 HALFTONE :
00032 ((bpp == 1) ? BLACKONWHITE : COLORONCOLOR)));
00033 }
00034
00035
00036
00037
00038
00039 #define MAXTXTBUFFER 80
00040 #define MAXVERSIONBUFFER 300 // Max size of buffer (contains all 3 strings).
00041 #define MAXVERSIONSTRING 100 // Size of each string buffer.
00042 #define OFFSET_BLDSTRING 0 // Offset into verbuffer of build-string.
00043 #define OFFSET_TYPSTRING 100 // Offset into verbuffer of type string.
00044 #define OFFSET_CSDSTRING 200 // Offset into verbuffer of CSD string.
00045
00046 WCHAR
wszT[
MAXTXTBUFFER];
00047 WCHAR
SafeModeStr[64];
00048 int SafeModeStrLen;
00049
00050
00051
00052
00053 WCHAR
wszProductName[
MAXTXTBUFFER];
00054 WCHAR
wszProductBuild[
MAXTXTBUFFER];
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
VOID
00067 GetVersionInfo(
00068 BOOL Verbose
00069 )
00070 {
00071 WCHAR NameBuffer[
MAXVERSIONBUFFER];
00072 WCHAR Title1[128];
00073 WCHAR Title2[128];
00074 WCHAR wszPID[
MAXVERSIONSTRING];
00075 WCHAR wszPro[
MAXVERSIONSTRING];
00076 WCHAR wszSrv[
MAXVERSIONSTRING];
00077 WCHAR wszPBuild[
MAXVERSIONSTRING];
00078 WCHAR wszEvaluation[
MAXVERSIONSTRING];
00079 UNICODE_STRING UserBuildString;
00080 UNICODE_STRING UserTypeString;
00081 UNICODE_STRING UserCSDString;
00082
NTSTATUS Status;
00083
00084
00085 RTL_QUERY_REGISTRY_TABLE BaseServerRegistryConfigurationTable[] = {
00086
00087 {
NULL,
00088 RTL_QUERY_REGISTRY_DIRECT,
00089
L"CurrentBuildNumber",
00090 &UserBuildString,
00091 REG_NONE,
00092
NULL,
00093 0},
00094
00095 {
NULL,
00096 RTL_QUERY_REGISTRY_DIRECT,
00097
L"CurrentType",
00098 &UserTypeString,
00099 REG_NONE,
00100
NULL,
00101 0},
00102
00103 {
NULL,
00104 RTL_QUERY_REGISTRY_DIRECT,
00105
L"CSDVersion",
00106 &UserCSDString,
00107 REG_NONE,
00108
NULL,
00109 0},
00110
00111 {
NULL,
00112 0,
00113
NULL,
00114
NULL,
00115 REG_NONE,
00116
NULL,
00117 0}
00118 };
00119
00120 UserBuildString.Buffer = &NameBuffer[
OFFSET_BLDSTRING];
00121 UserBuildString.Length = 0;
00122 UserBuildString.MaximumLength =
MAXVERSIONSTRING *
sizeof(WCHAR);
00123
00124 UserTypeString.Buffer = &NameBuffer[
OFFSET_TYPSTRING];
00125 UserTypeString.Length = 0;
00126 UserTypeString.MaximumLength =
MAXVERSIONSTRING *
sizeof(WCHAR);
00127
00128 UserCSDString.Buffer = &NameBuffer[
OFFSET_CSDSTRING];
00129 UserCSDString.Length = 0;
00130 UserCSDString.MaximumLength =
MAXVERSIONSTRING *
sizeof(WCHAR);
00131
00132
Status =
RtlQueryRegistryValues(RTL_REGISTRY_WINDOWS_NT,
00133
L"",
00134 BaseServerRegistryConfigurationTable,
00135
NULL,
00136
NULL);
00137
00138
if (!
NT_SUCCESS(
Status)) {
00139 RIPMSG1(RIP_WARNING,
"GetVersionInfo failed with status %x",
Status);
00140
return;
00141 }
00142
00143
ServerLoadString(
hModuleWin, STR_DTBS_PRODUCTID, wszPID,
ARRAY_SIZE(wszPID) );
00144
ServerLoadString(
hModuleWin, STR_DTBS_PRODUCTPRO, wszPro,
ARRAY_SIZE(wszPro) );
00145
ServerLoadString(
hModuleWin, STR_DTBS_PRODUCTSRV, wszSrv,
ARRAY_SIZE(wszSrv) );
00146
ServerLoadString(
hModuleWin, STR_DTBS_PRODUCTBUILD, wszPBuild,
ARRAY_SIZE(wszPBuild) );
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156 swprintf(
00157
wszProductName,
00158 wszPID,
00159 ((USER_SHARED_DATA->NtProductType == NtProductWinNt) ? wszPro : wszSrv)
00160 );
00161
00162
00163
if (
gfUnsignedDrivers) {
00164
00165
ServerLoadString(
hModuleWin, STR_TESTINGONLY, wszEvaluation,
ARRAY_SIZE(wszEvaluation) );
00166 }
else if (USER_SHARED_DATA->SystemExpirationDate.QuadPart) {
00167
ServerLoadString(
hModuleWin, STR_DTBS_EVALUATION, wszEvaluation,
00168
ARRAY_SIZE(wszEvaluation));
00169 }
else {
00170 wszEvaluation[0] =
'\0';
00171 }
00172
00173 swprintf(
00174
wszProductBuild,
00175 wszPBuild,
00176 wszEvaluation,
00177 UserBuildString.Buffer
00178 );
00179
00180
if (Verbose) {
00181
00182
ServerLoadString(
hModuleWin, STR_SAFEMODE_TITLE1, Title1,
ARRAY_SIZE(Title1) );
00183
ServerLoadString(
hModuleWin, STR_SAFEMODE_TITLE2, Title2,
ARRAY_SIZE(Title2) );
00184
00185 swprintf(
00186
wszT,
00187 UserCSDString.Length == 0 ? Title1 : Title2,
00188 UserBuildString.Buffer,
00189 UserCSDString.Buffer,
00190 USER_SHARED_DATA->NtSystemRoot
00191 );
00192
00193 }
else {
00194 PWSTR s = wcsrchr( UserTypeString.Buffer,
L' ' );
00195
if (s) {
00196 s += 1;
00197 }
else {
00198 s = UserTypeString.Buffer;
00199 }
00200
00201
ServerLoadString(
hModuleWin, STR_SAFEMODE_TITLE3, Title1,
ARRAY_SIZE(Title1) );
00202
ServerLoadString(
hModuleWin, STR_SAFEMODE_TITLE4, Title2,
ARRAY_SIZE(Title2) );
00203
00204 swprintf(
00205
wszT,
00206 UserCSDString.Length == 0 ? Title1 : Title2,
00207 UserBuildString.Buffer,
00208 UserCSDString.Buffer,
00209 s
00210 );
00211 }
00212 }
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223 VOID GetDefaultWallpaperName(
00224 LPWSTR lpszWallpaper
00225 )
00226 {
00227
00228
00229
00230
00231
00232
00233
00234
if (USER_SHARED_DATA->NtProductType == NtProductWinNt) {
00235
wcsncpycch(lpszWallpaper,
L"winnt", 8);
00236 }
else {
00237
wcsncpycch(lpszWallpaper,
L"lanmannt", 8);
00238 }
00239
00240 lpszWallpaper[8] = (WCHAR)0;
00241
00242
if (
gpsi->BitsPixel *
gpsi->Planes > 4) {
00243
int iStart = wcslen(lpszWallpaper);
00244 iStart =
min(iStart, 5);
00245
00246 lpszWallpaper[iStart] = (WCHAR)0;
00247 wcscat(lpszWallpaper,
L"256");
00248 }
00249
00250
return;
00251 }
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261 #define GDWPN_KEYSIZE 40
00262 #define GDWPN_BITSIZE 256
00263
00264 LPWSTR
GetDeskWallpaperName(PUNICODE_STRING pProfileUserName,
00265 LPWSTR lpszFile
00266 )
00267 {
00268 WCHAR wszKey[
GDWPN_KEYSIZE];
00269 WCHAR wszNone[
GDWPN_KEYSIZE];
00270 LPWSTR lpszBitmap =
NULL;
00271
00272
00273
00274
00275
ServerLoadString(
hModuleWin, STR_NONE, wszNone,
ARRAY_SIZE(wszNone));
00276
00277
if ((lpszFile ==
NULL) ||
00278 (lpszFile == SETWALLPAPER_DEFAULT) ||
00279 (lpszFile == SETWALLPAPER_METRICS)) {
00280
00281
00282
00283
00284
00285 lpszBitmap = UserAllocPool(
GDWPN_BITSIZE *
sizeof(WCHAR), TAG_SYSTEM);
00286
if (lpszBitmap ==
NULL)
00287
return NULL;
00288
00289
00290
00291
00292
00293
00294
if (!
FastGetProfileStringFromIDW(pProfileUserName,
00295
PMAP_DESKTOP,
00296 STR_DTBITMAP,
00297 wszNone,
00298 lpszBitmap,
00299
GDWPN_BITSIZE
00300 )) {
00301 wcscpy(lpszBitmap, wszNone);
00302 }
00303
00304 }
else {
00305
00306
UINT uLen;
00307
00308 uLen = wcslen(lpszFile) + 1;
00309 uLen =
max(uLen,
GDWPN_BITSIZE);
00310
00311
00312
00313
00314
00315
00316 lpszBitmap = UserAllocPool(uLen *
sizeof(WCHAR), TAG_SYSTEM);
00317
if (lpszBitmap ==
NULL)
00318
return NULL;
00319
00320 wcscpy(lpszBitmap, lpszFile);
00321 }
00322
00323
00324
00325
00326
00327
if ((*lpszBitmap == (WCHAR)0) || (_wcsicmp(lpszBitmap, wszNone) == 0)) {
00328 UserFreePool(lpszBitmap);
00329
return NULL;
00330 }
00331
00332
00333
00334
00335
ServerLoadString(
hModuleWin, STR_DEFAULT, wszKey,
ARRAY_SIZE(wszKey));
00336
00337
if (_wcsicmp(lpszBitmap, wszKey) == 0) {
00338
GetDefaultWallpaperName(lpszBitmap);
00339 }
00340
00341
00342
return lpszBitmap;
00343 }
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354 BOOL TestVGAColors(
00355 LPLOGPALETTE ppal)
00356 {
00357
int i;
00358
int n;
00359
int size;
00360 COLORREF clr;
00361
00362
static CONST
DWORD StupidColors[] = {
00363 0x00000000,
00364 0x00000080,
00365 0x00008000,
00366 0x00008080,
00367 0x00800000,
00368 0x00800080,
00369 0x00808000,
00370 0x00c0c0c0,
00371 0x00808080,
00372 0x000000ff,
00373 0x0000ff00,
00374 0x0000ffff,
00375 0x00ff0000,
00376 0x00ff00ff,
00377 0x00ffff00,
00378 0x00ffffff,
00379
00380 0x000000BF,
00381 0x0000BF00,
00382 0x0000BFBF,
00383 0x00BF0000,
00384 0x00BF00BF,
00385 0x00BFBF00,
00386
00387 0x000000C0,
00388 0x0000C000,
00389 0x0000C0C0,
00390 0x00C00000,
00391 0x00C000C0,
00392 0x00C0C000,
00393 };
00394
00395 size = (
sizeof(StupidColors) /
sizeof(StupidColors[0]));
00396
00397
for (i = 0; i < (
int)ppal->palNumEntries; i++) {
00398
00399 clr = ((LPDWORD)ppal->palPalEntry)[i];
00400
00401
for (
n = 0;
n < size;
n++) {
00402
00403
if (StupidColors[
n] == clr)
00404
break;
00405 }
00406
00407
if (
n == size)
00408
return FALSE;
00409 }
00410
00411
return TRUE;
00412 }
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428 #define FIXED_GAMMA (WORD)13000
00429
00430 VOID DoHTColorAdjust(
00431 HDC hdc)
00432 {
00433 COLORADJUSTMENT ca;
00434
00435
00436
if (GreGetColorAdjustment(hdc, &ca)) {
00437
00438 ca.caRedGamma =
00439 ca.caGreenGamma =
00440 ca.caBlueGamma =
FIXED_GAMMA;
00441
00442 GreSetColorAdjustment(hdc, &ca);
00443 }
00444
00445
return;
00446 }
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463 HBITMAP
ConvertToDDB(
00464 HDC hdc,
00465 HBITMAP hbmOld,
00466 HPALETTE hpal)
00467 {
00468 BITMAP bm;
00469 HBITMAP hbmNew;
00470
00471
00472
00473
00474 GreExtGetObjectW(hbmOld,
sizeof(bm), &bm);
00475
00476
00477
00478
00479
if (hbmNew = GreCreateCompatibleBitmap(hdc, bm.bmWidth, bm.bmHeight)) {
00480
00481 HPALETTE hpalDst;
00482 HPALETTE hpalSrc;
00483 HBITMAP hbmDst;
00484 HBITMAP hbmSrc;
00485
UINT bpp;
00486
BOOL fHalftone =
FALSE;
00487
00488
00489
00490
00491 hbmDst = GreSelectBitmap(
ghdcMem2, hbmNew);
00492 hbmSrc = GreSelectBitmap(
ghdcMem, hbmOld);
00493
00494
00495
00496
00497 bpp = (bm.bmPlanes * bm.bmBitsPixel);
00498
00499
00500
00501
00502
00503
00504
if (hpal) {
00505
00506 hpalDst =
_SelectPalette(
ghdcMem2, hpal,
FALSE);
00507 hpalSrc =
_SelectPalette(
ghdcMem, hpal,
FALSE);
00508
00509
xxxRealizePalette(
ghdcMem2);
00510
00511
00512
00513
00514
00515
if (bpp >
gpsi->BitCount) {
00516 fHalftone =
TRUE;
00517
DoHTColorAdjust(
ghdcMem2);
00518 }
00519 }
00520
00521
00522
00523
00524
00525
00526
SetBestStretchMode(
ghdcMem2, bpp, fHalftone);
00527
00528
00529
00530
00531
00532 GreStretchBlt(
ghdcMem2,
00533 0,
00534 0,
00535 bm.bmWidth,
00536 bm.bmHeight,
00537
ghdcMem,
00538 0,
00539 0,
00540 bm.bmWidth,
00541 bm.bmHeight,
00542 SRCCOPY,
00543 0);
00544
00545
00546
00547
00548
if (hpal) {
00549
_SelectPalette(
ghdcMem2, hpalDst,
FALSE);
00550
_SelectPalette(
ghdcMem, hpalSrc,
FALSE);
00551 }
00552
00553
00554
00555
00556 GreSelectBitmap(
ghdcMem2, hbmDst);
00557 GreSelectBitmap(
ghdcMem, hbmSrc);
00558 GreDeleteObject(hbmOld);
00559
00560 GreSetBitmapOwner(hbmNew, OBJECT_OWNER_PUBLIC);
00561
00562 }
else {
00563 hbmNew = hbmOld;
00564 }
00565
00566
return hbmNew;
00567 }
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581 HPALETTE
CreatePaletteFromBitmap(
00582 HBITMAP hbm)
00583 {
00584 HPALETTE hpal;
00585 LPLOGPALETTE ppal;
00586 HBITMAP hbmT;
00587
DWORD size;
00588
int i;
00589
00590
00591
00592
00593 size =
sizeof(LOGPALETTE) + (
MAXPAL *
sizeof(PALETTEENTRY));
00594
00595 ppal = (LPLOGPALETTE)UserAllocPool(size, TAG_SYSTEM);
00596
if (!ppal)
00597
return NULL;
00598
00599
00600
00601
00602
00603 hbmT = GreSelectBitmap(
ghdcMem, hbm);
00604 ppal->palVersion = 0x300;
00605 ppal->palNumEntries = (WORD)GreGetDIBColorTable(
ghdcMem,
00606 0,
00607
MAXPAL,
00608 (LPRGBQUAD)ppal->palPalEntry);
00609 GreSelectBitmap(
ghdcMem, hbmT);
00610
00611
00612
00613
00614
00615
00616
if (ppal->palNumEntries == 0) {
00617 hpal = GreCreateHalftonePalette(
gpDispInfo->
hdcScreen);
00618 }
else {
00619
00620
BYTE tmpR;
00621
00622
00623
00624
00625
for (i=0; i < (
int)ppal->palNumEntries; i++) {
00626 tmpR = ppal->palPalEntry[i].peRed;
00627 ppal->palPalEntry[i].peRed = ppal->palPalEntry[i].peBlue;
00628 ppal->palPalEntry[i].peBlue = tmpR;
00629 ppal->palPalEntry[i].peFlags = 0;
00630 }
00631
00632
00633
00634
00635
00636 hpal =
TestVGAColors(ppal) ?
NULL : GreCreatePalette(ppal);
00637 }
00638
00639 UserFreePool(ppal);
00640
00641
00642
00643
00644
if (hpal)
00645 GreSetPaletteOwner(hpal, OBJECT_OWNER_PUBLIC);
00646
00647
return hpal;
00648 }
00649
00650
00651
00652
00653
00654
00655
00656
00657
BOOL
00658 TileWallpaper(HDC hdc, LPCRECT lprc, BOOL fOffset)
00659 {
00660
int xO;
00661
int yO;
00662
int x;
00663
int y;
00664 BITMAP bm;
00665 HBITMAP hbmT =
NULL;
00666 POINT ptOffset;
00667
00668
if (fOffset) {
00669 ptOffset.x =
gsrcWallpaper.
x;
00670 ptOffset.y =
gsrcWallpaper.
y;
00671 }
else {
00672 ptOffset.x = 0;
00673 ptOffset.y = 0;
00674 }
00675
00676
00677
00678
00679
00680
00681
00682
if (GreExtGetObjectW(
ghbmWallpaper,
sizeof(BITMAP), (PBITMAP)&bm)) {
00683 xO = lprc->left - (lprc->left % bm.bmWidth) + (ptOffset.x % bm.bmWidth);
00684
if (xO > lprc->left) {
00685 xO -= bm.bmWidth;
00686 }
00687
00688 yO = lprc->top - (lprc->top % bm.bmHeight) + (ptOffset.y % bm.bmHeight);
00689
if (yO > lprc->top) {
00690 yO -= bm.bmHeight;
00691 }
00692
00693
00694
00695
00696
if (hbmT = GreSelectBitmap(
ghdcMem,
ghbmWallpaper)) {
00697
for (y = yO; y < lprc->bottom; y += bm.bmHeight) {
00698
for (x = xO; x < lprc->right; x += bm.bmWidth) {
00699 GreBitBlt(hdc,
00700 x,
00701 y,
00702 bm.bmWidth,
00703 bm.bmHeight,
00704
ghdcMem,
00705 0,
00706 0,
00707 SRCCOPY,
00708 0);
00709 }
00710 }
00711
00712 GreSelectBitmap(
ghdcMem, hbmT);
00713 }
00714 }
00715
00716
return (hbmT !=
NULL);
00717 }
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
BOOL
00729 GetWallpaperCenterRect(LPRECT lprc, LPPOINT lppt, LPCRECT lprcMonitor)
00730 {
00731 RECT rc;
00732
00733
00734
if (
gsrcWallpaper.
x != 0 ||
gsrcWallpaper.
y != 0) {
00735 rc.left = lprcMonitor->left +
gsrcWallpaper.
x;
00736 rc.top = lprcMonitor->top +
gsrcWallpaper.
y;
00737 }
else {
00738 rc.left = (lprcMonitor->left + lprcMonitor->right -
gsrcWallpaper.
cx) / 2;
00739 rc.top = (lprcMonitor->top + lprcMonitor->bottom -
gsrcWallpaper.
cy) / 2;
00740 }
00741
00742 rc.right = rc.left +
gsrcWallpaper.
cx;
00743 rc.bottom = rc.top +
gsrcWallpaper.
cy;
00744
00745 lppt->x =
max(0, lprcMonitor->left - rc.left);
00746 lppt->y =
max(0, lprcMonitor->top - rc.top);
00747
00748
return IntersectRect(lprc, &rc, lprcMonitor);
00749 }
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
BOOL
00762 CenterWallpaper(HDC hdc, LPCRECT lprcMonitor)
00763 {
00764 RECT rc;
00765 HBITMAP hbmT;
00766
BOOL f =
TRUE;
00767 HRGN hrgn;
00768 POINT pt;
00769
00770
if (
GetWallpaperCenterRect(&rc, &pt, lprcMonitor)) {
00771
00772
00773
00774
00775
00776
00777
if (hbmT = GreSelectBitmap(
ghdcMem,
ghbmWallpaper)) {
00778
00779 GreBitBlt(hdc,
00780 rc.left,
00781 rc.top,
00782 rc.right - rc.left,
00783 rc.bottom - rc.top,
00784
ghdcMem,
00785 pt.x,
00786 pt.y,
00787 SRCCOPY,
00788 0);
00789
00790 GreSelectBitmap(
ghdcMem, hbmT);
00791 }
else {
00792 f =
FALSE;
00793 }
00794 }
00795
00796
00797
00798
00799
00800
if (hrgn =
CreateEmptyRgn()) {
00801
if (GreGetRandomRgn(hdc, hrgn, 1) != -1) {
00802 GreExcludeClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom);
00803
FillRect(hdc, lprcMonitor,
SYSHBR(
DESKTOP));
00804 GreExtSelectClipRgn(hdc, hrgn, RGN_COPY);
00805 }
else {
00806 f =
FALSE;
00807 }
00808
00809 GreDeleteObject(hrgn);
00810 }
else {
00811 f =
FALSE;
00812 }
00813
00814
return f;
00815 }
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829 BOOL xxxDrawWallpaper(
00830
PWND pwnd,
00831 HDC hdc,
00832
PMONITOR pMonitorPaint,
00833 LPCRECT lprc)
00834 {
00835
BOOL f;
00836 HPALETTE hpalT;
00837
int i;
00838
00839
CheckLock(pwnd);
00840
CheckLock(pMonitorPaint);
00841 UserAssert(
ghbmWallpaper !=
NULL);
00842 UserAssert(lprc);
00843
00844
00845
00846
00847
00848
if (
ghpalWallpaper &&
00849 pMonitorPaint->
dwMONFlags &
MONF_PALETTEDISPLAY) {
00850
00851 hpalT =
_SelectPalette(hdc,
ghpalWallpaper,
FALSE);
00852 i =
xxxRealizePalette(hdc);
00853 }
else {
00854 hpalT =
NULL;
00855 }
00856
00857
if (
gwWPStyle & DTF_TILE) {
00858 f =
TileWallpaper(hdc, lprc, pwnd !=
NULL);
00859 }
else {
00860 f =
CenterWallpaper(hdc, &pMonitorPaint->
rcMonitor);
00861 }
00862
00863
if (hpalT) {
00864
_SelectPalette(hdc, hpalT,
FALSE);
00865 }
00866
00867
return f;
00868 }
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880 HBITMAP
xxxExpandBitmap(
00881 HBITMAP hbm)
00882 {
00883
int nx;
00884
int ny;
00885 BITMAP bm;
00886 HBITMAP hbmNew;
00887 HBITMAP hbmD;
00888 LPRECT lprc;
00889 RECT rc;
00890
PMONITOR pMonitor;
00891
TL tlpMonitor;
00892
00893
00894
00895
00896
00897
00898
00899
00900 GreExtGetObjectW(hbm,
sizeof(bm), (PBITMAP)&bm);
00901
00902 pMonitor =
GetPrimaryMonitor();
00903 lprc = &pMonitor->
rcMonitor;
00904 nx = (lprc->right /
TILE_XMINSIZE) / bm.bmWidth;
00905 ny = (lprc->bottom /
TILE_YMINSIZE) / bm.bmHeight;
00906
00907
if (nx == 0)
00908 nx++;
00909
00910
if (ny == 0)
00911 ny++;
00912
00913
if ((nx + ny) <= 2)
00914
return hbm;
00915
00916
00917
00918
00919
00920 rc.left = rc.top = 0;
00921 rc.right = nx * bm.bmWidth;
00922 rc.bottom = ny * bm.bmHeight;
00923 hbmD = GreSelectBitmap(
ghdcMem, hbm);
00924 hbmNew = GreCreateCompatibleBitmap(
ghdcMem, rc.right, rc.bottom);
00925 GreSelectBitmap(
ghdcMem, hbmD);
00926
00927
if (hbmNew ==
NULL)
00928
return hbm;
00929
00930
if (hbmD = GreSelectBitmap(
ghdcMem2, hbmNew)) {
00931
00932
00933
00934
ThreadLockAlways(pMonitor, &tlpMonitor);
00935
xxxDrawWallpaper(
NULL,
ghdcMem2, pMonitor, &rc);
00936
ThreadUnlock(&tlpMonitor);
00937 GreSelectBitmap(
ghdcMem2, hbmD);
00938 }
00939
00940 GreDeleteObject(hbm);
00941
00942 GreSetBitmapOwner(hbmNew, OBJECT_OWNER_PUBLIC);
00943
00944
return hbmNew;
00945 }
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961 BOOL xxxLoadDesktopWallpaper(
00962 LPWSTR lpszFile)
00963 {
00964
UINT LR_flags;
00965
int dxDesired;
00966
int dyDesired;
00967 BITMAP bm;
00968 UNICODE_STRING strName;
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978 LR_flags = LR_LOADFROMFILE;
00979
00980
if (
gpDispInfo->
fAnyPalette ||
gpsi->BitCount >= 8) {
00981 LR_flags |= LR_CREATEREALDIB;
00982 }
00983
00984
00985
00986
00987
00988
00989
if (
gwWPStyle & DTF_STRETCH) {
00990
PMONITOR pMonitor;
00991
int dxMonitor, dyMonitor;
00992
00993 dxDesired = INT_MAX;
00994 dyDesired = INT_MAX;
00995
for ( pMonitor =
gpDispInfo->
pMonitorFirst;
00996 pMonitor;
00997 pMonitor = pMonitor->
pMonitorNext) {
00998
00999
if (!(pMonitor->
dwMONFlags &
MONF_VISIBLE))
01000
continue;
01001
01002 dxMonitor = pMonitor->
rcMonitor.right - pMonitor->
rcMonitor.left;
01003 dxDesired =
min(dxDesired, dxMonitor);
01004 dyMonitor = pMonitor->
rcMonitor.bottom - pMonitor->
rcMonitor.top;
01005 dyDesired =
min(dyDesired, dyMonitor);
01006 }
01007 }
else {
01008 dxDesired = dyDesired = 0;
01009 }
01010
01011
01012
01013
01014
01015
RtlInitUnicodeString(&strName, lpszFile);
01016
01017
ghbmWallpaper =
xxxClientLoadImage(
01018 &strName,
01019 0,
01020 IMAGE_BITMAP,
01021 dxDesired,
01022 dyDesired,
01023 LR_flags,
01024
TRUE);
01025
01026
if (
ghbmWallpaper ==
NULL)
01027
return FALSE;
01028
01029
01030
01031
01032
01033
if (
gpDispInfo->
fAnyPalette) {
01034
ghpalWallpaper =
CreatePaletteFromBitmap(
ghbmWallpaper);
01035 }
01036
01037
01038
01039
01040
01041
01042
01043 GreExtGetObjectW(
ghbmWallpaper,
sizeof(bm), &bm);
01044
01045
if (
gpDispInfo->
cMonitors == 1 &&
01046
gpsi->BitCount <= bm.bmPlanes * bm.bmBitsPixel) {
01047
01048
ghbmWallpaper =
ConvertToDDB(
01049
gpDispInfo->
hdcScreen,
01050
ghbmWallpaper,
01051
ghpalWallpaper);
01052 }
01053
01054
01055
01056
01057
01058
01059
01060 GreSetBitmapOwner(
ghbmWallpaper, OBJECT_OWNER_PUBLIC);
01061
01062
if (
gwWPStyle & DTF_TILE) {
01063
ghbmWallpaper =
xxxExpandBitmap(
ghbmWallpaper);
01064 }
01065
01066
return TRUE;
01067 }
01068
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079 BOOL xxxSetDeskWallpaper(PUNICODE_STRING pProfileUserName,
01080 LPWSTR lpszFile)
01081 {
01082 BITMAP bm;
01083
UINT WallpaperStyle2;
01084
PWND pwndShell;
01085
TL tl;
01086
PTHREADINFO ptiCurrent =
PtiCurrent();
01087
PDESKTOP pdesk;
01088
BOOL fRet =
FALSE;
01089 HBITMAP hbmOld;
01090
01091
PROFINTINFO apsi[] = {
01092 {
PMAP_DESKTOP, (LPWSTR)STR_TILEWALL , 0, &
gwWPStyle },
01093 {
PMAP_DESKTOP, (LPWSTR)STR_DTSTYLE , 0, &WallpaperStyle2 },
01094 {
PMAP_DESKTOP, (LPWSTR)STR_DTORIGINX, 0, &
gsrcWallpaper.
x },
01095 {
PMAP_DESKTOP, (LPWSTR)STR_DTORIGINY, 0, &
gsrcWallpaper.
y },
01096 {0,
NULL, 0,
NULL }
01097 };
01098
01099 pdesk = ptiCurrent->
rpdesk;
01100 hbmOld =
ghbmWallpaper;
01101
01102
01103
01104
01105
01106 pwndShell = (pdesk ? pdesk->
pDeskInfo->
spwndShell :
NULL);
01107
01108
if ((lpszFile == SETWALLPAPER_METRICS) && !(
gwWPStyle & DTF_STRETCH)) {
01109
01110
gsrcWallpaper.
x = 0;
01111
gsrcWallpaper.
y = 0;
01112
01113
if (
ghbmWallpaper)
01114
goto CreateNewWallpaper;
01115
01116
goto Metric_Change;
01117 }
01118
01119 CreateNewWallpaper:
01120
01121
01122
01123
01124
if (
ghpalWallpaper) {
01125 GreDeleteObject(
ghpalWallpaper);
01126
ghpalWallpaper =
NULL;
01127 }
01128
01129
if (
ghbmWallpaper) {
01130 GreDeleteObject(
ghbmWallpaper);
01131
ghbmWallpaper =
NULL;
01132 }
01133
01134
01135
01136
01137
01138
01139
01140
FreeAllSpbs();
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
if (lpszFile == SETWALLPAPER_METRICS) {
01156
01157 UserAssert(
gpszWall !=
NULL);
01158
01159
goto LoadWallpaper;
01160 }
01161
01162
01163
01164
01165
if (
gpszWall) {
01166 UserFreePool(
gpszWall);
01167
gpszWall =
NULL;
01168 }
01169
01170
01171
01172
01173
01174
01175
gpszWall =
GetDeskWallpaperName(pProfileUserName,lpszFile);
01176
if (!
gpszWall) {
01177 fRet =
TRUE;
01178
goto SDW_Exit;
01179 }
01180
01181
01182
01183
01184
01185
01186
01187
01188
FastGetProfileIntsW(pProfileUserName, apsi);
01189
01190
gwWPStyle &= DTF_TILE;
01191
if (!(
gwWPStyle & DTF_TILE)) {
01192
gwWPStyle = WallpaperStyle2 & DTF_STRETCH;
01193 }
01194
01195
01196
01197
01198
01199
01200 LoadWallpaper:
01201
01202
if (
xxxLoadDesktopWallpaper(
gpszWall) ==
FALSE) {
01203
gwWPStyle = 0;
01204
goto SDW_Exit;
01205 }
01206
01207
01208
01209
01210
01211
if (
ghpalWallpaper !=
NULL) {
01212
PWND pwndSend;
01213
01214
if (pwndShell) {
01215 pwndSend = pwndShell;
01216 }
else {
01217 pwndSend = (pdesk ? pdesk->
pDeskInfo->
spwnd :
NULL);
01218 }
01219
01220
01221
01222
01223
01224 GreRealizeDefaultPalette(
gpDispInfo->
hdcScreen,
TRUE);
01225
01226
01227
01228
01229
01230
01231
if (pwndSend) {
01232 HWND hwnd =
HW(pwndSend);
01233
01234
ThreadLockAlways(pwndSend, &tl);
01235
xxxSendNotifyMessage(pwndSend, WM_PALETTECHANGED, (WPARAM)hwnd, 0);
01236
ThreadUnlock(&tl);
01237 }
01238 }
01239
01240 Metric_Change:
01241
if (fRet = GreExtGetObjectW(
ghbmWallpaper,
sizeof(bm), (PBITMAP)&bm)) {
01242
gsrcWallpaper.
cx = bm.bmWidth;
01243
gsrcWallpaper.
cy = bm.bmHeight;
01244 }
01245
01246
01247 SDW_Exit:
01248
01249
01250
01251
01252
if ((pwndShell !=
NULL) &&
01253 ((hbmOld && !
ghbmWallpaper) || (!hbmOld &&
ghbmWallpaper))) {
01254
01255
ThreadLockAlways(pwndShell, &tl);
01256
xxxSendNotifyMessage(pwndShell,
01257 WM_SHELLNOTIFY,
01258 SHELLNOTIFY_WALLPAPERCHANGED,
01259 (LPARAM)
ghbmWallpaper);
01260
ThreadUnlock(&tl);
01261 }
01262
01263
return fRet;
01264 }
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275 void DesktopBuildPaint(
01276 HDC hdc,
01277
PMONITOR pMonitor)
01278 {
01279 SIZE size;
01280
int imode;
01281
int x;
01282
int y;
01283 COLORREF oldColor;
01284 RECT rcText1 = {0,0,0,0};
01285
01286 HFONT oldFont =
NULL;
01287
01288 PWCHAR pwszT =
wszProductName;
01289
01290
01291
01292
01293 imode = GreSetBkMode(hdc, TRANSPARENT);
01294
01295
if (GreGetBrushColor(
SYSHBR(BACKGROUND)) != 0x00ffffff) {
01296 oldColor = GreSetTextColor( hdc, RGB(255,255,255) );
01297 }
else {
01298 oldColor = GreSetTextColor( hdc, RGB(0,0,0) );
01299 }
01300
01301
01302
01303
01304
01305
if (
gpsi &&
gpsi->hCaptionFont) {
01306 oldFont = GreSelectFont(hdc,
gpsi->hCaptionFont);
01307 }
01308
01309
if (
gDrawVersionAlways) {
01310 pwszT = (wcslen(
wszProductName) > wcslen(USER_SHARED_DATA->NtSystemRoot))?
wszProductName:USER_SHARED_DATA->NtSystemRoot;
01311 }
01312
01313 GreGetTextExtentW(
01314 hdc,
01315 pwszT,
01316 wcslen(pwszT),
01317 &size,
01318 GGTE_WIN3_EXTENT);
01319
01320 x = pMonitor->
rcWork.right - size.cx - 5;
01321 y = pMonitor->
rcWork.bottom -
01322 ((
gDrawVersionAlways? 3: 2) * size.cy) - 5;
01323
01324 rcText1.top = y;
01325 rcText1.bottom = rcText1.top + size.cy;
01326 rcText1.left = x;
01327 rcText1.right = rcText1.left + size.cx;
01328
01329
GreSetTextAlign(hdc, TA_RIGHT | TA_BOTTOM);
01330
01331 GreExtTextOutW(
01332 hdc,
01333 rcText1.right,
01334 rcText1.bottom,
01335 0,
01336 &rcText1,
01337
wszProductName,
01338 wcslen(
wszProductName),
01339 (LPINT)
NULL
01340 );
01341
01342
01343
01344
01345
01346
if (oldFont !=
NULL &&
ghMenuFont !=
NULL ) {
01347 GreSelectFont(hdc,
ghMenuFont);
01348 }
01349
01350 rcText1.top = rcText1.bottom + 1;
01351 rcText1.bottom = rcText1.top + size.cy;
01352
01353 GreExtTextOutW(
01354 hdc,
01355 rcText1.right,
01356 rcText1.bottom,
01357 0,
01358 &rcText1,
01359
wszProductBuild,
01360 wcslen(
wszProductBuild),
01361 (LPINT)
NULL
01362 );
01363
01364
01365
01366
01367
if (
gDrawVersionAlways) {
01368 rcText1.top = rcText1.bottom + 1;
01369 rcText1.bottom = rcText1.top + size.cy;
01370
01371 GreExtTextOutW(
01372 hdc,
01373 rcText1.right,
01374 rcText1.bottom,
01375 0,
01376 &rcText1,
01377 USER_SHARED_DATA->NtSystemRoot,
01378 wcslen(USER_SHARED_DATA->NtSystemRoot),
01379 (LPINT)
NULL
01380 );
01381 }
01382
01383
if (oldFont) {
01384 GreSelectFont(hdc, oldFont);
01385 }
01386
01387 GreSetBkMode(hdc, imode);
01388 GreSetTextColor(hdc, oldColor);
01389 }
01390
01391
01392
01393
01394
01395
01396
01397
01398
01399
01400
01401
BOOL
01402 xxxDesktopPaintCallback(
01403
PMONITOR pMonitor,
01404 HDC hdc,
01405 LPRECT lprcMonitorClip,
01406 LPARAM dwData)
01407 {
01408
BOOL f;
01409
PWND pwnd;
01410
01411
CheckLock(pMonitor);
01412
01413 pwnd = (
PWND)dwData;
01414
01415
01416
if (**((PULONG *)&
InitSafeBootMode)) {
01417
FillRect(hdc, lprcMonitorClip,
ghbrBlack );
01418 f =
TRUE;
01419 }
else {
01420
01421
01422
01423
if (!
gbDesktopLocked) {
01424
01425
01426
01427
01428
if (
ghbmWallpaper) {
01429 f =
xxxDrawWallpaper(
01430 pwnd,
01431 hdc,
01432 pMonitor,
01433 lprcMonitorClip);
01434 }
else {
01435
FillRect(hdc, lprcMonitorClip,
SYSHBR(
DESKTOP));
01436 f =
TRUE;
01437 }
01438 }
01439 }
01440
01441
if (**((PULONG *)&
InitSafeBootMode)
01442 ||
gDrawVersionAlways
01443 ||
gdwCanPaintDesktop) {
01444
static BOOL fInit =
TRUE;
01445 SIZE size;
01446
int imode;
01447 COLORREF oldColor;
01448 HFONT oldFont =
NULL;
01449
01450
01451
01452
01453
01454
if (fInit) {
01455
if (**((PULONG *)&
InitSafeBootMode)) {
01456
ServerLoadString(
hModuleWin, STR_SAFEMODE,
SafeModeStr,
ARRAY_SIZE(
SafeModeStr) );
01457
SafeModeStrLen = wcslen(
SafeModeStr);
01458 }
01459
GetVersionInfo(**((PULONG *)&
InitSafeBootMode) == 0);
01460 fInit =
FALSE;
01461 }
01462
01463
if (**((PULONG *)&
InitSafeBootMode)) {
01464
if (
gpsi !=
NULL &&
gpsi->hCaptionFont !=
NULL) {
01465 oldFont = GreSelectFont(hdc,
gpsi->hCaptionFont);
01466 }
01467
01468 GreGetTextExtentW(hdc,
wszT, wcslen(
wszT), &size, GGTE_WIN3_EXTENT);
01469 imode = GreSetBkMode(hdc, TRANSPARENT);
01470
01471 oldColor = GreSetTextColor( hdc, RGB(255,255,255) );
01472
01473 GreExtTextOutW(
01474 hdc,
01475 (pMonitor->
rcWork.left + pMonitor->
rcWork.right - size.cx) / 2,
01476 pMonitor->
rcWork.top,
01477 0,
01478 (LPRECT)
NULL,
01479
wszT,
01480 wcslen(
wszT),
01481 (LPINT)
NULL
01482 );
01483
01484 GreGetTextExtentW(hdc,
SafeModeStr,
SafeModeStrLen, &size, GGTE_WIN3_EXTENT);
01485
01486 GreExtTextOutW(
01487 hdc,
01488 pMonitor->
rcWork.left,
01489 pMonitor->
rcWork.top,
01490 0,
01491 (LPRECT)
NULL,
01492
SafeModeStr,
01493
SafeModeStrLen,
01494 (LPINT)
NULL
01495 );
01496
01497 GreExtTextOutW(
01498 hdc,
01499 pMonitor->
rcWork.right - size.cx,
01500 pMonitor->
rcWork.top,
01501 0,
01502 (LPRECT)
NULL,
01503
SafeModeStr,
01504
SafeModeStrLen,
01505 (LPINT)
NULL
01506 );
01507
01508 GreExtTextOutW(
01509 hdc,
01510 pMonitor->
rcWork.right - size.cx,
01511 pMonitor->
rcWork.bottom -
gpsi->tmSysFont.tmHeight,
01512 0,
01513 (LPRECT)
NULL,
01514
SafeModeStr,
01515
SafeModeStrLen,
01516 (LPINT)
NULL
01517 );
01518
01519 GreExtTextOutW(
01520 hdc,
01521 pMonitor->
rcWork.left,
01522 pMonitor->
rcWork.bottom -
gpsi->tmSysFont.tmHeight,
01523 0,
01524 (LPRECT)
NULL,
01525
SafeModeStr,
01526
SafeModeStrLen,
01527 (LPINT)
NULL
01528 );
01529
01530 GreSetBkMode(hdc, imode);
01531 GreSetTextColor(hdc, oldColor);
01532
01533
if (oldFont) {
01534 GreSelectFont(hdc, oldFont);
01535 }
01536 }
else {
01537
DesktopBuildPaint(hdc, pMonitor);
01538 }
01539 }
01540
01541
return f;
01542 }
01543
01544
01545
01546
01547
01548
01549
01550
01551
01552
01553
01554
01555
01556
void
01557 xxxInvalidateDesktopOnPaletteChange(
PWND pwnd)
01558 {
01559
PDESKTOP pdesk;
01560
PWND pwndShell;
01561
TL tlpwndShell;
01562 RECT rc;
01563
BOOL fRedrawDesktop;
01564
01565
CheckLock(pwnd);
01566
01567
01568
01569
01570 pdesk =
PtiCurrent()->rpdesk;
01571 pwndShell = (pdesk) ? pdesk->
pDeskInfo->
spwndShell :
NULL;
01572
if (!pwndShell) {
01573 fRedrawDesktop =
TRUE;
01574 rc =
gpsi->rcScreen;
01575 }
else {
01576
ThreadLockAlways(pwndShell, &tlpwndShell);
01577
xxxRedrawWindow(
01578 pwndShell,
01579
NULL,
01580
NULL,
01581 RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN);
01582
01583
01584
01585
01586
01587
01588 fRedrawDesktop =
SubtractRect(&rc, &pwnd->
rcWindow, &pwndShell->
rcWindow);
01589
ThreadUnlock(&tlpwndShell);
01590 }
01591
01592
01593
01594
01595
if (fRedrawDesktop) {
01596
xxxRedrawWindow(
01597 pwnd,
01598 &rc,
01599
NULL,
01600 RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN);
01601 }
01602 }
01603
01604
01605
01606
01607
01608
01609
01610
01611
01612
01613
01614
01615 BOOL xxxInternalPaintDesktop(
01616
PWND pwnd,
01617 HDC hdc,
01618 BOOL fPaint)
01619 {
01620
BOOL fRet;
01621
01622
CheckLock(pwnd);
01623
01624
if (fPaint) {
01625 RECT rcOrg, rcT;
01626 POINT pt;
01627
01628
01629
01630
01631
01632
01633
01634 GreGetDCOrgEx(hdc, &pt, &rcOrg);
01635
CopyRect(&rcT, &rcOrg);
01636
OffsetRect(&rcT, -rcT.left, -rcT.top);
01637 GreSetDCOrg(hdc, rcT.left, rcT.top, (PRECTL)&rcT);
01638
01639 fRet =
xxxEnumDisplayMonitors(
01640 hdc,
01641
NULL,
01642 (MONITORENUMPROC)
xxxDesktopPaintCallback,
01643 (LPARAM)pwnd,
01644
TRUE);
01645
01646
01647
01648
01649 GreSetDCOrg(hdc, rcOrg.left, rcOrg.top, (PRECTL)&rcOrg);
01650
01651 }
else if (
ghpalWallpaper &&
01652
GetPrimaryMonitor()->
dwMONFlags &
MONF_PALETTEDISPLAY) {
01653
01654
01655
01656 HPALETTE hpalT;
01657
int i;
01658
01659 hpalT =
_SelectPalette(hdc,
ghpalWallpaper,
FALSE);
01660 i =
xxxRealizePalette(hdc);
01661
_SelectPalette(hdc, hpalT,
FALSE);
01662
01663
if (i > 0) {
01664
xxxInvalidateDesktopOnPaletteChange(pwnd);
01665 }
01666 fRet =
TRUE;
01667 }
01668
01669
return fRet;
01670 }
01671