Moved implementation of EnumDisplaySettings from ASCII to Unicode.
[wine] / windows / dce.c
1 /*
2  * USER DCE functions
3  *
4  * Copyright 1993 Alexandre Julliard
5  *           1996,1997 Alex Korobka
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  *
21  *
22  * Note: Visible regions of CS_OWNDC/CS_CLASSDC window DCs
23  * have to be updated dynamically.
24  *
25  * Internal DCX flags:
26  *
27  * DCX_DCEEMPTY    - dce is uninitialized
28  * DCX_DCEBUSY     - dce is in use
29  * DCX_DCEDIRTY    - ReleaseDC() should wipe instead of caching
30  * DCX_KEEPCLIPRGN - ReleaseDC() should not delete the clipping region
31  * DCX_WINDOWPAINT - BeginPaint() is in effect
32  */
33
34 #include <assert.h>
35 #include "dce.h"
36 #include "win.h"
37 #include "gdi.h"
38 #include "user.h"
39 #include "wine/debug.h"
40 #include "windef.h"
41 #include "wingdi.h"
42 #include "wine/winbase16.h"
43 #include "wine/winuser16.h"
44
45 WINE_DEFAULT_DEBUG_CHANNEL(dc);
46
47 static DCE *firstDCE;
48 static HDC defaultDCstate;
49
50 static void DCE_DeleteClipRgn( DCE* );
51 static INT DCE_ReleaseDC( DCE* );
52
53
54 /***********************************************************************
55  *           DCE_DumpCache
56  */
57 static void DCE_DumpCache(void)
58 {
59     DCE *dce;
60
61     USER_Lock();
62     dce = firstDCE;
63
64     DPRINTF("DCE:\n");
65     while( dce )
66     {
67         DPRINTF("\t[0x%08x] hWnd 0x%04x, dcx %08x, %s %s\n",
68              (unsigned)dce, dce->hwndCurrent, (unsigned)dce->DCXflags,
69              (dce->DCXflags & DCX_CACHE) ? "Cache" : "Owned",
70              (dce->DCXflags & DCX_DCEBUSY) ? "InUse" : "" );
71         dce = dce->next;
72     }
73
74     USER_Unlock();
75 }
76
77 /***********************************************************************
78  *           DCE_AllocDCE
79  *
80  * Allocate a new DCE.
81  */
82 DCE *DCE_AllocDCE( HWND hWnd, DCE_TYPE type )
83 {
84     DCE * dce;
85
86     if (!(dce = HeapAlloc( GetProcessHeap(), 0, sizeof(DCE) ))) return NULL;
87     if (!(dce->hDC = CreateDCA( "DISPLAY", NULL, NULL, NULL )))
88     {
89         HeapFree( GetProcessHeap(), 0, dce );
90         return 0;
91     }
92     if (!defaultDCstate) defaultDCstate = GetDCState16( dce->hDC );
93
94     /* store DCE handle in DC hook data field */
95
96     SetDCHook( dce->hDC, DCHook16, (DWORD)dce );
97
98     dce->hwndCurrent = WIN_GetFullHandle( hWnd );
99     dce->hClipRgn    = 0;
100
101     if( type != DCE_CACHE_DC ) /* owned or class DC */
102     {
103         dce->DCXflags = DCX_DCEBUSY;
104         if( hWnd )
105         {
106             LONG style = GetWindowLongW( hWnd, GWL_STYLE );
107             if (style & WS_CLIPCHILDREN) dce->DCXflags |= DCX_CLIPCHILDREN;
108             if (style & WS_CLIPSIBLINGS) dce->DCXflags |= DCX_CLIPSIBLINGS;
109         }
110         SetHookFlags16(dce->hDC,DCHF_INVALIDATEVISRGN);
111     }
112     else dce->DCXflags = DCX_CACHE | DCX_DCEEMPTY;
113
114     USER_Lock();
115     dce->next = firstDCE;
116     firstDCE = dce;
117     USER_Unlock();
118     return dce;
119 }
120
121
122 /***********************************************************************
123  *           DCE_FreeDCE
124  */
125 DCE* DCE_FreeDCE( DCE *dce )
126 {
127     DCE **ppDCE, *ret;
128
129     if (!dce) return NULL;
130
131     USER_Lock();
132
133     ppDCE = &firstDCE;
134
135     while (*ppDCE && (*ppDCE != dce)) ppDCE = &(*ppDCE)->next;
136     if (*ppDCE == dce) *ppDCE = dce->next;
137     ret = *ppDCE;
138     USER_Unlock();
139
140     SetDCHook(dce->hDC, NULL, 0L);
141
142     DeleteDC( dce->hDC );
143     if( dce->hClipRgn && !(dce->DCXflags & DCX_KEEPCLIPRGN) )
144         DeleteObject(dce->hClipRgn);
145     HeapFree( GetProcessHeap(), 0, dce );
146
147     return ret;
148 }
149
150 /***********************************************************************
151  *           DCE_FreeWindowDCE
152  *
153  * Remove owned DCE and reset unreleased cache DCEs.
154  */
155 void DCE_FreeWindowDCE( HWND hwnd )
156 {
157     DCE *pDCE;
158     WND *pWnd = WIN_GetPtr( hwnd );
159
160     pDCE = firstDCE;
161     while( pDCE )
162     {
163         if( pDCE->hwndCurrent == hwnd )
164         {
165             if( pDCE == pWnd->dce ) /* owned or Class DCE*/
166             {
167                 if (pWnd->clsStyle & CS_OWNDC)  /* owned DCE*/
168                 {
169                     pDCE = DCE_FreeDCE( pDCE );
170                     pWnd->dce = NULL;
171                     continue;
172                 }
173                 else if( pDCE->DCXflags & (DCX_INTERSECTRGN | DCX_EXCLUDERGN) ) /* Class DCE*/
174                 {
175                     if (USER_Driver.pReleaseDC)
176                         USER_Driver.pReleaseDC( pDCE->hwndCurrent, pDCE->hDC );
177                     DCE_DeleteClipRgn( pDCE );
178                     pDCE->hwndCurrent = 0;
179                 }
180             }
181             else
182             {
183                 if( pDCE->DCXflags & DCX_DCEBUSY ) /* shared cache DCE */
184                 {
185                     /* FIXME: AFAICS we are doing the right thing here so
186                      * this should be a WARN. But this is best left as an ERR
187                      * because the 'application error' is likely to come from
188                      * another part of Wine (i.e. it's our fault after all).
189                      * We should change this to WARN when Wine is more stable
190                      * (for 1.0?).
191                      */
192                     ERR("[%08x] GetDC() without ReleaseDC()!\n",hwnd);
193                     DCE_ReleaseDC( pDCE );
194                 }
195
196                 if (pDCE->hwndCurrent && USER_Driver.pReleaseDC)
197                     USER_Driver.pReleaseDC( pDCE->hwndCurrent, pDCE->hDC );
198                 pDCE->DCXflags &= DCX_CACHE;
199                 pDCE->DCXflags |= DCX_DCEEMPTY;
200                 pDCE->hwndCurrent = 0;
201             }
202         }
203         pDCE = pDCE->next;
204     }
205     WIN_ReleasePtr( pWnd );
206 }
207
208
209 /***********************************************************************
210  *   DCE_DeleteClipRgn
211  */
212 static void DCE_DeleteClipRgn( DCE* dce )
213 {
214     dce->DCXflags &= ~(DCX_EXCLUDERGN | DCX_INTERSECTRGN | DCX_WINDOWPAINT);
215
216     if( dce->DCXflags & DCX_KEEPCLIPRGN )
217         dce->DCXflags &= ~DCX_KEEPCLIPRGN;
218     else
219         if( dce->hClipRgn > 1 )
220             DeleteObject( dce->hClipRgn );
221
222     dce->hClipRgn = 0;
223
224     /* make it dirty so that the vis rgn gets recomputed next time */
225     dce->DCXflags |= DCX_DCEDIRTY;
226     SetHookFlags16( dce->hDC, DCHF_INVALIDATEVISRGN );
227 }
228
229
230 /***********************************************************************
231  *   DCE_ReleaseDC
232  */
233 static INT DCE_ReleaseDC( DCE* dce )
234 {
235     if ((dce->DCXflags & (DCX_DCEEMPTY | DCX_DCEBUSY)) != DCX_DCEBUSY) return 0;
236
237     /* restore previous visible region */
238
239     if ((dce->DCXflags & (DCX_INTERSECTRGN | DCX_EXCLUDERGN)) &&
240         (dce->DCXflags & (DCX_CACHE | DCX_WINDOWPAINT)) )
241         DCE_DeleteClipRgn( dce );
242
243     if (dce->DCXflags & DCX_CACHE)
244     {
245         /* make the DC clean so that SetDCState doesn't try to update the vis rgn */
246         SetHookFlags16( dce->hDC, DCHF_VALIDATEVISRGN );
247         SetDCState16( dce->hDC, defaultDCstate );
248         dce->DCXflags &= ~DCX_DCEBUSY;
249         if (dce->DCXflags & DCX_DCEDIRTY)
250         {
251             /* don't keep around invalidated entries
252              * because SetDCState() disables hVisRgn updates
253              * by removing dirty bit. */
254             if (dce->hwndCurrent && USER_Driver.pReleaseDC)
255                 USER_Driver.pReleaseDC( dce->hwndCurrent, dce->hDC );
256             dce->hwndCurrent = 0;
257             dce->DCXflags &= DCX_CACHE;
258             dce->DCXflags |= DCX_DCEEMPTY;
259         }
260     }
261     return 1;
262 }
263
264
265 /***********************************************************************
266  *   DCE_InvalidateDCE
267  *
268  * It is called from SetWindowPos() and EVENT_MapNotify - we have to
269  * mark as dirty all busy DCEs for windows that have pWnd->parent as
270  * an ancestor and whose client rect intersects with specified update
271  * rectangle. In addition, pWnd->parent DCEs may need to be updated if
272  * DCX_CLIPCHILDREN flag is set.  */
273 BOOL DCE_InvalidateDCE(HWND hwnd, const RECT* pRectUpdate)
274 {
275     HWND hwndScope = GetAncestor( hwnd, GA_PARENT );
276     BOOL bRet = FALSE;
277
278     if( hwndScope )
279     {
280         DCE *dce;
281
282         TRACE("scope hwnd = %04x, (%i,%i - %i,%i)\n",
283                      hwndScope, pRectUpdate->left,pRectUpdate->top,
284                      pRectUpdate->right,pRectUpdate->bottom);
285         if(TRACE_ON(dc))
286           DCE_DumpCache();
287
288         /* walk all DCEs and fixup non-empty entries */
289
290         for (dce = firstDCE; (dce); dce = dce->next)
291         {
292             if (dce->DCXflags & DCX_DCEEMPTY) continue;
293             if ((dce->hwndCurrent == hwndScope) && !(dce->DCXflags & DCX_CLIPCHILDREN))
294                 continue;  /* child window positions don't bother us */
295
296             /* check if DCE window is within the z-order scope */
297
298             if (hwndScope == dce->hwndCurrent || IsChild( hwndScope, dce->hwndCurrent ))
299             {
300                 if (hwnd != dce->hwndCurrent)
301                 {
302                     /* check if the window rectangle intersects this DCE window */
303                     RECT rect;
304                     GetWindowRect( dce->hwndCurrent, &rect );
305                     MapWindowPoints( 0, hwndScope, (POINT *)&rect, 2 );
306                     if (!IntersectRect( &rect, &rect, pRectUpdate )) continue;
307
308                 }
309                 if( !(dce->DCXflags & DCX_DCEBUSY) )
310                 {
311                     /* Don't bother with visible regions of unused DCEs */
312
313                     TRACE("\tpurged %p dce [%04x]\n", dce, dce->hwndCurrent);
314                     if (dce->hwndCurrent && USER_Driver.pReleaseDC)
315                         USER_Driver.pReleaseDC( dce->hwndCurrent, dce->hDC );
316                     dce->hwndCurrent = 0;
317                     dce->DCXflags &= DCX_CACHE;
318                     dce->DCXflags |= DCX_DCEEMPTY;
319                 }
320                 else
321                 {
322                     /* Set dirty bits in the hDC and DCE structs */
323
324                     TRACE("\tfixed up %p dce [%04x]\n", dce, dce->hwndCurrent);
325                     dce->DCXflags |= DCX_DCEDIRTY;
326                     SetHookFlags16(dce->hDC, DCHF_INVALIDATEVISRGN);
327                     bRet = TRUE;
328                 }
329             }
330         } /* dce list */
331     }
332     return bRet;
333 }
334
335
336 /***********************************************************************
337  *           DCE_ExcludeRgn
338  *
339  *  Translate given region from the wnd client to the DC coordinates
340  *  and add it to the clipping region.
341  */
342 INT DCE_ExcludeRgn( HDC hDC, HWND hwnd, HRGN hRgn )
343 {
344   POINT  pt = {0, 0};
345   DCE     *dce = firstDCE;
346
347   while (dce && (dce->hDC != hDC)) dce = dce->next;
348   if (!dce) return ERROR;
349
350   MapWindowPoints( hwnd, dce->hwndCurrent, &pt, 1);
351   if( dce->DCXflags & DCX_WINDOW )
352   {
353       WND *wnd = WIN_FindWndPtr(dce->hwndCurrent);
354       pt.x += wnd->rectClient.left - wnd->rectWindow.left;
355       pt.y += wnd->rectClient.top - wnd->rectWindow.top;
356       WIN_ReleaseWndPtr(wnd);
357   }
358   OffsetRgn(hRgn, pt.x, pt.y);
359
360   return ExtSelectClipRgn( hDC, hRgn, RGN_DIFF );
361 }
362
363
364 /***********************************************************************
365  *              GetDCEx (USER32.@)
366  *
367  * Unimplemented flags: DCX_LOCKWINDOWUPDATE
368  *
369  * FIXME: Full support for hrgnClip == 1 (alias for entire window).
370  */
371 HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags )
372 {
373     HDC         hdc = 0;
374     DCE *       dce;
375     WND *       wndPtr;
376     DWORD       dcxFlags = 0;
377     BOOL        bUpdateVisRgn = TRUE;
378     BOOL        bUpdateClipOrigin = FALSE;
379     HWND parent, full;
380
381     TRACE("hwnd %04x, hrgnClip %04x, flags %08x\n",
382           hwnd, hrgnClip, (unsigned)flags);
383
384     if (!hwnd) hwnd = GetDesktopWindow();
385     if (!(full = WIN_IsCurrentProcess( hwnd )))
386     {
387         FIXME( "not supported yet on other process window %x\n", hwnd );
388         return 0;
389     }
390     hwnd = full;
391     if (!(wndPtr = WIN_GetPtr( hwnd ))) return 0;
392
393     /* fixup flags */
394
395     if (flags & (DCX_WINDOW | DCX_PARENTCLIP)) flags |= DCX_CACHE;
396
397     if (flags & DCX_USESTYLE)
398     {
399         flags &= ~( DCX_CLIPCHILDREN | DCX_CLIPSIBLINGS | DCX_PARENTCLIP);
400
401         if( wndPtr->dwStyle & WS_CLIPSIBLINGS )
402             flags |= DCX_CLIPSIBLINGS;
403
404         if ( !(flags & DCX_WINDOW) )
405         {
406             if (wndPtr->clsStyle & CS_PARENTDC) flags |= DCX_PARENTCLIP;
407
408             if (wndPtr->dwStyle & WS_CLIPCHILDREN &&
409                      !(wndPtr->dwStyle & WS_MINIMIZE) ) flags |= DCX_CLIPCHILDREN;
410             if (!wndPtr->dce) flags |= DCX_CACHE;
411         }
412     }
413
414     if (flags & DCX_WINDOW) flags &= ~DCX_CLIPCHILDREN;
415
416     parent = GetAncestor( hwnd, GA_PARENT );
417     if (!parent || (parent == GetDesktopWindow()))
418         flags = (flags & ~DCX_PARENTCLIP) | DCX_CLIPSIBLINGS;
419
420     /* it seems parent clip is ignored when clipping siblings or children */
421     if (flags & (DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN)) flags &= ~DCX_PARENTCLIP;
422
423     if( flags & DCX_PARENTCLIP )
424     {
425         LONG parent_style = GetWindowLongW( parent, GWL_STYLE );
426         if( (wndPtr->dwStyle & WS_VISIBLE) && (parent_style & WS_VISIBLE) )
427         {
428             flags &= ~DCX_CLIPCHILDREN;
429             if (parent_style & WS_CLIPSIBLINGS) flags |= DCX_CLIPSIBLINGS;
430         }
431     }
432
433     /* find a suitable DCE */
434
435     dcxFlags = flags & (DCX_PARENTCLIP | DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN |
436                         DCX_CACHE | DCX_WINDOW);
437
438     if (flags & DCX_CACHE)
439     {
440         DCE*    dceEmpty;
441         DCE*    dceUnused;
442
443         dceEmpty = dceUnused = NULL;
444
445         /* Strategy: First, we attempt to find a non-empty but unused DCE with
446          * compatible flags. Next, we look for an empty entry. If the cache is
447          * full we have to purge one of the unused entries.
448          */
449
450         for (dce = firstDCE; (dce); dce = dce->next)
451         {
452             if ((dce->DCXflags & (DCX_CACHE | DCX_DCEBUSY)) == DCX_CACHE )
453             {
454                 dceUnused = dce;
455
456                 if (dce->DCXflags & DCX_DCEEMPTY)
457                     dceEmpty = dce;
458                 else
459                 if ((dce->hwndCurrent == hwnd) &&
460                    ((dce->DCXflags & (DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN |
461                                       DCX_CACHE | DCX_WINDOW | DCX_PARENTCLIP)) == dcxFlags))
462                 {
463                     TRACE("\tfound valid %08x dce [%04x], flags %08x\n",
464                                         (unsigned)dce, hwnd, (unsigned)dcxFlags );
465                     bUpdateVisRgn = FALSE;
466                     bUpdateClipOrigin = TRUE;
467                     break;
468                 }
469             }
470         }
471
472         if (!dce) dce = (dceEmpty) ? dceEmpty : dceUnused;
473
474         /* if there's no dce empty or unused, allocate a new one */
475         if (!dce)
476         {
477             dce = DCE_AllocDCE( 0, DCE_CACHE_DC );
478         }
479     }
480     else
481     {
482         dce = wndPtr->dce;
483         if (dce && dce->hwndCurrent == hwnd)
484         {
485             TRACE("\tskipping hVisRgn update\n");
486             bUpdateVisRgn = FALSE; /* updated automatically, via DCHook() */
487         }
488     }
489     if (!dce)
490     {
491         hdc = 0;
492         goto END;
493     }
494
495     if (!(flags & (DCX_INTERSECTRGN | DCX_EXCLUDERGN))) hrgnClip = 0;
496
497     if (((flags ^ dce->DCXflags) & (DCX_INTERSECTRGN | DCX_EXCLUDERGN)) &&
498         (dce->hClipRgn != hrgnClip))
499     {
500         /* if the extra clip region has changed, get rid of the old one */
501         DCE_DeleteClipRgn( dce );
502     }
503
504     dce->hwndCurrent = hwnd;
505     dce->hClipRgn = hrgnClip;
506     dce->DCXflags = flags & (DCX_PARENTCLIP | DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN |
507                              DCX_CACHE | DCX_WINDOW | DCX_WINDOWPAINT |
508                              DCX_KEEPCLIPRGN | DCX_INTERSECTRGN | DCX_EXCLUDERGN);
509     dce->DCXflags |= DCX_DCEBUSY;
510     dce->DCXflags &= ~DCX_DCEDIRTY;
511     hdc = dce->hDC;
512
513     if (bUpdateVisRgn) SetHookFlags16( hdc, DCHF_INVALIDATEVISRGN ); /* force update */
514
515     if (!USER_Driver.pGetDC( hwnd, hdc, hrgnClip, flags )) hdc = 0;
516
517     TRACE("(%04x,%04x,0x%lx): returning %04x\n", hwnd, hrgnClip, flags, hdc);
518 END:
519     WIN_ReleasePtr(wndPtr);
520     return hdc;
521 }
522
523
524 /***********************************************************************
525  *              GetDC (USER32.@)
526  * RETURNS
527  *      :Handle to DC
528  *      NULL: Failure
529  */
530 HDC WINAPI GetDC(
531              HWND hwnd /* [in] handle of window */
532 ) {
533     if (!hwnd)
534         return GetDCEx( 0, 0, DCX_CACHE | DCX_WINDOW );
535     return GetDCEx( hwnd, 0, DCX_USESTYLE );
536 }
537
538
539 /***********************************************************************
540  *              GetWindowDC (USER32.@)
541  */
542 HDC WINAPI GetWindowDC( HWND hwnd )
543 {
544     return GetDCEx( hwnd, 0, DCX_USESTYLE | DCX_WINDOW );
545 }
546
547
548 /***********************************************************************
549  *              ReleaseDC (USER32.@)
550  *
551  * RETURNS
552  *      1: Success
553  *      0: Failure
554  */
555 INT WINAPI ReleaseDC(
556              HWND hwnd /* [in] Handle of window - ignored */,
557              HDC hdc   /* [in] Handle of device context */
558 ) {
559     DCE * dce;
560     INT nRet = 0;
561
562     USER_Lock();
563     dce = firstDCE;
564
565     TRACE("%04x %04x\n", hwnd, hdc );
566
567     while (dce && (dce->hDC != hdc)) dce = dce->next;
568
569     if ( dce )
570         if ( dce->DCXflags & DCX_DCEBUSY )
571             nRet = DCE_ReleaseDC( dce );
572
573     USER_Unlock();
574
575     return nRet;
576 }
577
578 /***********************************************************************
579  *              DCHook (USER.362)
580  *
581  * See "Undoc. Windows" for hints (DC, SetDCHook, SetHookFlags)..
582  */
583 BOOL16 WINAPI DCHook16( HDC16 hDC, WORD code, DWORD data, LPARAM lParam )
584 {
585     BOOL retv = TRUE;
586     DCE *dce = (DCE *)data;
587
588     TRACE("hDC = %04x, %i\n", hDC, code);
589
590     if (!dce) return 0;
591     assert(dce->hDC == hDC);
592
593     /* Grab the windows lock before doing anything else  */
594     USER_Lock();
595
596     switch( code )
597     {
598       case DCHC_INVALIDVISRGN:
599            /* GDI code calls this when it detects that the
600             * DC is dirty (usually after SetHookFlags()). This
601             * means that we have to recompute the visible region.
602             */
603            if( dce->DCXflags & DCX_DCEBUSY )
604            {
605                /* Dirty bit has been cleared by caller, set it again so that
606                 * pGetDC recomputes the visible region. */
607                SetHookFlags16( dce->hDC, DCHF_INVALIDATEVISRGN );
608                USER_Driver.pGetDC( dce->hwndCurrent, dce->hDC, dce->hClipRgn, dce->DCXflags );
609            }
610            else /* non-fatal but shouldn't happen */
611              WARN("DC is not in use!\n");
612            break;
613
614       case DCHC_DELETEDC:
615            /*
616             * Windows will not let you delete a DC that is busy
617             * (between GetDC and ReleaseDC)
618             */
619
620            if ( dce->DCXflags & DCX_DCEBUSY )
621            {
622                WARN("Application trying to delete a busy DC\n");
623                retv = FALSE;
624            }
625            else DCE_FreeDCE( dce );
626            break;
627
628       default:
629            FIXME("unknown code\n");
630     }
631
632   USER_Unlock();  /* Release the wnd lock */
633   return retv;
634 }
635
636
637 /**********************************************************************
638  *              WindowFromDC (USER32.@)
639  */
640 HWND WINAPI WindowFromDC( HDC hDC )
641 {
642     DCE *dce;
643     HWND hwnd;
644
645     USER_Lock();
646     dce = firstDCE;
647
648     while (dce && (dce->hDC != hDC)) dce = dce->next;
649
650     hwnd = dce ? dce->hwndCurrent : 0;
651     USER_Unlock();
652
653     return hwnd;
654 }
655
656
657 /***********************************************************************
658  *              LockWindowUpdate (USER32.@)
659  */
660 BOOL WINAPI LockWindowUpdate( HWND hwnd )
661 {
662     static HWND lockedWnd;
663
664     FIXME("(%x), partial stub!\n",hwnd);
665
666     USER_Lock();
667     if (lockedWnd)
668     {
669         if (!hwnd)
670         {
671             /* Unlock lockedWnd */
672             /* FIXME: Do something */
673         }
674         else
675         {
676             /* Attempted to lock a second window */
677             /* Return FALSE and do nothing */
678             USER_Unlock();
679             return FALSE;
680         }
681     }
682     lockedWnd = hwnd;
683     USER_Unlock();
684     return TRUE;
685 }