00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
#include "precomp.h"
00014
#pragma hdrstop
00015
00016
BOOL RemoveEventMessage(
PQ pq, DWORD dwQEvent, DWORD dwQEventStop);
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 void xxxDeactivate(
00035
PTHREADINFO pti,
00036 DWORD tidSetForeground)
00037 {
00038
PWND pwndLose;
00039
AAS aas;
00040
TL tlpwndCapture;
00041
TL tlpwndChild;
00042
TL tlpwndLose;
00043
TL tlpti;
00044
TL tlptiLose;
00045 WPARAM wParam;
00046
PTHREADINFO ptiLose;
00047
PTHREADINFO ptiCurrent =
PtiCurrent();
00048
BOOL fSetActivateAppBit =
FALSE;
00049
00050
00051
00052
00053
00054
00055
00056
if (pti->
pq->
spwndActive ==
NULL)
00057
return;
00058
00059
00060
00061
00062
00063
if (pti != ptiCurrent)
00064
ThreadLockPti(ptiCurrent, pti, &tlpti);
00065
00066
00067
00068
00069
00070
if (!(pti->
TIF_flags &
TIF_INACTIVATEAPPMSG)) {
00071 pti->
TIF_flags |=
TIF_INACTIVATEAPPMSG;
00072 fSetActivateAppBit =
TRUE;
00073 }
00074
00075
00076
00077
00078
if (pti->
pq->
spwndCapture !=
NULL) {
00079
ThreadLockAlwaysWithPti(ptiCurrent, pti->
pq->
spwndCapture, &tlpwndCapture);
00080
xxxSendMessage(pti->
pq->
spwndCapture, WM_CANCELMODE, 0, 0);
00081
ThreadUnlock(&tlpwndCapture);
00082
00083
00084
00085
00086
00087
00088
SetWakeBit(pti, QS_MOUSEMOVE);
00089 }
00090
00091
00092
00093
00094
00095
00096
if (pti->
pq->
spwndActive !=
NULL) {
00097 pwndLose = pti->
pq->
spwndActive;
00098 ptiLose =
GETPTI(pwndLose);
00099
00100
ThreadLockPti(ptiCurrent, ptiLose, &tlptiLose);
00101
ThreadLockAlwaysWithPti(ptiCurrent, pwndLose, &tlpwndLose);
00102 wParam = MAKELONG(WA_INACTIVE,
TestWF(pwndLose,
WFMINIMIZED));
00103
if (!
xxxSendMessage(pwndLose, WM_NCACTIVATE, WA_INACTIVE, 0)) {
00104
ThreadUnlock(&tlpwndLose);
00105
ThreadUnlockPti(ptiCurrent, &tlptiLose);
00106
goto Exit;
00107 }
00108
xxxSendMessage(pwndLose, WM_ACTIVATE, wParam, 0);
00109
00110
00111
00112
00113
00114
if (pti->
pq->
spwndActive == pwndLose) {
00115
Lock(&pti->
pq->
spwndActivePrev, pti->
pq->
spwndActive);
00116
Unlock(&pti->
pq->
spwndActive);
00117 }
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
ClrWF(pwndLose,
WFFRAMEON);
00129
ThreadUnlock(&tlpwndLose);
00130
00131
00132
00133
00134
00135 aas.
ptiNotify = (ptiLose->
TIF_flags &
TIF_INCLEANUP) ?
NULL : ptiLose;
00136
ThreadUnlockPti(ptiCurrent, &tlptiLose);
00137 }
else {
00138
00139
00140
00141
00142
00143 pwndLose = (
PWND)-1;
00144 aas.
ptiNotify = pti;
00145 }
00146
00147
if (aas.
ptiNotify) {
00148 aas.
tidActDeact = tidSetForeground;
00149 aas.
fActivating =
FALSE;
00150 aas.
fQueueNotify =
FALSE;
00151
00152
ThreadLockWithPti(ptiCurrent,
00153 pti->
rpdesk->
pDeskInfo->
spwnd->
spwndChild, &tlpwndChild);
00154
xxxInternalEnumWindow(pti->
rpdesk->
pDeskInfo->
spwnd->
spwndChild,
00155 (
WNDENUMPROC_PWND)
xxxActivateApp, (LPARAM)&aas,
BWL_ENUMLIST);
00156
ThreadUnlock(&tlpwndChild);
00157 }
00158
00159
00160
00161
00162
00163
00164
if (pti->
pq->
spwndActive == pwndLose) {
00165
00166
ThreadLockWithPti(ptiCurrent, pwndLose, &tlpwndLose);
00167
if (!
xxxSendMessage(pwndLose, WM_NCACTIVATE, WA_INACTIVE, 0)) {
00168
ThreadUnlock(&tlpwndLose);
00169
goto Exit;
00170 }
00171
xxxSendMessage(pwndLose, WM_ACTIVATE, WA_INACTIVE, 0);
00172
ThreadUnlock(&tlpwndLose);
00173
00174
00175
00176
00177
00178
if (pti->
pq->
spwndActive == pwndLose) {
00179
Lock(&pti->
pq->
spwndActivePrev, pti->
pq->
spwndActive);
00180
Unlock(&pti->
pq->
spwndActive);
00181 }
00182 }
00183
00184
if (pti->
pq->
spwndFocus !=
NULL) {
00185 pwndLose =
Unlock(&pti->
pq->
spwndFocus);
00186
if (pwndLose !=
NULL) {
00187
ThreadLockAlwaysWithPti(ptiCurrent, pwndLose, &tlpwndLose);
00188
xxxSendMessage(pwndLose, WM_KILLFOCUS, 0, 0);
00189
#ifdef FE_IME
00190
if (
IS_IME_ENABLED()) {
00191
xxxFocusSetInputContext(pwndLose,
FALSE,
FALSE);
00192 }
00193
#endif
00194
ThreadUnlock(&tlpwndLose);
00195 }
00196 }
00197
00198 Exit:
00199
if (fSetActivateAppBit) {
00200 pti->
TIF_flags &= ~
TIF_INACTIVATEAPPMSG;
00201 }
00202
if (pti != ptiCurrent)
00203
ThreadUnlockPti(ptiCurrent, &tlpti);
00204 }
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220 void xxxSendFocusMessages(
00221
PTHREADINFO pti,
00222
PWND pwndReceive)
00223 {
00224
PWND pwndLose;
00225
TL tlpwndLose;
00226
00227
CheckLock(pwndReceive);
00228
00229
00230
00231
00232
00233 pti->
pq->
QF_flags &= ~
QF_FOCUSNULLSINCEACTIVE;
00234
if (pwndReceive ==
NULL && pti->
pq->
spwndActive !=
NULL)
00235 pti->
pq->
QF_flags |=
QF_FOCUSNULLSINCEACTIVE;
00236
00237 pwndLose = pti->
pq->
spwndFocus;
00238
ThreadLockWithPti(pti, pwndLose, &tlpwndLose);
00239
00240
00241
00242
00243 UserAssert((pwndReceive ==
NULL)
00244 ||
TestWF(pwndReceive,
WFDESTROYED)
00245 || (pti->
pq ==
GETPTI(pwndReceive)->pq));
00246
Lock(&pti->
pq->
spwndFocus, pwndReceive);
00247
00248
if (pwndReceive ==
NULL) {
00249
if (pwndLose !=
NULL) {
00250
00251
00252
00253
if (
FWINABLE()) {
00254
xxxWindowEvent(EVENT_OBJECT_FOCUS,
NULL, OBJID_CLIENT, INDEXID_OBJECT, 0);
00255 }
00256
xxxSendMessage(pwndLose, WM_KILLFOCUS, 0, 0);
00257
#ifdef FE_IME
00258
if (
IS_IME_ENABLED()) {
00259
xxxFocusSetInputContext(pwndLose,
FALSE,
FALSE);
00260 }
00261
#endif
00262
}
00263 }
else {
00264
00265
00266
00267
00268
00269
if (pti->
pq ==
gpqForeground)
00270
SetForegroundThread(
GETPTI(pwndReceive));
00271
00272
if (pwndLose !=
NULL) {
00273
xxxSendMessage(pwndLose, WM_KILLFOCUS, (WPARAM)
HWq(pwndReceive), 0);
00274
#ifdef FE_IME
00275
if (
IS_IME_ENABLED()) {
00276
xxxFocusSetInputContext(pwndLose,
FALSE,
FALSE);
00277 }
00278
#endif
00279
}
00280
00281
00282
00283
00284
00285
00286
00287
00288
if (pwndReceive == pti->
pq->
spwndFocus) {
00289
#ifdef FE_IME
00290
if (
IS_IME_ENABLED()) {
00291
xxxFocusSetInputContext(pwndReceive,
TRUE,
FALSE);
00292 }
00293
#endif
00294
00295
00296
00297
00298
00299
if (
FWINABLE()) {
00300
xxxWindowEvent(EVENT_OBJECT_FOCUS, pwndReceive, OBJID_CLIENT,
00301 INDEXID_OBJECT, 0);
00302 }
00303
xxxSendMessage(pwndReceive, WM_SETFOCUS, (WPARAM)
HW(pwndLose), 0);
00304 }
00305 }
00306
00307
ThreadUnlock(&tlpwndLose);
00308 }
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336 BOOL xxxActivateApp(
00337
PWND pwnd,
00338
AAS *paas)
00339 {
00340
CheckLock(pwnd);
00341
00342
if (
GETPTI(pwnd) == paas->
ptiNotify) {
00343
00344
if (paas->
fQueueNotify) {
00345
QueueNotifyMessage(pwnd, WM_ACTIVATEAPP, paas->
fActivating,
00346 paas->
tidActDeact);
00347 }
else {
00348
xxxSendMessage(pwnd, WM_ACTIVATEAPP, paas->
fActivating,
00349 paas->
tidActDeact);
00350 }
00351 }
00352
00353
return TRUE;
00354 }
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365 BOOL FBadWindow(
00366
PWND pwnd)
00367 {
00368
return (pwnd ==
NULL
00369 || !
TestWF(pwnd,
WFVISIBLE)
00370 ||
TestWF(pwnd,
WFDISABLED));
00371 }
00372
00373
00374 void xxxUpdateTray(
PWND pwnd)
00375 {
00376
PWND pwndT;
00377
00378
CheckLock(pwnd);
00379
if (!
TestWF(pwnd,
WFVISIBLE)) {
00380
return;
00381 }
00382
00383
for (pwndT = pwnd; pwndT->
spwndOwner; pwndT = pwndT->
spwndOwner) {
00384 }
00385
00386
00387
if (
GETPTI(pwndT)->pq ==
gpqForeground &&
00388
FDoTray() &&
00389 (
FCallHookTray() ||
FPostTray(pwndT->
head.rpdesk)) &&
00390
FTopLevel(pwndT) &&
00391
TestWF(pwndT,
WFVISIBLE))
00392 {
00393
BOOL fFirstTry;
00394
BOOL fTryAgain;
00395
PWND pwndArg;
00396
TL tlpwndArg;
00397
00398 fFirstTry =
TRUE;
00399
do {
00400 fTryAgain =
FALSE;
00401
if (
TestWF(pwndT,
WFWIN40COMPAT)) {
00402
if (
TestWF(pwnd,
WFWIN40COMPAT) &&
IsTrayWindow(pwnd)) {
00403 pwndArg = pwnd;
00404 }
else {
00405 pwndArg =
IsTrayWindow(pwndT) ? pwndT :
NULL;
00406 }
00407 }
else {
00408
if (
TestWF(pwndT,
WEFTOOLWINDOW)) {
00409 pwndArg =
NULL;
00410 }
else if (
FHas31TrayStyles(pwndT)) {
00411 pwndArg =
Is31TrayWindow(pwndT) ? pwndT :
NULL;
00412 }
else if (fFirstTry && (pwndT = pwndT->
spwndLastActive)) {
00413 fFirstTry =
FALSE;
00414 fTryAgain =
TRUE;
00415 }
else {
00416
return;
00417 }
00418 }
00419 }
while (fTryAgain);
00420
00421
ThreadLock(pwndArg, &tlpwndArg);
00422
xxxSetTrayWindow(
00423 (pwndArg) ? pwndArg->
head.rpdesk : pwndT->
head.rpdesk,
00424 pwndArg,
00425
NULL);
00426
00427
ThreadUnlock(&tlpwndArg);
00428 }
00429 }
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472 BOOL xxxActivateThisWindow(
00473
PWND pwnd,
00474 DWORD tidLoseForeground,
00475 DWORD fFlags)
00476 {
00477
PTHREADINFO ptiCurrent =
PtiCurrent();
00478
PWND pwndT, pwndActivePrev, pwndActiveSave;
00479
TL tlpwndActive;
00480
TL tlpwndChild;
00481
TL tlpwndActivePrev;
00482 WPARAM wParam;
00483
BOOL fSetActivateAppBit;
00484
00485
BOOL fMouse = (
BOOL)(fFlags &
ATW_MOUSE);
00486
BOOL fSetFocus = (
BOOL)(fFlags &
ATW_SETFOCUS);
00487
BOOL fAsync = (
BOOL)(fFlags &
ATW_ASYNC);
00488
00489
#if DBG
00490
PQ pqSave = ptiCurrent->
pq;
00491
#endif
00492
00493
00494
CheckLock(pwnd);
00495
00496
00497
00498
00499
if ((pwnd ==
NULL) || (pwnd ==
PWNDDESKTOP(pwnd))) {
00500
return FALSE;
00501 }
00502
00503
00504
00505
00506
if (
HMIsMarkDestroy(pwnd))
00507
return FALSE;
00508
00509
00510
00511
00512
if (
GETPTI(pwnd)->pq != ptiCurrent->
pq) {
00513
return FALSE;
00514 }
00515
00516 pwndActiveSave = ptiCurrent->
pq->
spwndActive;
00517
00518
00519
00520
00521
00522
if ((pwnd != pwndActiveSave) && !
TestWF(pwnd,
WFBEINGACTIVATED)) {
00523
00524
00525
00526
00527 {
00528 CBTACTIVATESTRUCT CbtActivateParams;
00529
00530
if (
IsHooked(ptiCurrent,
WHF_CBT)) {
00531
00532 CbtActivateParams.fMouse = fMouse;
00533 CbtActivateParams.hWndActive =
HW(pwndActiveSave);
00534
00535
if (
xxxCallHook(HCBT_ACTIVATE,
00536 (WPARAM)
HWq(pwnd), (LPARAM)&CbtActivateParams, WH_CBT)) {
00537
return FALSE;
00538 }
00539 }
00540 }
00541
00542 ptiCurrent->
pq->
QF_flags &= ~
QF_EVENTDEACTIVATEREMOVED;
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
if (ptiCurrent->
pq->
spwndActive &&
TestWF(ptiCurrent->
pq->
spwndActive,
WFDESTROYED)) {
00559
Lock(&ptiCurrent->
pq->
spwndActive,
NULL);
00560 }
else {
00561
Lock(&ptiCurrent->
pq->
spwndActivePrev, ptiCurrent->
pq->
spwndActive);
00562 }
00563 pwndActivePrev = ptiCurrent->
pq->
spwndActive;
00564
00565
00566
00567
00568
00569
00570
if ((pwndActivePrev !=
NULL) && (ptiCurrent->
pq ==
gpqForeground)) {
00571
gpqForegroundPrev = ptiCurrent->
pq;
00572 }
00573
00574
00575
00576
00577
if (pwndActivePrev !=
NULL) {
00578
ThreadLockWithPti(ptiCurrent, pwndActivePrev, &tlpwndActive);
00579
00580
00581
00582
00583
00584 wParam = MAKELONG(WA_INACTIVE,
TestWF(pwndActivePrev,
WFMINIMIZED));
00585
if (!
xxxSendMessage(pwndActivePrev, WM_NCACTIVATE,
00586 wParam, (LPARAM)
HWq(pwnd))) {
00587
ThreadUnlock(&tlpwndActive);
00588
return FALSE;
00589 }
00590
00591
xxxSendMessage(pwndActivePrev, WM_ACTIVATE, wParam, (LPARAM)
HWq(pwnd));
00592
00593
ThreadUnlock(&tlpwndActive);
00594 }
00595
00596
00597
00598
00599
00600
00601
if (ptiCurrent->
pq->
spwndActivePrev != ptiCurrent->
pq->
spwndActive ||
00602 pwndActiveSave != ptiCurrent->
pq->
spwndActive) {
00603
#if DBG
00604
if (ptiCurrent->
pq->
spwndActivePrev == ptiCurrent->
pq->
spwndActive) {
00605 RIPMSG0(RIP_WARNING,
"xxxActivateThisWindow: ptiCurrent->pq->spwndActive changed in callbacks");
00606 }
00607
#endif
00608
return FALSE;
00609 }
00610
00611
00612
00613
00614
00615
00616
if (
HMIsMarkDestroy(pwnd))
00617
return FALSE;
00618
00619
00620
00621
00622
00623
if (
GETPTI(pwnd)->pq != ptiCurrent->
pq) {
00624 RIPMSG1(RIP_WARNING,
"xxxActivateThisWindow: Queue unattached:%#p", pqSave);
00625
return FALSE;
00626 }
00627
00628
00629
00630
00631
00632
00633
00634
00635
if (ptiCurrent->
pq->
spwndActive ==
NULL)
00636 ptiCurrent->
pq->
QF_flags &= ~
QF_FOCUSNULLSINCEACTIVE;
00637
00638
Lock(&ptiCurrent->
pq->
spwndActive, pwnd);
00639
00640
00641
00642
00643
00644
00645
00646
00647
SetWF(pwnd,
WFBEINGACTIVATED);
00648
00649
if (
FWINABLE()) {
00650
xxxWindowEvent(EVENT_SYSTEM_FOREGROUND, pwnd, OBJID_WINDOW, INDEXID_OBJECT,
WEF_USEPWNDTHREAD);
00651 }
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
RemoveEventMessage(ptiCurrent->
pq,
QEVENT_ACTIVATE,
QEVENT_DEACTIVATE);
00671
00672
xxxMakeWindowForegroundWithState(
NULL, 0);
00673
00674 pwndActivePrev = ptiCurrent->
pq->
spwndActivePrev;
00675
ThreadLockWithPti(ptiCurrent, pwndActivePrev, &tlpwndActivePrev);
00676
00677
if (
TEST_PUSIF(
PUSIF_PALETTEDISPLAY) &&
xxxSendMessage(pwnd, WM_QUERYNEWPALETTE, 0, 0)) {
00678
xxxSendNotifyMessage(
PWND_BROADCAST, WM_PALETTEISCHANGING,
00679 (WPARAM)
HWq(pwnd), 0);
00680 }
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
if (!(fFlags &
ATW_NOZORDER) && !
TestWF(pwnd,
WFCHILD)) {
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703 pwndT =
PWNDDESKTOP(pwnd)->spwndChild;
00704
00705
while (pwndT && (!
TestWF(pwndT,
WFVISIBLE))) {
00706 pwndT = pwndT->
spwndNext;
00707 }
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
if ((pwnd != pwndT) || (pwndActivePrev && !
IsVisible(pwndActivePrev))) {
00729
00730
if (!(fAsync && (
gpqForeground != ptiCurrent->
pq))) {
00731
DWORD dwFlags;
00732
00733
00734
00735
00736
00737
dwFlags = SWP_NOSIZE | SWP_NOMOVE;
00738
if (pwnd == pwndT)
00739
dwFlags |= SWP_NOACTIVATE;
00740
00741
xxxSetWindowPos(pwnd,
PWND_TOP, 0, 0, 0, 0,
dwFlags);
00742 }
00743 }
00744 }
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757 fSetActivateAppBit =
FALSE;
00758
if (!(ptiCurrent->
TIF_flags &
TIF_INACTIVATEAPPMSG) &&
00759 ((pwndActivePrev ==
NULL) ||
00760 (
GETPTI(pwndActivePrev) !=
GETPTI(pwnd)))) {
00761
AAS aas;
00762
00763
00764
00765
00766
00767
00768
if (pwndActivePrev !=
NULL) {
00769
PTHREADINFO ptiPrev =
GETPTI(pwndActivePrev);
00770
TL tlptiPrev;
00771
00772
00773
00774
00775
00776 ptiPrev->
TIF_flags |=
TIF_INACTIVATEAPPMSG;
00777
00778 aas.
ptiNotify = ptiPrev;
00779 aas.
tidActDeact =
TIDq(ptiCurrent);
00780 aas.
fActivating =
FALSE;
00781 aas.
fQueueNotify =
FALSE;
00782
00783
ThreadLockPti(ptiCurrent, ptiPrev, &tlptiPrev);
00784
ThreadLockWithPti(ptiCurrent, pwndActivePrev->
head.rpdesk->pDeskInfo->spwnd->spwndChild, &tlpwndChild);
00785
xxxInternalEnumWindow(pwndActivePrev->
head.rpdesk->pDeskInfo->spwnd->spwndChild,
00786 (
WNDENUMPROC_PWND)
xxxActivateApp, (LPARAM)&aas,
BWL_ENUMLIST);
00787
ThreadUnlock(&tlpwndChild);
00788 ptiPrev->
TIF_flags &= ~
TIF_INACTIVATEAPPMSG;
00789
ThreadUnlockPti(ptiCurrent, &tlptiPrev);
00790 }
00791
00792
00793
00794
00795
00796
00797 ptiCurrent->
TIF_flags |=
TIF_INACTIVATEAPPMSG;
00798 fSetActivateAppBit =
TRUE;
00799
00800 aas.
ptiNotify =
GETPTI(pwnd);
00801 aas.
tidActDeact = tidLoseForeground;
00802 aas.
fActivating =
TRUE;
00803 aas.
fQueueNotify =
FALSE;
00804
00805
ThreadLockWithPti(ptiCurrent, ptiCurrent->
rpdesk->
pDeskInfo->
spwnd->
spwndChild, &tlpwndChild);
00806
xxxInternalEnumWindow(ptiCurrent->
rpdesk->
pDeskInfo->
spwnd->
spwndChild,
00807 (
WNDENUMPROC_PWND)
xxxActivateApp, (LPARAM)&aas,
BWL_ENUMLIST);
00808
ThreadUnlock(&tlpwndChild);
00809 }
00810
00811
00812
00813
00814
00815
if (
TestWF(pwnd,
WFFRAMEON)) {
00816
SetWF(pwnd,
WFNONCPAINT);
00817 }
00818
00819
00820
00821
00822
00823
00824
00825
if (!
HMIsMarkDestroy(pwnd)) {
00826
00827
00828
00829
00830 pwndT = pwnd;
00831
while (pwndT->
spwndOwner !=
NULL) {
00832 pwndT = pwndT->
spwndOwner;
00833 }
00834
Lock(&pwndT->
spwndLastActive, pwnd);
00835 }
00836
00837
00838
xxxSendMessage(pwnd, WM_NCACTIVATE,
00839 MAKELONG(
GETPTI(pwnd)->pq ==
gpqForeground,
00840 ptiCurrent->
pq->
spwndActive !=
NULL ?
00841
TestWF(ptiCurrent->
pq->
spwndActive,
WFMINIMIZED) : 0),
00842 (LPARAM)
HW(pwndActivePrev));
00843
00844
if (ptiCurrent->
pq->
spwndActive !=
NULL) {
00845
xxxSendMessage(pwnd, WM_ACTIVATE,
00846 MAKELONG((fMouse ? WA_CLICKACTIVE : WA_ACTIVE),
00847
TestWF(ptiCurrent->
pq->
spwndActive,
WFMINIMIZED)),
00848 (LPARAM)
HW(pwndActivePrev));
00849 }
else {
00850
xxxSendMessage(pwnd, WM_ACTIVATE,
00851 MAKELONG((fMouse ? WA_CLICKACTIVE : WA_ACTIVE), 0),
00852 (LPARAM)
HW(pwndActivePrev));
00853 }
00854
00855
xxxUpdateTray(pwnd);
00856
00857
ThreadUnlock(&tlpwndActivePrev);
00858
00859
ClrWF(pwnd,
WFNONCPAINT);
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
ThreadLockWithPti(ptiCurrent, ptiCurrent->
pq->
spwndActive, &tlpwndActive);
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
#if 0
00910
00911
00912
if (fSetFocus && ptiCurrent->
pq->
spwndFocus !=
NULL && ptiCurrent->
pq->
spwndActive !=
00913
GetTopLevelWindow(ptiCurrent->
pq->
spwndFocus))
00914
#else
00915
if (fSetFocus && !(ptiCurrent->
pq->
QF_flags &
QF_FOCUSNULLSINCEACTIVE) &&
00916 ptiCurrent->
pq->
spwndActive !=
GetTopLevelWindow(ptiCurrent->
pq->
spwndFocus)) {
00917
#endif
00918
00919
xxxSendFocusMessages(ptiCurrent,
00920 (ptiCurrent->
pq->
spwndActive !=
NULL &&
00921
TestWF(ptiCurrent->
pq->
spwndActive,
WFMINIMIZED)) ?
00922
NULL : ptiCurrent->
pq->
spwndActive);
00923 }
00924
00925
ThreadUnlock(&tlpwndActive);
00926
00927
00928
00929
00930
00931
00932 ptiCurrent->
pq->
QF_flags |=
QF_ACTIVATIONCHANGE;
00933
00934
if (
gppiScreenSaver ==
NULL) {
00935
00936
00937
00938
00939
00940
if (ptiCurrent->
rpdesk ==
grpdeskRitInput) {
00941
glinp.
timeLastInputMessage =
NtGetTickCount();
00942 }
00943
00944 }
else {
00945
00946
if (
GETPTI(pwnd)->ppi !=
gppiScreenSaver) {
00947
00948
00949
00950
00951
00952
00953
#if 0
00954
00955
if (ptiCurrent->
rpdesk !=
gppiScreenSaver->
rpdeskStartup) {
00956
00957
00958
00959
00960 }
00961
#endif
00962
00963
glinp.
timeLastInputMessage =
NtGetTickCount();
00964
gppiScreenSaver->W32PF_Flags &= ~W32PF_IDLESCREENSAVER;
00965
SetForegroundPriorityProcess(
gppiScreenSaver,
gppiScreenSaver->
ptiMainThread,
TRUE);
00966 }
00967 }
00968
00969
00970
00971
00972
00973
if (fSetActivateAppBit)
00974 ptiCurrent->
TIF_flags &= ~
TIF_INACTIVATEAPPMSG;
00975
00976
00977 }
else {
00978
#if DBG
00979
if (
TestWF(pwnd,
WFBEINGACTIVATED)) {
00980 RIPMSG1(RIP_WARNING,
"xxxActivateThisWindow recursing on pwnd %#p\n", pwnd);
00981 }
00982
#endif
00983
ptiCurrent->
pq->
QF_flags &= ~
QF_EVENTDEACTIVATEREMOVED;
00984
if (
TEST_PUSIF(
PUSIF_PALETTEDISPLAY) &&
xxxSendMessage(pwnd, WM_QUERYNEWPALETTE, 0, 0)) {
00985
xxxSendNotifyMessage(
PWND_BROADCAST, WM_PALETTEISCHANGING,
00986 (WPARAM)
HWq(pwnd), 0);
00987 }
00988 }
00989
00990
ClrWF(pwnd,
WFBEINGACTIVATED);
00991
return ptiCurrent->
pq->
spwndActive == pwnd;
00992 }
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004 BOOL RemoveEventMessage(
01005
PQ pq,
01006 DWORD dwQEvent,
01007 DWORD dwQEventStop)
01008 {
01009
PQMSG pqmsgT;
01010
PQMSG pqmsgPrev;
01011
BOOL bRemovedEvent =
FALSE;
01012
01013
01014
01015
01016
for (pqmsgT = pq->
mlInput.
pqmsgWriteLast; pqmsgT !=
NULL; ) {
01017
01018
if (pqmsgT->
dwQEvent == dwQEventStop)
01019
return(bRemovedEvent);
01020
01021 pqmsgPrev = pqmsgT->
pqmsgPrev;
01022
01023
01024
01025
01026
01027
if (pqmsgT->
dwQEvent == dwQEvent &&
01028 pqmsgT != (
PQMSG)pq->
idSysPeek) {
01029
DelQEntry(&(pq->
mlInput), pqmsgT);
01030 bRemovedEvent =
TRUE;
01031 }
01032 pqmsgT = pqmsgPrev;
01033 }
01034
return(bRemovedEvent);
01035 }
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056 BOOL CanForceForeground(
PPROCESSINFO ppi)
01057 {
01058
01059
if ((
glinp.
ptiLastWoken !=
NULL)
01060 && (
glinp.
ptiLastWoken->
ppi != ppi)
01061 && (
gptiForeground !=
NULL)
01062 && (
gptiForeground->
ppi != ppi)
01063 && !(ppi->W32PF_Flags & (W32PF_ALLOWFOREGROUNDACTIVATE |
W32PF_ALLOWSETFOREGROUND))
01064 && (ppi !=
gppiInputProvider)
01065 && (
gpqForeground !=
NULL)
01066 &&
01067
#if DBG
01068
01069
01070
01071
01072
01073 (gfDebugForegroundIgnoreDebugPort
01074 || (
01075
#endif
01076
(
glinp.
ptiLastWoken->
ppi->Process->DebugPort ==
NULL)
01077 && (
gptiForeground->
ppi->Process->DebugPort ==
NULL)
01078
#if DBG
01079
))
01080
#endif
01081
&& !
IsTimeFromLastRITEvent(
UP(FOREGROUNDLOCKTIMEOUT))) {
01082
01083
return FALSE;
01084 }
else {
01085
return TRUE;
01086 }
01087
01088 }
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101 BOOL xxxAllowSetForegroundWindow(
01102 DWORD dwProcessId)
01103 {
01104
DWORD dwError;
01105
PEPROCESS pep;
01106
NTSTATUS Status;
01107
PPROCESSINFO ppi;
01108
01109
01110
01111
01112
if (dwProcessId != ASFW_ANY) {
01113
LeaveCrit();
01114
Status =
LockProcessByClientId((HANDLE)LongToHandle( dwProcessId ), &
pep);
01115
EnterCrit();
01116
if (!
NT_SUCCESS(
Status)) {
01117 RIPERR0(ERROR_INVALID_PARAMETER, RIP_VERBOSE,
"");
01118
return FALSE;
01119 }
01120 ppi =
PpiFromProcess(
pep);
01121
if (ppi ==
NULL) {
01122 dwError = ERROR_INVALID_PARAMETER;
01123
goto UnlockAndFail;
01124 }
01125 }
01126
01127
01128
01129
01130
01131
if (!
CanForceForeground(
PpiCurrent())) {
01132 dwError = ERROR_ACCESS_DENIED;
01133
goto UnlockAndFail;
01134 }
01135
01136
01137
01138
if (dwProcessId != ASFW_ANY) {
01139 TAGMSG2(DBGTAG_FOREGROUND,
"xxxAllowSetForegroundWindow by %#p to %#p",
PpiCurrent(), ppi);
01140
glinp.
ptiLastWoken = ppi->
ptiList;
01141
UnlockProcess(
pep);
01142 }
else {
01143 TAGMSG1(DBGTAG_FOREGROUND,
"xxxAllowSetForegroundWindow by %#p to ANY",
PpiCurrent());
01144
glinp.
ptiLastWoken =
NULL;
01145 }
01146
return TRUE;
01147
01148 UnlockAndFail:
01149
if (dwProcessId != ASFW_ANY) {
01150
UnlockProcess(
pep);
01151 }
01152 RIPERR0(dwError, RIP_VERBOSE,
"");
01153
return FALSE;
01154 }
01155
01156
01157
01158
01159
01160
01161
01162
01163
01164
01165
01166
01167 BOOL _LockSetForegroundWindow(
01168 UINT uLockCode)
01169 {
01170
DWORD dwError;
01171
PPROCESSINFO ppiCurrent =
PpiCurrent();
01172
01173
switch (uLockCode) {
01174
case LSFW_LOCK:
01175
01176
01177
01178
if (
CanForceForeground(ppiCurrent) && (
gppiLockSFW ==
NULL)) {
01179
gppiLockSFW = ppiCurrent;
01180 TAGMSG1(DBGTAG_FOREGROUND,
"_LockSetForegroundWindow locked by %#p", ppiCurrent);
01181 }
else {
01182 dwError = ERROR_ACCESS_DENIED;
01183
goto FailIt;
01184 }
01185
break;
01186
01187
case LSFW_UNLOCK:
01188
01189
01190
01191
if (ppiCurrent ==
gppiLockSFW) {
01192
gppiLockSFW =
NULL;
01193 TAGMSG0(DBGTAG_FOREGROUND,
"_LockSetForegroundWindow UNLOCKED");
01194 }
else {
01195 dwError = ERROR_ACCESS_DENIED;
01196
goto FailIt;
01197 }
01198
break;
01199
01200
default:
01201 dwError = ERROR_INVALID_PARAMETER;
01202
goto FailIt;
01203 }
01204
01205
return TRUE;
01206
01207 FailIt:
01208 RIPERR0(dwError, RIP_VERBOSE,
"");
01209
return FALSE;
01210 }
01211
01212
01213
01214
01215
01216
01217
01218 void CleanupDecSFWLockCount(PVOID pIgnore)
01219 {
01220
DecSFWLockCount();
01221 UNREFERENCED_PARAMETER(pIgnore);
01222 }
01223
01224
01225
01226
01227
01228
01229
01230 BOOL xxxStubSetForegroundWindow(
01231
PWND pwnd)
01232 {
01233
return xxxSetForegroundWindow(pwnd,
TRUE);
01234 }
01235 BOOL xxxSetForegroundWindow(
01236
PWND pwnd,
01237 BOOL fFlash)
01238 {
01239
BOOL fNiceCall =
TRUE;
01240
BOOL fSyncActivate, fActive;
01241
DWORD dwFlashFlags;
01242
PTHREADINFO ptiCurrent =
PtiCurrent();
01243
PWND pwndFlash;
01244
TL tlpwndFlash;
01245
01246
CheckLock(pwnd);
01247
01248
01249
01250
01251
01252
01253
if ((pwnd !=
NULL) && (
GETPTI(pwnd)->pq ==
gpqForeground)) {
01254 fSyncActivate = (
gpqForeground == ptiCurrent->
pq);
01255
if (fSyncActivate) {
01256
gppiWantForegroundPriority = ptiCurrent->
ppi;
01257 }
else {
01258
gppiWantForegroundPriority =
GETPTI(pwnd)->ppi;
01259 }
01260
01261
goto JustActivateIt;
01262 }
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276
01277
01278
01279
if ((!
IsForegroundLocked() || (ptiCurrent->
ppi ==
gppiInputProvider))
01280 && (ptiCurrent->
TIF_flags & (
TIF_ALLOWFOREGROUNDACTIVATE |
TIF_SYSTEMTHREAD |
TIF_CSRSSTHREAD)
01281 ||
CanForceForeground(ptiCurrent->
ppi)
01282 ||
GiveUpForeground())) {
01283
01284 TAGMSG1(DBGTAG_FOREGROUND,
"xxxSetForegroundWindow FRemoveForegroundActivate %#p", ptiCurrent);
01285
01286
FRemoveForegroundActivate(ptiCurrent);
01287
return xxxSetForegroundWindow2(pwnd, ptiCurrent, 0);
01288 }
01289 fNiceCall =
FALSE;
01290 TAGMSG3(DBGTAG_FOREGROUND,
"xxxSetForegroundWindow: rude call by %#p to %#p-%#p",
01291 ptiCurrent, pwnd, (pwnd !=
NULL ?
GETPTI(pwnd) :
NULL));
01292
if (pwnd ==
NULL) {
01293
return FALSE;
01294 }
01295
01296
01297
01298
01299
if (fFlash) {
01300 pwndFlash =
DSW_GetTopLevelCreatorWindow(
GetTopLevelWindow(pwnd));
01301
if (
IsTrayWindow(pwndFlash)) {
01302 dwFlashFlags = FLASHW_TRAY;
01303 }
else {
01304 pwndFlash = pwnd;
01305 dwFlashFlags = FLASHW_ALL;
01306 }
01307
ThreadLockAlways(pwndFlash, &tlpwndFlash);
01308
xxxFlashWindow(pwndFlash,
01309 MAKELONG(dwFlashFlags | FLASHW_TIMERNOFG,
UP(FOREGROUNDFLASHCOUNT)),
01310 0);
01311
ThreadUnlock(&tlpwndFlash);
01312 }
01313
01314
01315
01316 fSyncActivate = (ptiCurrent->
pq ==
GETPTI(pwnd)->pq);
01317
01318 JustActivateIt:
01319
01320
if (fSyncActivate) {
01321 fActive =
xxxActivateWindow(pwnd,
AW_USE);
01322 }
else if (pwnd ==
GETPTI(pwnd)->pq->spwndActive) {
01323 fActive =
TRUE;
01324 }
else {
01325 fActive =
PostEventMessage(
GETPTI(pwnd),
GETPTI(pwnd)->pq,
01326
QEVENT_ACTIVATE,
NULL, 0,
01327 0, (LPARAM)
HWq(pwnd)) ;
01328 }
01329
01330
01331
01332
01333
return fNiceCall && fActive;
01334 }
01335
01336
01337
01338
01339
01340
01341
01342 BOOL xxxSetForegroundWindow2(
01343
PWND pwnd,
01344
PTHREADINFO pti,
01345 DWORD fFlags)
01346 {
01347
PTHREADINFO ptiForegroundOld;
01348
PTHREADINFO ptiForegroundNew;
01349
PQ pqForegroundOld, pqForegroundNew, pqCurrent;
01350 HWND hwnd;
01351
PQMSG pqmsgDeactivate, pqmsgActivate;
01352
BOOL bRemovedEvent;
01353
PTHREADINFO ptiCurrent =
PtiCurrent();
01354
BOOL retval =
TRUE;
01355
UINT uMsg;
01356
CheckLock(pwnd);
01357
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367
01368
01369
01370
01371
01372
01373
if (pwnd !=
NULL && (pwnd->
head.rpdesk !=
grpdeskRitInput ||
01374
HMIsMarkDestroy(pwnd))) {
01375
return FALSE;
01376 }
01377
01378
01379
01380
01381
gppiLockSFW =
NULL;
01382 TAGMSG3(DBGTAG_FOREGROUND,
"xxxSetForegroundWindow2 by %#p to %#p-%#p",
01383 ptiCurrent, pwnd, (pwnd !=
NULL ?
GETPTI(pwnd) :
NULL));
01384
01385
01386
01387
01388
01389
if ((
gptiForeground !=
NULL) && !(
gptiForeground->
TIF_flags &
TIF_INCLEANUP)) {
01390 ptiForegroundOld =
gptiForeground;
01391 }
else {
01392 ptiForegroundOld =
NULL;
01393 }
01394 pqForegroundOld =
NULL;
01395 pqForegroundNew =
NULL;
01396 pqCurrent =
NULL;
01397
01398
gpqForegroundPrev =
gpqForeground;
01399
01400
if (pwnd !=
NULL) {
01401 ptiForegroundNew =
GETPTI(pwnd);
01402 UserAssert(ptiForegroundNew->
rpdesk ==
grpdeskRitInput);
01403
gppiWantForegroundPriority =
GETPTI(pwnd)->ppi;
01404
gpqForeground =
GETPTI(pwnd)->pq;
01405 UserAssert(
gpqForeground->
cThreads != 0);
01406 UserAssert(
gpqForeground->
ptiMouse->
rpdesk ==
grpdeskRitInput);
01407
01408
01409 UserAssert(!
gpqForeground || (
gpqForeground->
ptiKeyboard &&
gpqForeground->
ptiKeyboard->
rpdesk));
01410
SetForegroundThread(
GETPTI(pwnd));
01411 }
else {
01412 ptiForegroundNew =
NULL;
01413
gppiWantForegroundPriority =
NULL;
01414
gpqForeground =
NULL;
01415
SetForegroundThread(
NULL);
01416 }
01417
01418
01419
01420
01421
if (
gpqForeground !=
gpqForegroundPrev) {
01422
TL tlptiForegroundOld;
01423
TL tlptiForegroundNew;
01424
TL tlpti;
01425
01426
ThreadLockPti(ptiCurrent, ptiForegroundOld, &tlptiForegroundOld);
01427
ThreadLockPti(ptiCurrent, ptiForegroundNew, &tlptiForegroundNew);
01428
ThreadLockPti(ptiCurrent, pti, &tlpti);
01429
01430
01431
01432
01433
01434
if (pti !=
NULL) {
01435
01436
01437
01438
01439
xxxCancelTracking();
01440
01441
01442
01443
01444
01445
01446
zzzClipCursor(
NULL);
01447
LockWindowUpdate2(
NULL,
TRUE);
01448
01449
01450
01451
01452
01453
xxxMakeWindowForegroundWithState(
NULL, 0);
01454 }
01455
01456
01457
01458
01459
01460 pqForegroundOld =
NULL;
01461
if (ptiForegroundOld && !(ptiForegroundOld->
TIF_flags &
TIF_INCLEANUP)) {
01462 pqForegroundOld = ptiForegroundOld->
pq;
01463 }
01464
01465 pqCurrent =
NULL;
01466
if (pti !=
NULL)
01467 pqCurrent = pti->
pq;
01468
01469
01470
01471
01472 pqmsgDeactivate = pqmsgActivate =
NULL;
01473
01474
if ((pqForegroundOld !=
NULL) && (pqForegroundOld != pqCurrent)) {
01475
if ((pqmsgDeactivate =
AllocQEntry(&pqForegroundOld->
mlInput)) ==
01476
NULL) {
01477 retval =
FALSE;
01478
goto Exit;
01479 }
01480 }
01481
01482
01483
01484
01485
if (pqForegroundOld !=
NULL) {
01486
01487
01488
01489
01490
01491
01492
if (pqForegroundOld != pqCurrent) {
01493
StoreQMessage(pqmsgDeactivate,
NULL, 0,
01494
gptiForeground !=
NULL ? (WPARAM)
gptiForeground->pEThread->Cid.UniqueThread : 0,
01495 0, 0,
QEVENT_DEACTIVATE, 0);
01496
01497
01498
01499
01500
01501
01502
if (ptiForegroundOld !=
NULL) {
01503
SetWakeBit(ptiForegroundOld, QS_EVENTSET);
01504
01505
StoreQMessagePti(pqmsgDeactivate, ptiForegroundOld);
01506
01507 }
01508
01509
if (pqForegroundOld->
spwndActive !=
NULL) {
01510
if (ptiForegroundOld !=
NULL &&
FHungApp(ptiForegroundOld,
CMSHUNGAPPTIMEOUT)) {
01511
TL tlpwnd;
01512
ThreadLockAlwaysWithPti(ptiCurrent, pqForegroundOld->
spwndActive, &tlpwnd);
01513
xxxRedrawHungWindowFrame(pqForegroundOld->
spwndActive,
FALSE);
01514
ThreadUnlock(&tlpwnd);
01515 }
else {
01516
SetHungFlag(pqForegroundOld->
spwndActive,
WFREDRAWFRAMEIFHUNG);
01517 }
01518 }
01519 }
01520 }
01521
01522
01523
01524
01525
01526 pqForegroundNew =
NULL;
01527
if (ptiForegroundNew && !(ptiForegroundNew->
TIF_flags &
TIF_INCLEANUP)) {
01528 pqForegroundNew = ptiForegroundNew->
pq;
01529 }
01530
01531
01532
01533
01534
01535 pqCurrent =
NULL;
01536
if (pti !=
NULL) {
01537 pqCurrent = pti->
pq;
01538 }
01539
01540
if ((pqForegroundNew !=
NULL) && (pqForegroundNew != pqCurrent)) {
01541 pqmsgActivate =
AllocQEntry(&pqForegroundNew->
mlInput);
01542
if (pqmsgActivate ==
NULL) {
01543 retval =
FALSE;
01544
goto Exit;
01545 }
01546 }
01547
01548
01549
01550
01551
if (pqForegroundNew !=
NULL) {
01552
01553
01554
01555
01556
01557
01558
01559
01560
01561
01562
01563
01564
01565
01566
01567
01568
01569
01570
01571
01572 bRemovedEvent =
RemoveEventMessage(pqForegroundNew,
QEVENT_DEACTIVATE, (
DWORD)-1);
01573
01574
01575
01576
01577
01578
01579
if (pqForegroundNew != pqCurrent) {
01580
01581
01582
01583
01584
01585
01586
01587
01588
01589
if ((pqCurrent ==
NULL) && (!(fFlags &
SFW_SWITCH))) {
01590 hwnd =
NULL;
01591 }
else {
01592 hwnd =
HW(pwnd);
01593 }
01594
01595
if (bRemovedEvent) {
01596 pqForegroundNew->
QF_flags |=
QF_EVENTDEACTIVATEREMOVED;
01597 }
01598
01599
01600
01601
01602
01603
01604
01605
01606
01607
01608
01609
01610
01611
if (fFlags &
SFW_ACTIVATERESTORE) {
01612 uMsg =
PEM_ACTIVATE_RESTORE;
01613 }
else {
01614 uMsg = 0;
01615 }
01616
01617
if (fFlags &
SFW_NOZORDER) {
01618 uMsg |=
PEM_ACTIVATE_NOZORDER;
01619 }
01620
01621
StoreQMessage(pqmsgActivate,
NULL, uMsg,
01622 (fFlags &
SFW_STARTUP) ? 0 : (WPARAM)
TID(ptiForegroundOld),
01623 (LPARAM)hwnd, 0,
QEVENT_ACTIVATE, 0);
01624
01625
01626
01627
01628
01629
01630
01631
01632
StoreQMessagePti(pqmsgActivate, ptiForegroundNew);
01633
01634
SetWakeBit(ptiForegroundNew, QS_EVENTSET);
01635
01636
if (pqForegroundNew->
spwndActive !=
NULL) {
01637
if (
FHungApp(ptiForegroundNew,
CMSHUNGAPPTIMEOUT)) {
01638
TL tlpwnd;
01639
ThreadLockAlwaysWithPti(ptiCurrent, pqForegroundNew->
spwndActive, &tlpwnd);
01640
xxxRedrawHungWindowFrame(pqForegroundNew->
spwndActive,
TRUE);
01641
ThreadUnlock(&tlpwnd);
01642 }
else {
01643
SetHungFlag(pqForegroundNew->
spwndActive,
WFREDRAWFRAMEIFHUNG);
01644 }
01645 }
01646
01647 }
else {
01648
if (pwnd != pqCurrent->
spwndActive) {
01649
if (!(fFlags &
SFW_STARTUP)) {
01650 retval =
xxxActivateThisWindow(pwnd,
TID(ptiForegroundOld),
01651 ((fFlags &
SFW_SETFOCUS) ? 0 :
ATW_SETFOCUS));
01652
01653
01654
01655
01656
if (retval &&
TestUP(ACTIVEWINDOWTRACKING)) {
01657
zzzActiveCursorTracking(pwnd);
01658 }
01659
goto Exit;
01660 }
01661
01662 }
else {
01663
01664
01665
01666
01667
01668
xxxSendMessage(pwnd, WM_NCACTIVATE,
01669
TRUE,
01670 (LPARAM)
HW(pwnd));
01671
xxxUpdateTray(pwnd);
01672
if (!(fFlags &
SFW_NOZORDER)) {
01673
xxxSetWindowPos(pwnd,
PWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
01674 }
01675 }
01676 }
01677
01678
01679 }
01680
01681
01682
01683
01684
01685 pqForegroundOld =
NULL;
01686
if (ptiForegroundOld && !(ptiForegroundOld->
TIF_flags &
TIF_INCLEANUP)) {
01687 pqForegroundOld = ptiForegroundOld->
pq;
01688 }
01689
01690 pqCurrent =
NULL;
01691
if (pti !=
NULL)
01692 pqCurrent = pti->
pq;
01693
01694
01695
01696
01697
01698
01699
if ((pqForegroundOld !=
NULL) && (pqForegroundOld == pqCurrent)) {
01700
xxxDeactivate(pti, (pwnd !=
NULL) ?
TIDq(
GETPTI(pwnd)) : 0);
01701 }
01702 Exit:
01703
ThreadUnlockPti(ptiCurrent, &tlpti);
01704
ThreadUnlockPti(ptiCurrent, &tlptiForegroundNew);
01705
ThreadUnlockPti(ptiCurrent, &tlptiForegroundOld);
01706 }
01707
01708
return retval;
01709 }
01710
01711
01712
01713
01714
01715
01716
01717 BOOL FRemoveForegroundActivate(
PTHREADINFO pti)
01718 {
01719
BOOL fRemoved;
01720
PPROCESSINFO ppi;
01721
01722
01723
01724
01725 ppi = pti->
ppi;
01726
if (ppi->W32PF_Flags & W32PF_APPSTARTING) {
01727
ClearAppStarting(ppi);
01728 }
01729
01730
01731
01732
01733 fRemoved = (pti->
TIF_flags &
TIF_ALLOWFOREGROUNDACTIVATE);
01734
if (fRemoved) {
01735 pti->
TIF_flags &= ~
TIF_ALLOWFOREGROUNDACTIVATE ;
01736 TAGMSG1(DBGTAG_FOREGROUND,
"FRemoveForegroundActivate clear TIF %#p", pti);
01737 }
else {
01738 fRemoved = (ppi->W32PF_Flags & W32PF_ALLOWFOREGROUNDACTIVATE);
01739 }
01740
if (fRemoved) {
01741 ppi->W32PF_Flags &= ~W32PF_ALLOWFOREGROUNDACTIVATE;
01742 TAGMSG1(DBGTAG_FOREGROUND,
"FRemoveForegroundActivate clear W32PF %#p", ppi);
01743 }
01744
01745
return fRemoved;
01746
01747 }
01748
01749
01750
01751
01752
01753
01754
01755
01756
01757
01758
01759
01760
01761 BOOL FAllowForegroundActivate(
01762
PQ pq,
01763
PWND pwnd)
01764 {
01765
PTHREADINFO ptiCurrent =
PtiCurrent();
01766 UserAssert(pwnd !=
NULL);
01767
01768
01769
01770 TAGMSG1(DBGTAG_FOREGROUND,
"FAllowForegroundActivate FRemoveForegroundActivate %#p", ptiCurrent);
01771
if (!
FRemoveForegroundActivate(ptiCurrent)) {
01772
return FALSE;
01773 }
01774
01775
01776
01777
01778
01779
01780
01781
01782
if ((ptiCurrent->
rpdesk !=
grpdeskRitInput)
01783 || (
gpqForeground == pq)
01784 ||
IsForegroundLocked()) {
01785 TAGMSG0(DBGTAG_FOREGROUND,
"FAllowForegroundActivate FALSE due to addtional checks");
01786
return FALSE;
01787 }
01788
01789
01790
01791
01792
01793
01794
01795
#if DBG
01796
if (
TestwndChild(pwnd)) {
01797 RIPMSG1(RIP_WARNING,
"FAllowForegroundActivate pwnd %#p is not top level", pwnd);
01798 }
01799
#endif
01800
if (
TestWF(pwnd,
WEFNOACTIVATE)) {
01801 TAGMSG1(DBGTAG_FOREGROUND,
"FAllowForegroundActivate noactivate window:%#p", pwnd);
01802
return FALSE;
01803 }
01804
01805
return TRUE;
01806 }
01807
01808
01809
01810
01811
01812
01813
01814
01815 PWND xxxSetFocus(
01816
PWND pwnd)
01817 {
01818 HWND hwndTemp;
01819
PTHREADINFO ptiCurrent =
PtiCurrent();
01820
PTHREADINFO ptiActiveKL;
01821
PWND pwndTemp =
NULL;
01822
TL tlpwndTemp;
01823
01824
CheckLock(pwnd);
01825
01826
01827
01828
if (pwnd ==
NULL) {
01829
if (
IsHooked(ptiCurrent,
WHF_CBT) &&
xxxCallHook(HCBT_SETFOCUS, 0,
01830 (LPARAM)
HW(ptiCurrent->
pq->
spwndFocus), WH_CBT)) {
01831
return NULL;
01832 }
01833
01834
01835
01836
01837 hwndTemp =
HW(ptiCurrent->
pq->
spwndFocus);
01838
xxxSendFocusMessages(ptiCurrent, pwnd);
01839
return RevalidateHwnd(hwndTemp);
01840 }
01841
01842
01843
01844
01845
if (
GETPTI(pwnd)->pq != ptiCurrent->
pq) {
01846
return NULL;
01847 }
01848
01849
01850
01851
01852
01853
for (pwndTemp = pwnd; pwndTemp !=
NULL; pwndTemp = pwndTemp->
spwndParent) {
01854
if (
TestWF(pwndTemp,
WFMINIMIZED) ||
TestWF(pwndTemp,
WFDISABLED)) {
01855
01856
01857
01858
01859
01860
return NULL;
01861 }
01862
01863
if (!
TestwndChild(pwndTemp)) {
01864
break;
01865 }
01866 }
01867 UserAssert(pwndTemp !=
NULL);
01868
01869
01870
01871
01872
ThreadLockWithPti(ptiCurrent, pwndTemp, &tlpwndTemp);
01873
if (pwnd != ptiCurrent->
pq->
spwndFocus) {
01874
if (
IsHooked(ptiCurrent,
WHF_CBT) &&
xxxCallHook(HCBT_SETFOCUS, (WPARAM)
HWq(pwnd),
01875 (LPARAM)
HW(ptiCurrent->
pq->
spwndFocus), WH_CBT)) {
01876
ThreadUnlock(&tlpwndTemp);
01877
return NULL;
01878 }
01879
01880
01881
01882
01883
01884
01885
01886
01887
01888
01889
01890
01891
if (pwndTemp != ptiCurrent->
pq->
spwndActive) {
01892
01893
01894
01895
01896
01897
if (ptiCurrent->
pq !=
gpqForeground &&
FAllowForegroundActivate(ptiCurrent->
pq, pwndTemp)) {
01898
01899
01900
01901
01902
01903
if (!
TestWF(pwndTemp,
WFVISIBLE)){
01904 ptiCurrent->
ppi->W32PF_Flags |= W32PF_ALLOWFOREGROUNDACTIVATE;
01905 }
01906
if (!
xxxSetForegroundWindow2(pwndTemp, ptiCurrent,
SFW_SETFOCUS)) {
01907
ThreadUnlock(&tlpwndTemp);
01908
return NULL;
01909 }
01910 }
01911
01912
01913
01914
01915
if (pwndTemp != ptiCurrent->
pq->
spwndActive) {
01916
if (!
xxxActivateThisWindow(pwndTemp, 0, 0)) {
01917
ThreadUnlock(&tlpwndTemp);
01918
return NULL;
01919 }
01920 }
01921 }
01922
01923
01924
01925
01926 pwndTemp = ptiCurrent->
pq->
spwndFocus;
01927
ThreadUnlock(&tlpwndTemp);
01928
ThreadLockWithPti(ptiCurrent, pwndTemp, &tlpwndTemp);
01929
01930
01931
01932
01933
01934
xxxSendFocusMessages(ptiCurrent, pwnd);
01935
01936 }
else {
01937 pwndTemp = ptiCurrent->
pq->
spwndFocus;
01938 }
01939
01940
if (ptiCurrent->
pq->
spwndFocus) {
01941
01942
01943
01944
01945
01946
01947
01948 ptiActiveKL =
GETPTI(ptiCurrent->
pq->
spwndFocus);
01949 }
else {
01950
01951
01952
01953 ptiActiveKL = ptiCurrent;
01954 }
01955 UserAssert(ptiActiveKL);
01956
01957
01958
01959
01960
01961
if (ptiActiveKL->
spklActive) {
01962 HKL hklActive = ptiActiveKL->
spklActive->
hkl;
01963
01964
if ((
gLCIDSentToShell != hklActive) &&
IsHooked(ptiCurrent,
WHF_SHELL)) {
01965
gLCIDSentToShell = hklActive;
01966
xxxCallHook(HSHELL_LANGUAGE, (WPARAM)
NULL, (LPARAM)hklActive, WH_SHELL);
01967 }
01968 }
01969
01970 hwndTemp =
HW(pwndTemp);
01971
ThreadUnlock(&tlpwndTemp);
01972
01973
01974
01975
01976
01977
01978
return RevalidateHwnd(hwndTemp);
01979 }
01980
01981
01982
01983
01984
01985
01986
01987
01988
01989
01990 PWND xxxSetActiveWindow(
01991
PWND pwnd)
01992 {
01993 HWND hwndActiveOld;
01994
PTHREADINFO pti;
01995
01996
CheckLock(pwnd);
01997
01998 pti =
PtiCurrent();
01999
02000
02001
02002
02003
02004
02005
if (!(pti->
TIF_flags &
TIF_16BIT) && (pwnd !=
NULL) && (
GETPTI(pwnd)->pq != pti->
pq)) {
02006
return NULL;
02007 }
02008
02009 hwndActiveOld =
HW(pti->
pq->
spwndActive);
02010
02011
xxxActivateWindow(pwnd,
AW_USE);
02012
02013
return RevalidateHwnd(hwndActiveOld);
02014 }
02015
02016
02017
02018
02019
02020
02021
02022
02023
02024
02025
02026
02027
02028
02029
02030
02031
02032
02033
02034
02035
02036
02037
02038
02039
02040
02041
02042
02043
02044
02045
02046
02047
02048
02049
02050
02051
02052
02053
02054
02055
02056
02057
02058
02059
02060 BOOL xxxActivateWindow(
02061
PWND pwnd,
02062 UINT cmd)
02063 {
02064
DWORD fFlags =
ATW_SETFOCUS;
02065
PTHREADINFO ptiCurrent =
PtiCurrent();
02066
TL tlpwnd;
02067
BOOL fSuccess;
02068
BOOL fAllowForeground, fSetForegroundRight;
02069
02070
CheckLock(pwnd);
02071
02072
02073
if (pwnd !=
NULL) {
02074
02075
02076
02077
02078
02079
if (
TestwndChild(pwnd))
02080
return FALSE;
02081
02082 }
else {
02083 cmd =
AW_SKIP2;
02084 }
02085
02086
switch (cmd) {
02087
02088
case AW_TRY2:
02089 fFlags |=
ATW_MOUSE;
02090
02091
02092
02093
02094
case AW_TRY:
02095
02096
02097
02098
02099
if (!
FBadWindow(pwnd)) {
02100
break;
02101 }
02102
02103
02104
02105
02106
case AW_SKIP:
02107
02108
02109
02110
02111
if (
TestwndPopup(pwnd) && !
FBadWindow(pwnd->
spwndOwner)) {
02112 pwnd = pwnd->
spwndOwner;
02113
break;
02114 }
02115
02116
02117
02118
02119
02120
case AW_SKIP2:
02121
02122
02123
02124
02125
if ((
gpqForegroundPrev !=
NULL)
02126 && !
FBadWindow(
gpqForegroundPrev->
spwndActivePrev)
02127
02128
02129
02130
02131
02132
02133 && !
TestWF(
gpqForegroundPrev->
spwndActivePrev,
WFBOTTOMMOST)) {
02134
02135 pwnd =
gpqForegroundPrev->
spwndActivePrev;
02136
break;
02137 }
02138
02139 {
02140
PWND pwndSave = pwnd;
02141
DWORD flags =
NTW_IGNORETOOLWINDOW;
02142
02143 TryAgain:
02144
02145
02146
02147
02148 pwnd =
NextTopWindow(ptiCurrent, pwndSave, (cmd ==
AW_SKIP ? pwndSave :
NULL),
02149 flags);
02150
02151
if (pwnd) {
02152
if (!
FBadWindow(pwnd->
spwndLastActive))
02153 pwnd = pwnd->
spwndLastActive;
02154 }
else {
02155
if (flags ==
NTW_IGNORETOOLWINDOW) {
02156 flags = 0;
02157
goto TryAgain;
02158 }
02159 }
02160 }
02161
02162
02163
case AW_USE:
02164
break;
02165
02166
case AW_USE2:
02167 fFlags |=
ATW_MOUSE;
02168
break;
02169
02170
default:
02171
return FALSE;
02172 }
02173
02174
if (pwnd ==
NULL)
02175
return FALSE;
02176
02177
ThreadLockAlwaysWithPti(ptiCurrent, pwnd, &tlpwnd);
02178
02179
if (
GETPTI(pwnd)->pq == ptiCurrent->
pq) {
02180
02181
02182
02183
02184
02185
02186
02187
02188
02189
02190
02191
02192
02193
02194
02195
02196
02197
02198
02199
02200
02201
02202
02203
02204
if (!
FAllowForegroundActivate(ptiCurrent->
pq, pwnd)) {
02205 fSuccess =
xxxActivateThisWindow(pwnd, 0, fFlags);
02206
ThreadUnlock(&tlpwnd);
02207
return fSuccess;
02208 }
02209
02210 fAllowForeground =
TRUE;
02211
02212
02213
02214
02215
02216 fSetForegroundRight = (ptiCurrent->
cVisWindows == 0);
02217
02218 }
else {
02219
02220
02221
02222
02223 fAllowForeground = (
gpqForeground == ptiCurrent->
pq)
02224 || (
gpqForeground ==
NULL);
02225
02226
02227
02228
02229
02230
02231
02232
02233
02234
02235
02236
if (fAllowForeground) {
02237 fSetForegroundRight = ((ptiCurrent->
TIF_flags &
TIF_ALLOWFOREGROUNDACTIVATE)
02238 || (ptiCurrent->
cVisWindows != 0)
02239 || (cmd ==
AW_USE));
02240 }
else {
02241 fSetForegroundRight =
FALSE;
02242 }
02243 }
02244
02245 fSuccess =
FALSE;
02246
if (fAllowForeground) {
02247
02248
02249
02250
02251 ptiCurrent->
TIF_flags |=
TIF_ALLOWFOREGROUNDACTIVATE;
02252 TAGMSG1(DBGTAG_FOREGROUND,
"xxxActivateWindow temporarly set TIF %#p", ptiCurrent);
02253 fSuccess =
xxxSetForegroundWindow(pwnd, (cmd ==
AW_USE));
02254
02255
if (fSetForegroundRight) {
02256
02257
02258
02259
02260
02261
02262
02263
02264
02265
02266
02267
02268
02269
02270
02271
02272
02273 ptiCurrent->
TIF_flags |=
TIF_ALLOWFOREGROUNDACTIVATE;
02274 TAGMSG1(DBGTAG_FOREGROUND,
"xxxActivateWindow set TIF %#p", ptiCurrent);
02275 }
else {
02276
02277
02278
02279 ptiCurrent->
TIF_flags &= ~
TIF_ALLOWFOREGROUNDACTIVATE;
02280 TAGMSG1(DBGTAG_FOREGROUND,
"xxxActivateWindow clear TIF %#p", ptiCurrent);
02281 }
02282 }
02283
02284
ThreadUnlock(&tlpwnd);
02285
return fSuccess;
02286 }
02287
02288
02289
02290
02291
02292
02293
02294
02295
02296
02297
02298
02299
02300 PWND GNT_NextTopScan(
02301
PTHREADINFO pti,
02302
PWND pwnd,
02303
PWND pwndOwner)
02304 {
02305
if (pwnd ==
NULL) {
02306 UserAssert(pti->
rpdesk !=
NULL &&
02307 (pti->
rpdesk->
dwDTFlags &
DF_DESKWNDDESTROYED) == 0);
02308 pwnd = pti->
rpdesk->
pDeskInfo->
spwnd->
spwndChild;
02309 }
else {
02310 pwnd = pwnd->
spwndNext;
02311 }
02312
02313
for (; pwnd !=
NULL; pwnd = pwnd->
spwndNext) {
02314
if (pwnd->
spwndOwner == pwndOwner)
02315
break;
02316 }
02317
02318
return pwnd;
02319 }
02320
02321
02322
02323
02324
02325
02326
02327
02328
02329
02330
02331
02332 PWND NTW_GetNextTop(
02333
PTHREADINFO pti,
02334
PWND pwnd)
02335 {
02336
PWND pwndOwner;
02337
02338
if (pwnd ==
NULL) {
02339
goto ReturnFirst;
02340 }
02341
02342
02343
02344
02345
02346
02347
02348
02349 pwndOwner = pwnd;
02350 pwnd =
NULL;
02351
02352
do {
02353
if ((pwnd =
GNT_NextTopScan(pti, pwnd, pwndOwner)) !=
NULL) {
02354
return pwnd;
02355 }
02356
02357 pwnd = pwndOwner;
02358
if (pwnd !=
NULL)
02359 pwndOwner = pwnd->
spwndOwner;
02360
02361 }
while (pwnd !=
NULL);
02362
02363 ReturnFirst:
02364
02365
02366
02367
02368
return GNT_NextTopScan(pti,
NULL,
NULL);
02369 }
02370
02371
02372
02373
02374
02375
02376
02377
02378
02379
02380
02381
02382 PWND NTW_GetPrevTop(
02383
PTHREADINFO pti,
02384
PWND pwndCurrent)
02385 {
02386
PWND pwnd;
02387
PWND pwndPrev;
02388
02389
02390
02391
02392
02393 pwndPrev =
NULL;
02394
02395
do {
02396 pwnd =
NTW_GetNextTop(pti, pwndPrev);
02397
if (pwnd == pwndCurrent && pwndPrev !=
NULL) {
02398
break;
02399 }
02400 }
while ((pwndPrev = pwnd) !=
NULL);
02401
02402
return pwndPrev;
02403 }
02404
02405
02406
02407
02408
02409
02410
02411
02412
02413
02414
02415
02416 PWND CheckTopLevelOnly(
02417
PWND pwnd)
02418 {
02419
02420
02421
02422
02423
while (pwnd !=
NULL &&
GETFNID(pwnd) ==
FNID_DESKTOP) {
02424 pwnd = pwnd->
spwndChild;
02425 }
02426
02427
return pwnd;
02428 }
02429
02430
02431 PWND NextTopWindow(
02432
PTHREADINFO pti,
02433
PWND pwnd,
02434
PWND pwndSkip,
02435 DWORD flags )
02436 {
02437
BOOL fFoundFirstUnowned;
02438
PWND pwndPrev;
02439
PWND pwndStart = pwnd;
02440
PWND pwndFirstUnowned;
02441
02442
02443
02444
02445
02446 pwndFirstUnowned =
GNT_NextTopScan(pti,
NULL,
NULL);
02447 fFoundFirstUnowned =
FALSE;
02448
02449
if (pwnd ==
NULL) {
02450 pwnd =
NTW_GetNextTop(pti,
NULL);
02451
02452
02453
02454
02455 pwnd = pwndStart =
CheckTopLevelOnly(pwnd);
02456
02457
if (pwnd ==
NULL)
02458
return NULL;
02459
02460
goto Loop;
02461 }
02462
02463
02464
02465
02466 pwnd = pwndStart =
CheckTopLevelOnly(pwnd);
02467
if (pwnd ==
NULL)
02468
return NULL;
02469
02470
02471
02472
02473 pwndSkip =
CheckTopLevelOnly(pwndSkip);
02474
02475
02476
02477
while (
TRUE) {
02478 pwndPrev = pwnd;
02479 pwnd = ((flags &
NTW_PREVIOUS) ?
NTW_GetPrevTop(pti, pwnd) :
NTW_GetNextTop(pti, pwnd));
02480
02481
02482
02483
02484
if (pwnd == pwndStart)
02485
break;
02486
02487
if (pwnd == pwndFirstUnowned) {
02488
if (fFoundFirstUnowned) {
02489
break;
02490 }
else {
02491 fFoundFirstUnowned =
TRUE;
02492 }
02493 }
02494
02495
if (pwnd ==
NULL)
02496
break;
02497
02498
02499
02500
02501
02502
if (
PWNDDESKTOP(pwndStart) !=
PWNDDESKTOP(pwnd))
02503
break;
02504
02505
02506
02507
02508
if (pwndPrev == pwnd) {
02509
02510
02511
02512
02513
02514
02515
02516
break;
02517 }
02518
02519 Loop:
02520
if (pwnd == pwndSkip)
02521
continue;
02522
02523
02524
02525
02526
02527
02528
if (
TestWF(pwnd,
WFVISIBLE) &&
02529 !
TestWF(pwnd,
WFDISABLED) &&
02530 !
TestWF(pwnd,
WEFNOACTIVATE) &&
02531 (!(flags &
NTW_IGNORETOOLWINDOW) || !
TestWF(pwnd,
WEFTOOLWINDOW))) {
02532
02533
return pwnd;
02534 }
02535 }
02536
02537
return NULL;
02538 }
02539
02540
02541
02542
02543
02544
02545
02546
02547
02548
02549 void xxxCheckFocus(
02550
PWND pwnd)
02551 {
02552
TL tlpwndParent;
02553
PTHREADINFO pti;
02554
02555
CheckLock(pwnd);
02556
02557 pti =
PtiCurrent();
02558
02559
if (pwnd == pti->
pq->
spwndFocus) {
02560
02561
02562
02563
02564
if (
TestwndChild(pwnd)) {
02565
ThreadLockWithPti(pti, pwnd->
spwndParent, &tlpwndParent);
02566
xxxSetFocus(pwnd->
spwndParent);
02567
ThreadUnlock(&tlpwndParent);
02568 }
else {
02569
xxxSetFocus(
NULL);
02570 }
02571 }
02572
02573
if (pwnd == pti->
pq->
caret.
spwnd) {
02574
zzzDestroyCaret();
02575 }
02576 }
02577
02578
02579
02580
02581
02582
02583
02584
02585
02586
02587
02588 VOID SetForegroundThread(
02589
PTHREADINFO pti)
02590 {
02591
PKL pklPrev;
02592
02593
if (pti ==
gptiForeground)
02594
return;
02595
02596
02597
02598
02599
02600
02601
02602
02603 UserAssert((pti ==
NULL)
02604 || (pti->
pq ==
gpqForeground)
02605 || (pti ==
gptiRit));
02606
02607
02608
02609
02610
02611
02612
02613
02614
if ((pti ==
NULL) || (
gptiForeground ==
NULL) ||
02615 (pti->
ppi !=
gptiForeground->
ppi)) {
02616
if (
gptiForeground !=
NULL) {
02617
gptiForeground->
ppi->W32PF_Flags &= ~W32PF_FORCEBACKGROUNDPRIORITY;
02618
SetForegroundPriority(
gptiForeground,
FALSE);
02619 }
02620
02621
if (pti !=
NULL) {
02622
SetForegroundPriority(pti,
TRUE);
02623 }
02624 }
02625
02626
if (
gptiForeground) {
02627 pklPrev =
gptiForeground->
spklActive;
02628 }
else {
02629 pklPrev =
NULL;
02630 }
02631
gptiForeground = pti;
02632
if (
gptiForeground &&
gptiForeground->
spklActive) {
02633
ChangeForegroundKeyboardTable(pklPrev,
gptiForeground->
spklActive);
02634 }
02635
02636
02637
02638
02639
02640 RtlZeroMemory(
gafAsyncKeyStateRecentDown,
CBKEYSTATERECENTDOWN);
02641
02642
02643
02644
02645
gpsi->dwAsyncKeyCache++;
02646 }
02647
02648 VOID SetForegroundPriorityProcess(
02649
PPROCESSINFO ppi,
02650
PTHREADINFO pti,
02651 BOOL fSetForeground)
02652 {
02653
PEPROCESS Process;
02654 UCHAR PriorityClassSave;
02655
02656 UserAssert(ppi !=
NULL);
02657
02658 Process = ppi->Process;
02659 UserAssert(ppi->Process !=
NULL);
02660
02661
if (ppi->W32PF_Flags & W32PF_IDLESCREENSAVER) {
02662 fSetForeground =
FALSE;
02663 PriorityClassSave = Process->
PriorityClass;
02664 Process->
PriorityClass = PROCESS_PRIORITY_CLASS_IDLE;
02665 }
02666
02667
02668
02669
02670
02671
if (
gppiForegroundOld !=
NULL) {
02672
if (
gppiForegroundOld == ppi) {
02673
gppiForegroundOld =
NULL;
02674 }
else if (ppi !=
gppiScreenSaver) {
02675
PsSetProcessPriorityByClass(
gppiForegroundOld->Process,
PsProcessPriorityBackground);
02676
gppiForegroundOld =
NULL;
02677 }
02678 }
02679
02680
02681
02682
02683
02684
if (ppi->W32PF_Flags & W32PF_FORCEBACKGROUNDPRIORITY) {
02685
if (pti !=
NULL && !(pti->
TIF_flags &
TIF_GLOBALHOOKER)) {
02686
PsSetProcessPriorityByClass(Process,
PsProcessPrioritySpinning);
02687 }
02688 }
else if (fSetForeground) {
02689
PsSetProcessPriorityByClass(Process,
PsProcessPriorityForeground);
02690 }
else if (pti !=
NULL && !(pti->
TIF_flags &
TIF_GLOBALHOOKER)) {
02691
02692
02693
02694
02695
if (
gppiScreenSaver &&
gppiScreenSaver != ppi) {
02696
gppiForegroundOld = ppi;
02697 }
else {
02698
PsSetProcessPriorityByClass(Process,
PsProcessPriorityBackground);
02699 }
02700 }
02701
02702
if (ppi->W32PF_Flags & W32PF_IDLESCREENSAVER) {
02703 Process->
PriorityClass = PriorityClassSave;
02704 }
02705 }
02706
02707
02708 VOID SetForegroundPriority(
02709
PTHREADINFO pti,
02710 BOOL fSetForeground)
02711 {
02712 UserAssert(pti !=
NULL);
02713
02714
02715
02716
02717
if (pti->
TIF_flags & (
TIF_SYSTEMTHREAD |
TIF_CSRSSTHREAD))
02718
return;
02719
02720
SetForegroundPriorityProcess(pti->
ppi, pti, fSetForeground);
02721 }