ReactOS 0.4.17-dev-478-g4117217
painting.c File Reference
#include <win32k.h>
Include dependency graph for painting.c:

Go to the source code of this file.

Functions

 DBG_DEFAULT_CHANNEL (UserPainting)
 
BOOL UserExtTextOutW (HDC hdc, INT x, INT y, UINT flags, PRECTL lprc, LPCWSTR lpString, UINT count)
 
IntIntersectWithParents

Intersect window rectangle with all parent client rectangles.

Parameters
ChildPointer to child window to start intersecting from.
WindowRectPointer to rectangle that we want to intersect in screen coordinates on input and intersected rectangle on output (if TRUE is returned).
Returns
If any parent is minimized or invisible or the resulting rectangle is empty then FALSE is returned. Otherwise TRUE is returned.
BOOL FASTCALL IntIntersectWithParents (PWND Child, RECTL *WindowRect)
 
BOOL FASTCALL IntValidateParents (PWND Child, BOOL Recurse)
 
VOID FASTCALL IntSendSyncPaint (PWND Wnd, ULONG Flags)
 
HRGN FASTCALL IntCalcWindowRgn (PWND Wnd, BOOL Client)
 
HRGN FASTCALL IntGetNCUpdateRgn (PWND Window, BOOL Validate)
 
VOID FASTCALL IntSendNCPaint (PWND pWnd, HRGN hRgn)
 
VOID FASTCALL IntSendChildNCPaint (PWND pWnd)
 
VOID FASTCALL co_IntPaintWindows (PWND Wnd, ULONG Flags, BOOL Recurse)
 
VOID FASTCALL co_IntUpdateWindows (PWND Wnd, ULONG Flags, BOOL Recurse)
 
VOID FASTCALL UserUpdateWindows (PWND pWnd, ULONG Flags)
 
VOID FASTCALL UserSyncAndPaintWindows (PWND pWnd, ULONG Flags)
 
VOID FASTCALL IntInvalidateWindows (PWND Wnd, PREGION Rgn, ULONG Flags)
 
BOOL FASTCALL IntIsWindowDrawable (PWND Wnd)
 
BOOL FASTCALL co_UserRedrawWindow (PWND Window, const RECTL *UpdateRect, PREGION UpdateRgn, ULONG Flags)
 
VOID FASTCALL PaintSuspendedWindow (PWND pwnd, HRGN hrgnOrig)
 
VOID FASTCALL UpdateTheadChildren (PWND pWnd, HRGN hRgn)
 
VOID FASTCALL UpdateThreadWindows (PWND pWnd, PTHREADINFO pti, HRGN hRgn)
 
BOOL FASTCALL IntIsWindowDirty (PWND Wnd)
 
PWND FASTCALL IntFindWindowToRepaint (PWND Window, PTHREADINFO Thread)
 
VOID FASTCALL IntPaintWindow (PWND Window)
 
BOOL FASTCALL IntGetPaintMessage (PWND Window, UINT MsgFilterMin, UINT MsgFilterMax, PTHREADINFO Thread, MSG *Message, BOOL Remove)
 
BOOL FASTCALL IntPrintWindow (PWND pwnd, HDC hdcBlt, UINT nFlags)
 
BOOL FASTCALL IntFlashWindowEx (PWND pWnd, PFLASHWINFO pfwi)
 
HDC FASTCALL IntBeginPaint (PWND Window, PPAINTSTRUCT Ps)
 
BOOL FASTCALL IntEndPaint (PWND Wnd, PPAINTSTRUCT Ps)
 
BOOL FASTCALL IntFillWindow (PWND pWndParent, PWND pWnd, HDC hDC, HBRUSH hBrush)
 
HDC APIENTRY NtUserBeginPaint (HWND hWnd, PAINTSTRUCT *UnsafePs)
 
BOOL APIENTRY NtUserEndPaint (HWND hWnd, CONST PAINTSTRUCT *pUnsafePs)
 
BOOL APIENTRY NtUserFillWindow (HWND hWndParent, HWND hWnd, HDC hDC, HBRUSH hBrush)
 
BOOL APIENTRY NtUserFlashWindowEx (IN PFLASHWINFO pfwi)
 
INT FASTCALL co_UserGetUpdateRgn (PWND Window, HRGN hRgn, BOOL bErase)
 
BOOL FASTCALL co_UserGetUpdateRect (PWND Window, PRECT pRect, BOOL bErase)
 
INT APIENTRY NtUserGetUpdateRgn (HWND hWnd, HRGN hRgn, BOOL bErase)
 
BOOL APIENTRY NtUserGetUpdateRect (HWND hWnd, LPRECT UnsafeRect, BOOL bErase)
 
BOOL APIENTRY NtUserRedrawWindow (HWND hWnd, CONST RECT *lprcUpdate, HRGN hrgnUpdate, UINT flags)
 
BOOL UserDrawCaptionText (PWND pWnd, HDC hDc, const PUNICODE_STRING Text, const RECTL *lpRc, UINT uFlags, HFONT hFont)
 
BOOL UserDrawCaption (PWND pWnd, HDC hDc, RECTL *lpRc, HFONT hFont, HICON hIcon, const PUNICODE_STRING Str, UINT uFlags)
 
INT FASTCALL UserRealizePalette (HDC hdc)
 
BOOL APIENTRY NtUserDrawCaptionTemp (HWND hWnd, HDC hDC, LPCRECT lpRc, HFONT hFont, HICON hIcon, const PUNICODE_STRING str, UINT uFlags)
 
BOOL APIENTRY NtUserDrawCaption (HWND hWnd, HDC hDC, LPCRECT lpRc, UINT uFlags)
 
INT FASTCALL co_UserExcludeUpdateRgn (HDC hDC, PWND Window)
 
INT APIENTRY NtUserExcludeUpdateRgn (HDC hDC, HWND hWnd)
 
BOOL APIENTRY NtUserInvalidateRect (HWND hWnd, CONST RECT *lpUnsafeRect, BOOL bErase)
 
BOOL APIENTRY NtUserInvalidateRgn (HWND hWnd, HRGN hRgn, BOOL bErase)
 
BOOL APIENTRY NtUserPrintWindow (HWND hwnd, HDC hdcBlt, UINT nFlags)
 
BOOL APIENTRY NtUserValidateRect (HWND hWnd, const RECT *lpRect)
 

Function Documentation

◆ co_IntPaintWindows()

VOID FASTCALL co_IntPaintWindows ( PWND  Wnd,
ULONG  Flags,
BOOL  Recurse 
)

Definition at line 405 of file painting.c.

406{
407 HDC hDC;
409 HRGN TempRegion = NULL;
410
411 Wnd->state &= ~WNDS_PAINTNOTPROCESSED;
412
413 if (Wnd->state & WNDS_SENDNCPAINT ||
415 {
416 if (!(Wnd->style & WS_VISIBLE))
417 {
419 return;
420 }
421 else
422 {
423 if (Wnd->hrgnUpdate == NULL)
424 {
426 }
427
428 if (Wnd->head.pti == PsGetCurrentThreadWin32Thread())
429 {
430 if (Wnd->state & WNDS_SENDNCPAINT)
431 {
432 TempRegion = IntGetNCUpdateRgn(Wnd, TRUE);
433
434 IntSendNCPaint(Wnd, TempRegion);
435
436 if (TempRegion > HRGN_WINDOW && GreIsHandleValid(TempRegion))
437 {
438 /* NOTE: The region can already be deleted! */
439 GreDeleteObject(TempRegion);
440 }
441 }
442
444 {
446 if (Wnd->hrgnUpdate)
447 {
448 hDC = UserGetDCEx( Wnd,
449 Wnd->hrgnUpdate,
451
452 if (Wnd->head.pti->ppi != pti->ppi)
453 {
454 ERR("Sending DC to another Process!!!\n");
455 }
456
458 // Kill the loop, so Clear before we send.
460 {
462 }
463 UserReleaseDC(Wnd, hDC, FALSE);
464 }
465 }
466 }
467
468 }
469 }
470
471 /*
472 * Check that the window is still valid at this point
473 */
474 if (!IntIsWindow(hWnd))
475 {
476 return;
477 }
478
479 /*
480 * Paint child windows.
481 */
482
483 if (!(Flags & RDW_NOCHILDREN) &&
484 !(Wnd->style & WS_MINIMIZE) &&
487 {
488 HWND *List, *phWnd;
490
491 if ((List = IntWinListChildren(Wnd)))
492 {
493 for (phWnd = List; *phWnd; ++phWnd)
494 {
495 if ((Wnd = UserGetWindowObject(*phWnd)) == NULL)
496 continue;
497
498 if (Wnd->head.pti != pti && Wnd->style & WS_CHILD)
499 continue;
500
501 if (Wnd->style & WS_VISIBLE)
502 {
504 UserRefObjectCo(Wnd, &Ref);
507 }
508 }
510 }
511 }
512}
static HDC hDC
Definition: 3dtext.c:33
#define DCX_USESTYLE
Definition: GetDCEx.c:10
HWND hWnd
Definition: settings.c:17
#define ERR(fmt,...)
Definition: precomp.h:57
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define WNDS_SENDNCPAINT
Definition: ntuser.h:616
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
#define WNDS_ERASEBACKGROUND
Definition: ntuser.h:615
#define HRGN_WINDOW
Definition: ntuser.h:361
#define WNDS_SENDERASEBACKGROUND
Definition: ntuser.h:614
UINT_PTR WPARAM
Definition: minwindef.h:174
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
static HDC
Definition: imagelist.c:88
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:43
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:27
#define RDW_CLIPCHILDREN
Definition: painting.h:15
#define WS_CHILD
Definition: pedump.c:617
#define WS_MINIMIZE
Definition: pedump.c:622
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_CLIPCHILDREN
Definition: pedump.c:619
PPROCESSINFO ppi
Definition: win32.h:88
Definition: object.h:4
THRDESKHEAD head
Definition: ntuser.h:695
DWORD style
Definition: ntuser.h:706
HRGN hrgnUpdate
Definition: ntuser.h:721
DWORD state
Definition: ntuser.h:701
#define DCX_KEEPCLIPRGN
Definition: undocuser.h:69
HRGN FASTCALL IntGetNCUpdateRgn(PWND Window, BOOL Validate)
Definition: painting.c:260
VOID FASTCALL IntSendNCPaint(PWND pWnd, HRGN hRgn)
Definition: painting.c:350
VOID FASTCALL co_IntPaintWindows(PWND Wnd, ULONG Flags, BOOL Recurse)
Definition: painting.c:405
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:123
INT FASTCALL UserReleaseDC(PWND Window, HDC hDc, BOOL EndPaint)
Definition: windc.c:918
HDC FASTCALL UserGetDCEx(PWND Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1165
BOOL NTAPI GreIsHandleValid(HGDIOBJ hobj)
Definition: gdiobj.c:1153
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1495
#define USERTAG_WINDOWLIST
Definition: tags.h:298
HWND *FASTCALL IntWinListChildren(PWND Window)
Definition: window.c:275
BOOL FASTCALL IntIsWindow(HWND hWnd)
Definition: window.c:177
#define WM_ERASEBKGND
Definition: winuser.h:1653
#define DCX_CACHE
Definition: winuser.h:2150
#define RDW_NOCHILDREN
Definition: winuser.h:1233
#define DCX_INTERSECTRGN
Definition: winuser.h:2158
#define RDW_ALLCHILDREN
Definition: winuser.h:1232
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by co_IntGetUpdateRgn(), co_IntPaintWindows(), co_IntUpdateWindows(), co_UserGetUpdateRect(), co_UserGetUpdateRgn(), co_WinPosSetWindowPos(), IntPaintWindow(), and UserSyncAndPaintWindows().

◆ co_IntUpdateWindows()

VOID FASTCALL co_IntUpdateWindows ( PWND  Wnd,
ULONG  Flags,
BOOL  Recurse 
)

Definition at line 521 of file painting.c.

522{
525
526 if ( Wnd->hrgnUpdate != NULL || Wnd->state & WNDS_INTERNALPAINT )
527 {
528 if (Wnd->hrgnUpdate)
529 {
530 if (!IntValidateParents(Wnd, Recurse))
531 {
532 return;
533 }
534 }
535
536 if (Wnd->state & WNDS_INTERNALPAINT)
537 {
538 Wnd->state &= ~WNDS_INTERNALPAINT;
539
540 if (Wnd->hrgnUpdate == NULL)
541 MsqDecPaintCountQueue(Wnd->head.pti);
542 }
543
545 Wnd->state &= ~WNDS_UPDATEDIRTY;
546
548
549 UserRefObjectCo(Wnd, &Ref);
551
552 if (Wnd->state & WNDS_PAINTNOTPROCESSED)
553 {
555 }
557 }
558
559 // Force flags as a toggle. Fixes msg:test_paint_messages:WmChildPaintNc.
560 Flags = (Flags & RDW_NOCHILDREN) ? RDW_NOCHILDREN : RDW_ALLCHILDREN; // All children is the default.
561
562 /*
563 * Update child windows.
564 */
565
566 if (!(Flags & RDW_NOCHILDREN) &&
569 {
570 PWND Child;
571
572 for (Child = Wnd->spwndChild; Child; Child = Child->spwndNext)
573 {
574 /* transparent window, check for non-transparent sibling to paint first, then skip it */
575 if ( Child->ExStyle & WS_EX_TRANSPARENT &&
576 ( Child->hrgnUpdate != NULL || Child->state & WNDS_INTERNALPAINT ) )
577 {
578 PWND Next = Child->spwndNext;
579 while (Next)
580 {
581 if ( Next->hrgnUpdate != NULL || Next->state & WNDS_INTERNALPAINT ) break;
582
583 Next = Next->spwndNext;
584 }
585
586 if (Next) continue;
587 }
588
589 if (Child->style & WS_VISIBLE)
590 {
592 UserRefObjectCo(Child, &Ref);
595 }
596 }
597 }
598}
#define UserIsDesktopWindow(pWnd)
Definition: desktop.h:194
#define WNDS_INTERNALPAINT
Definition: ntuser.h:617
#define WNDS2_WMPAINTSENT
Definition: ntuser.h:641
#define WNDS_PAINTNOTPROCESSED
Definition: ntuser.h:627
VOID FASTCALL MsqDecPaintCountQueue(PTHREADINFO pti)
Definition: msgqueue.c:508
#define WS_EX_TRANSPARENT
Definition: pedump.c:649
STDMETHOD() Next(THIS_ ULONG celt, IAssociationElement *pElement, ULONG *pceltFetched) PURE
Definition: ntuser.h:694
DWORD state2
Definition: ntuser.h:702
struct _WND * spwndChild
Definition: ntuser.h:714
BOOL FASTCALL IntValidateParents(PWND Child, BOOL Recurse)
Definition: painting.c:62
VOID FASTCALL co_IntUpdateWindows(PWND Wnd, ULONG Flags, BOOL Recurse)
Definition: painting.c:521
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition: wdffdo.h:536
#define WM_PAINT
Definition: winuser.h:1648

Referenced by co_IntUpdateWindows(), IntPrintWindow(), MENU_ShowPopup(), NC_DoButton(), NtUserCallHwndLock(), and UserUpdateWindows().

◆ co_UserExcludeUpdateRgn()

INT FASTCALL co_UserExcludeUpdateRgn ( HDC  hDC,
PWND  Window 
)

Definition at line 2465 of file painting.c.

2466{
2467 POINT pt;
2468 RECT rc;
2469
2470 if (Window->hrgnUpdate)
2471 {
2472 if (Window->hrgnUpdate == HRGN_WINDOW)
2473 {
2474 return NtGdiIntersectClipRect(hDC, 0, 0, 0, 0);
2475 }
2476 else
2477 {
2478 INT ret = ERROR;
2479 HRGN hrgn = NtGdiCreateRectRgn(0,0,0,0);
2480
2481 if ( hrgn && GreGetDCPoint( hDC, GdiGetDCOrg, &pt) )
2482 {
2484 {
2485 NtGdiOffsetRgn(hrgn, pt.x, pt.y);
2486 }
2487 else
2488 {
2489 HRGN hrgnScreen;
2491 hrgnScreen = NtGdiCreateRectRgn(0,0,0,0);
2492 NtGdiCombineRgn(hrgnScreen, hrgnScreen, pm->hrgnMonitor, RGN_OR);
2493
2494 NtGdiCombineRgn(hrgn, hrgnScreen, NULL, RGN_COPY);
2495
2496 GreDeleteObject(hrgnScreen);
2497 }
2498
2499 NtGdiCombineRgn(hrgn, hrgn, Window->hrgnUpdate, RGN_DIFF);
2500
2501 NtGdiOffsetRgn(hrgn, -pt.x, -pt.y);
2502
2504
2506 }
2507 return ret;
2508 }
2509 }
2510 else
2511 {
2512 return GdiGetClipBox( hDC, &rc);
2513 }
2514}
static HRGN hrgn
#define pt(x, y)
Definition: drawing.c:79
return ret
Definition: mutex.c:146
#define ERROR(name)
Definition: error_private.h:53
static LPMONITOREX pm
Definition: localmon.c:45
#define CLIPRGN
Definition: precomp.h:18
BOOL APIENTRY GreGetDCPoint(HDC hDC, UINT iPoint, PPOINTL Point)
Definition: coord.c:1291
@ GdiGetDCOrg
Definition: ntgdityp.h:80
__kernel_entry W32KAPI INT APIENTRY NtGdiCombineRgn(_In_ HRGN hrgnDst, _In_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ INT iMode)
__kernel_entry W32KAPI HRGN APIENTRY NtGdiCreateRectRgn(_In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom)
__kernel_entry W32KAPI INT APIENTRY NtGdiExtSelectClipRgn(_In_ HDC hdc, _In_opt_ HRGN hrgn, _In_ INT iMode)
__kernel_entry W32KAPI INT APIENTRY NtGdiIntersectClipRect(_In_ HDC hdc, _In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom)
Definition: cliprgn.c:488
__kernel_entry W32KAPI INT APIENTRY NtGdiGetRandomRgn(_In_ HDC hdc, _In_ HRGN hrgn, _In_ INT iRgn)
__kernel_entry W32KAPI INT APIENTRY NtGdiOffsetRgn(_In_ HRGN hrgn, _In_ INT cx, _In_ INT cy)
Definition: region.c:3961
Definition: window.c:28
int32_t INT
Definition: typedefs.h:58
PMONITOR NTAPI UserGetPrimaryMonitor(VOID)
Definition: monitor.c:102
#define RGN_DIFF
Definition: wingdi.h:358
#define NULLREGION
Definition: wingdi.h:361
#define RGN_COPY
Definition: wingdi.h:357
#define RGN_OR
Definition: wingdi.h:359

Referenced by NtUserExcludeUpdateRgn().

◆ co_UserGetUpdateRect()

BOOL FASTCALL co_UserGetUpdateRect ( PWND  Window,
PRECT  pRect,
BOOL  bErase 
)

Definition at line 1862 of file painting.c.

1863{
1865 BOOL Ret = TRUE;
1866
1867 if (bErase)
1868 {
1870 UserRefObjectCo(Window, &Ref);
1873 }
1874
1875 Window->state &= ~WNDS_UPDATEDIRTY;
1876
1877 if (Window->hrgnUpdate == NULL)
1878 {
1879 pRect->left = pRect->top = pRect->right = pRect->bottom = 0;
1880 Ret = FALSE;
1881 }
1882 else
1883 {
1884 /* Get the update region bounding box. */
1885 if (Window->hrgnUpdate == HRGN_WINDOW)
1886 {
1887 *pRect = Window->rcClient;
1888 ERR("GURt: Caller is retrieving Window Region 1\n");
1889 }
1890 else
1891 {
1892 RegionType = IntGdiGetRgnBox(Window->hrgnUpdate, pRect);
1893
1895 RECTL_bIntersectRect(pRect, pRect, &Window->rcClient);
1896 }
1897
1898 if (IntIntersectWithParents(Window, pRect))
1899 {
1901 {
1902 RECTL_vOffsetRect(pRect,
1903 -Window->rcClient.left,
1904 -Window->rcClient.top);
1905 }
1906 if (Window->pcls->style & CS_OWNDC)
1907 {
1908 HDC hdc;
1909 //DWORD layout;
1911 //layout = NtGdiSetLayout(hdc, -1, 0);
1912 //IntMapWindowPoints( 0, Window, (LPPOINT)pRect, 2 );
1913 GreDPtoLP( hdc, (LPPOINT)pRect, 2 );
1914 //NtGdiSetLayout(hdc, -1, layout);
1916 }
1917 }
1918 else
1919 {
1920 pRect->left = pRect->top = pRect->right = pRect->bottom = 0;
1921 }
1922 }
1923 return Ret;
1924}
BOOL FASTCALL GreDPtoLP(HDC, LPPOINT, INT)
Definition: dcutil.c:7
unsigned int BOOL
Definition: ntddk_ex.h:94
RegionType
HDC hdc
Definition: main.c:9
LONG right
Definition: windef.h:108
LONG bottom
Definition: windef.h:109
LONG top
Definition: windef.h:107
LONG left
Definition: windef.h:106
BOOL FASTCALL IntIntersectWithParents(PWND Child, RECTL *WindowRect)
Definition: painting.c:35
BOOL FASTCALL RECTL_bIntersectRect(_Out_ RECTL *prclDst, _In_ const RECTL *prcl1, _In_ const RECTL *prcl2)
Definition: rect.c:55
FORCEINLINE VOID RECTL_vOffsetRect(_Inout_ RECTL *prcl, _In_ INT cx, _In_ INT cy)
Definition: rect.h:31
INT APIENTRY IntGdiGetRgnBox(HRGN hRgn, PRECTL pRect)
Definition: region.c:2561
#define CS_OWNDC
Definition: winuser.h:663

Referenced by NtUserGetUpdateRect().

◆ co_UserGetUpdateRgn()

INT FASTCALL co_UserGetUpdateRgn ( PWND  Window,
HRGN  hRgn,
BOOL  bErase 
)

Definition at line 1790 of file painting.c.

1791{
1792 int RegionType;
1793 BOOL Type;
1794 RECTL Rect;
1795
1797
1798 if (bErase)
1799 {
1801 UserRefObjectCo(Window, &Ref);
1804 }
1805
1806 Window->state &= ~WNDS_UPDATEDIRTY;
1807
1808 if (Window->hrgnUpdate == NULL)
1809 {
1810 NtGdiSetRectRgn(hRgn, 0, 0, 0, 0);
1811 return NULLREGION;
1812 }
1813
1814 Rect = Window->rcClient;
1816
1817 if (Window->hrgnUpdate == HRGN_WINDOW)
1818 {
1819 // Trap it out.
1820 ERR("GURn: Caller is passing Window Region 1\n");
1821 if (!Type)
1822 {
1823 NtGdiSetRectRgn(hRgn, 0, 0, 0, 0);
1824 return NULLREGION;
1825 }
1826
1828
1830 {
1832 -Window->rcClient.left,
1833 -Window->rcClient.top);
1834 }
1836 }
1837 else
1838 {
1839 HRGN hrgnTemp = GreCreateRectRgnIndirect(&Rect);
1840
1841 RegionType = NtGdiCombineRgn(hRgn, hrgnTemp, Window->hrgnUpdate, RGN_AND);
1842
1844 {
1845 if (hrgnTemp) GreDeleteObject(hrgnTemp);
1846 NtGdiSetRectRgn(hRgn, 0, 0, 0, 0);
1847 return RegionType;
1848 }
1849
1851 {
1853 -Window->rcClient.left,
1854 -Window->rcClient.top);
1855 }
1856 if (hrgnTemp) GreDeleteObject(hrgnTemp);
1857 }
1858 return RegionType;
1859}
Type
Definition: Type.h:7
static HRGN hRgn
Definition: mapping.c:32
__kernel_entry W32KAPI BOOL APIENTRY NtGdiSetRectRgn(_In_ HRGN hrgn, _In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom)
Definition: region.c:4048
#define GreCreateRectRgnIndirect(prc)
Definition: region.h:96
#define GreSetRectRgnIndirect(hRgn, prc)
Definition: region.h:99
#define ASSERT_REFS_CO(_obj_)
Definition: userfuncs.h:13
#define RGN_AND
Definition: wingdi.h:356
#define SIMPLEREGION
Definition: wingdi.h:362

Referenced by IntDefWindowProc(), and NtUserGetUpdateRgn().

◆ co_UserRedrawWindow()

BOOL FASTCALL co_UserRedrawWindow ( PWND  Window,
const RECTL UpdateRect,
PREGION  UpdateRgn,
ULONG  Flags 
)

Definition at line 897 of file painting.c.

902{
903 PREGION TmpRgn = NULL;
904 TRACE("co_UserRedrawWindow start Rgn %p\n",UpdateRgn);
905
906 /*
907 * Step 1.
908 * Validation of passed parameters.
909 */
910
912 {
913 return TRUE; // Just do nothing!!!
914 }
915
916 if (Window == NULL)
917 {
919 }
920
921 /*
922 * Step 2.
923 * Transform the parameters UpdateRgn and UpdateRect into
924 * a region hRgn specified in screen coordinates.
925 */
926
927 if (Flags & (RDW_INVALIDATE | RDW_VALIDATE)) // Both are OKAY!
928 {
929 /* We can't hold lock on GDI objects while doing roundtrips to user mode,
930 * so use a copy instead */
931 if (UpdateRgn)
932 {
933 TmpRgn = IntSysCreateRectpRgn(0, 0, 0, 0);
934
935 if (UpdateRgn > PRGN_WINDOW)
936 {
937 IntGdiCombineRgn(TmpRgn, UpdateRgn, NULL, RGN_COPY);
938 }
939
941 {
942 REGION_bOffsetRgn(TmpRgn, Window->rcClient.left, Window->rcClient.top);
943 }
944 }
945 else
946 {
947 if (UpdateRect != NULL)
948 {
950 {
952 }
953 else
954 {
955 TmpRgn = IntSysCreateRectpRgn(Window->rcClient.left + UpdateRect->left,
956 Window->rcClient.top + UpdateRect->top,
957 Window->rcClient.left + UpdateRect->right,
958 Window->rcClient.top + UpdateRect->bottom);
959 }
960 }
961 else
962 {
965 {
966 if (!RECTL_bIsEmptyRect(&Window->rcWindow))
967 TmpRgn = IntSysCreateRectpRgnIndirect(&Window->rcWindow);
968 }
969 else
970 {
971 if (!RECTL_bIsEmptyRect(&Window->rcClient))
972 TmpRgn = IntSysCreateRectpRgnIndirect(&Window->rcClient);
973 }
974 }
975 }
976 }
977
978 /* Fixes test RDW_INTERNALPAINT behavior */
979 if (TmpRgn == NULL)
980 {
981 TmpRgn = PRGN_WINDOW; // Need a region so the bits can be set!!!
982 }
983
984 /*
985 * Step 3.
986 * Adjust the window update region depending on hRgn and flags.
987 */
988
990 TmpRgn != NULL)
991 {
993 }
994
995 /*
996 * Step 4.
997 * Repaint and erase windows if needed.
998 */
999
1000 if (Flags & RDW_UPDATENOW)
1001 {
1003 }
1004 else if (Flags & RDW_ERASENOW)
1005 {
1006 if ((Flags & (RDW_NOCHILDREN|RDW_ALLCHILDREN)) == 0)
1008
1010 }
1011
1012 /*
1013 * Step 5.
1014 * Cleanup ;-)
1015 */
1016
1017 if (TmpRgn > PRGN_WINDOW)
1018 {
1019 REGION_Delete(TmpRgn);
1020 }
1021 TRACE("co_UserRedrawWindow exit\n");
1022
1023 return TRUE;
1024}
#define PRGN_WINDOW
Definition: painting.h:12
#define IntSysCreateRectpRgnIndirect(prc)
Definition: region.h:93
#define TRACE(s)
Definition: solgame.cpp:4
Definition: region.h:8
static int UpdateRect(TreeListData *pData, unsigned uItem, unsigned uSub)
Definition: treelist.c:1529
BOOL FASTCALL IntIsWindowDrawable(PWND Wnd)
Definition: painting.c:870
VOID FASTCALL UserSyncAndPaintWindows(PWND pWnd, ULONG Flags)
Definition: painting.c:623
VOID FASTCALL UserUpdateWindows(PWND pWnd, ULONG Flags)
Definition: painting.c:601
VOID FASTCALL IntInvalidateWindows(PWND Wnd, PREGION Rgn, ULONG Flags)
Definition: painting.c:645
FORCEINLINE BOOL RECTL_bIsEmptyRect(_In_ const RECTL *prcl)
Definition: rect.h:44
VOID FASTCALL REGION_Delete(PREGION pRgn)
Definition: region.c:2449
PREGION FASTCALL IntSysCreateRectpRgn(INT LeftRect, INT TopRect, INT RightRect, INT BottomRect)
Definition: region.c:2407
BOOL FASTCALL REGION_bOffsetRgn(_Inout_ PREGION prgn, _In_ INT cx, _In_ INT cy)
Definition: region.c:2707
INT FASTCALL IntGdiCombineRgn(PREGION prgnDest, PREGION prgnSrc1, PREGION prgnSrc2, INT iCombineMode)
Definition: region.c:2487
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1408
#define RDW_NOINTERNALPAINT
Definition: winuser.h:1228
#define RDW_UPDATENOW
Definition: winuser.h:1231
#define RDW_ERASENOW
Definition: winuser.h:1230
#define RDW_FRAME
Definition: winuser.h:1223
#define RDW_NOFRAME
Definition: winuser.h:1227
#define RDW_INTERNALPAINT
Definition: winuser.h:1224
#define RDW_VALIDATE
Definition: winuser.h:1229
#define RDW_INVALIDATE
Definition: winuser.h:1225

Referenced by co_IntSetScrollInfo(), co_IntShowDesktop(), co_UserFreeWindow(), co_VIS_WindowLayoutChanged(), co_WinPosMinMaximize(), co_WinPosSetWindowPos(), DefWndDoSizeMove(), DesktopWindowProc(), IntDefWindowProc(), IntForceMinimizeWindow(), IntScrollWindowEx(), IntSetLayeredWindowAttributes(), NtGdiUpdateColors(), NtUserCallHwndParamLock(), and NtUserRedrawWindow().

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UserPainting  )

◆ IntBeginPaint()

HDC FASTCALL IntBeginPaint ( PWND  Window,
PPAINTSTRUCT  Ps 
)

Definition at line 1443 of file painting.c.

1444{
1445 RECT Rect;
1446 INT type;
1447 BOOL Erase = FALSE;
1448
1450
1451 Window->state2 |= WNDS2_STARTPAINT;
1452 Window->state &= ~WNDS_PAINTNOTPROCESSED;
1453
1454 if (Window->state & WNDS_SENDNCPAINT)
1455 {
1456 HRGN hRgn;
1457 // Application can keep update dirty.
1458 do
1459 {
1460 Window->state &= ~WNDS_UPDATEDIRTY;
1464 {
1465 /* NOTE: The region can already be deleted! */
1467 }
1468 }
1469 while(Window->state & WNDS_UPDATEDIRTY);
1470 }
1471 else
1472 {
1473 Window->state &= ~WNDS_UPDATEDIRTY;
1474 }
1475
1476 RtlZeroMemory(Ps, sizeof(PAINTSTRUCT));
1477
1478 if (Window->state2 & WNDS2_ENDPAINTINVALIDATE)
1479 {
1480 ERR("BP: Another thread invalidated this window\n");
1481 }
1482
1483 Ps->hdc = UserGetDCEx( Window,
1484 Window->hrgnUpdate,
1486 if (!Ps->hdc)
1487 {
1488 return NULL;
1489 }
1490
1491 // If set, always clear flags out due to the conditions later on for sending the message.
1492 if (Window->state & WNDS_SENDERASEBACKGROUND)
1493 {
1495 Erase = TRUE;
1496 }
1497
1498 if (Window->hrgnUpdate != NULL)
1499 {
1500 MsqDecPaintCountQueue(Window->head.pti);
1502 /* The region is part of the dc now and belongs to the process! */
1503 Window->hrgnUpdate = NULL;
1504 }
1505 else
1506 {
1507 if (Window->state & WNDS_INTERNALPAINT)
1508 MsqDecPaintCountQueue(Window->head.pti);
1509 }
1510
1511 type = GdiGetClipBox(Ps->hdc, &Ps->rcPaint);
1512
1514
1515 Window->state &= ~WNDS_INTERNALPAINT;
1516
1517 if ( Erase && // Set to erase,
1518 type != NULLREGION && // don't erase if the clip box is empty,
1519 (!(Window->pcls->style & CS_PARENTDC) || // not parent dc or
1520 RECTL_bIntersectRect( &Rect, &Rect, &Ps->rcPaint) ) ) // intersecting.
1521 {
1523 if ( Ps->fErase )
1524 {
1526 }
1527 }
1528 else
1529 {
1530 Ps->fErase = FALSE;
1531 }
1532
1534
1535 return Ps->hdc;
1536}
void Erase(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, LONG radius)
Definition: drawing.cpp:302
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define WNDS2_ENDPAINTINVALIDATE
Definition: ntuser.h:642
#define WNDS_UPDATEDIRTY
Definition: ntuser.h:618
#define WNDS2_STARTPAINT
Definition: ntuser.h:643
#define GDI_OBJ_HMGR_POWNED
Definition: ntgdihdl.h:117
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
VOID FASTCALL IntSendChildNCPaint(PWND pWnd)
Definition: painting.c:372
BOOL FASTCALL IntGdiSetRegionOwner(HRGN hRgn, DWORD OwnerMask)
Definition: region.c:2459
BOOL FASTCALL co_UserHideCaret(PWND Window OPTIONAL)
Definition: caret.c:224
VOID FASTCALL IntGetClientRect(PWND WindowObject, RECTL *Rect)
Definition: winpos.c:92
#define CS_PARENTDC
Definition: winuser.h:664

Referenced by DesktopWindowProc(), IntDefWindowProc(), NtUserBeginPaint(), and PopupMenuWndProc().

◆ IntCalcWindowRgn()

HRGN FASTCALL IntCalcWindowRgn ( PWND  Wnd,
BOOL  Client 
)

Definition at line 209 of file painting.c.

210{
211 HRGN hRgnWindow;
212
213 if (Client)
214 {
215 hRgnWindow = NtGdiCreateRectRgn(
216 Wnd->rcClient.left,
217 Wnd->rcClient.top,
218 Wnd->rcClient.right,
219 Wnd->rcClient.bottom);
220 }
221 else
222 {
223 hRgnWindow = NtGdiCreateRectRgn(
224 Wnd->rcWindow.left,
225 Wnd->rcWindow.top,
226 Wnd->rcWindow.right,
227 Wnd->rcWindow.bottom);
228 }
229
230 if (Wnd->hrgnClip != NULL && !(Wnd->style & WS_MINIMIZE))
231 {
232 NtGdiOffsetRgn(hRgnWindow,
233 -Wnd->rcWindow.left,
234 -Wnd->rcWindow.top);
235 NtGdiCombineRgn(hRgnWindow, hRgnWindow, Wnd->hrgnClip, RGN_AND);
236 NtGdiOffsetRgn(hRgnWindow,
237 Wnd->rcWindow.left,
238 Wnd->rcWindow.top);
239 }
240
241 return hRgnWindow;
242}
Definition: client.c:28
HRGN hrgnClip
Definition: ntuser.h:733
RECT rcClient
Definition: ntuser.h:717
RECT rcWindow
Definition: ntuser.h:716

Referenced by IntGetNCUpdateRgn().

◆ IntEndPaint()

BOOL FASTCALL IntEndPaint ( PWND  Wnd,
PPAINTSTRUCT  Ps 
)

Definition at line 1539 of file painting.c.

1540{
1541 HDC hdc = NULL;
1542
1543 hdc = Ps->hdc;
1544
1545 UserReleaseDC(Wnd, hdc, TRUE);
1546
1548 {
1549 ERR("EP: Another thread invalidated this window\n");
1550 Wnd->state2 &= ~WNDS2_ENDPAINTINVALIDATE;
1551 }
1552
1554
1555 co_UserShowCaret(Wnd);
1556
1557 return TRUE;
1558}
BOOL FASTCALL co_UserShowCaret(PWND Window OPTIONAL)
Definition: caret.c:259

Referenced by DesktopWindowProc(), IntDefWindowProc(), NtUserEndPaint(), and PopupMenuWndProc().

◆ IntFillWindow()

BOOL FASTCALL IntFillWindow ( PWND  pWndParent,
PWND  pWnd,
HDC  hDC,
HBRUSH  hBrush 
)

Definition at line 1561 of file painting.c.

1565{
1566 RECT Rect, Rect1;
1567 INT type;
1568
1569 if (!pWndParent)
1570 pWndParent = pWnd;
1571
1572 type = GdiGetClipBox(hDC, &Rect);
1573
1574 IntGetClientRect(pWnd, &Rect1);
1575
1576 if ( type != NULLREGION && // Clip box is not empty,
1577 (!(pWnd->pcls->style & CS_PARENTDC) || // not parent dc or
1578 RECTL_bIntersectRect( &Rect, &Rect, &Rect1) ) ) // intersecting.
1579 {
1580 POINT ppt;
1581 INT x = 0, y = 0;
1582
1583 if (!UserIsDesktopWindow(pWndParent))
1584 {
1585 x = pWndParent->rcClient.left - pWnd->rcClient.left;
1586 y = pWndParent->rcClient.top - pWnd->rcClient.top;
1587 }
1588
1589 GreSetBrushOrg(hDC, x, y, &ppt);
1590
1591 if ( hBrush < (HBRUSH)CTLCOLOR_MAX )
1592 hBrush = GetControlColor( pWndParent, pWnd, hDC, HandleToUlong(hBrush) + WM_CTLCOLORMSGBOX);
1593
1594 FillRect(hDC, &Rect, hBrush);
1595
1596 GreSetBrushOrg(hDC, ppt.x, ppt.y, NULL);
1597
1598 return TRUE;
1599 }
1600 else
1601 return FALSE;
1602}
#define HandleToUlong(h)
Definition: basetsd.h:73
BOOL FASTCALL GreSetBrushOrg(HDC, INT, INT, LPPOINT)
Definition: dcutil.c:231
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
UINT style
Definition: ntuser.h:580
PCLS pcls
Definition: ntuser.h:720
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
HBRUSH FASTCALL GetControlColor(PWND pwndParent, PWND pwnd, HDC hdc, UINT CtlMsg)
Definition: misc.c:153
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
#define WM_CTLCOLORMSGBOX
Definition: winuser.h:1794
#define CTLCOLOR_MAX
Definition: winuser.h:969

Referenced by NtUserFillWindow().

◆ IntFindWindowToRepaint()

PWND FASTCALL IntFindWindowToRepaint ( PWND  Window,
PTHREADINFO  Thread 
)

Definition at line 1143 of file painting.c.

1144{
1145 PWND hChild;
1146 PWND TempWindow;
1147
1148 for (; Window != NULL; Window = Window->spwndNext)
1149 {
1151 {
1153 {
1154 /* Make sure all non-transparent siblings are already drawn. */
1155 if (Window->ExStyle & WS_EX_TRANSPARENT)
1156 {
1157 for (TempWindow = Window->spwndNext; TempWindow != NULL;
1158 TempWindow = TempWindow->spwndNext)
1159 {
1160 if (!(TempWindow->ExStyle & WS_EX_TRANSPARENT) &&
1161 IntWndBelongsToThread(TempWindow, Thread) &&
1162 IntIsWindowDirty(TempWindow))
1163 {
1164 return TempWindow;
1165 }
1166 }
1167 }
1168 return Window;
1169 }
1170 }
1171 /* find a child of the specified window that needs repainting */
1172 if (Window->spwndChild)
1173 {
1175 if (hChild != NULL)
1176 return hChild;
1177 }
1178 }
1179 return Window;
1180}
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
static HTREEITEM hChild
Definition: treeview.c:383
DWORD ExStyle
Definition: ntuser.h:704
struct _WND * spwndNext
Definition: ntuser.h:711
PWND FASTCALL IntFindWindowToRepaint(PWND Window, PTHREADINFO Thread)
Definition: painting.c:1143
BOOL FASTCALL IntIsWindowDirty(PWND Wnd)
Definition: painting.c:1127
#define IntWndBelongsToThread(WndObj, W32Thread)
Definition: window.h:32

Referenced by IntFindWindowToRepaint(), and IntGetPaintMessage().

◆ IntFlashWindowEx()

BOOL FASTCALL IntFlashWindowEx ( PWND  pWnd,
PFLASHWINFO  pfwi 
)

Definition at line 1313 of file painting.c.

1314{
1315 DWORD_PTR FlashState;
1316 UINT uCount = pfwi->uCount;
1317 BOOL Activate = FALSE, Ret = FALSE;
1318
1319 ASSERT(pfwi);
1320
1321 FlashState = (DWORD_PTR)UserGetProp(pWnd, AtomFlashWndState, TRUE);
1322
1323 if (FlashState == FLASHW_FINISHED)
1324 {
1325 // Cycle has finished, kill timer and set this to Stop.
1326 FlashState |= FLASHW_KILLSYSTIMER;
1327 pfwi->dwFlags = FLASHW_STOP;
1328 }
1329 else
1330 {
1331 if (FlashState)
1332 {
1333 if (pfwi->dwFlags == FLASHW_SYSTIMER)
1334 {
1335 // Called from system timer, restore flags, counts and state.
1336 pfwi->dwFlags = LOWORD(FlashState);
1337 uCount = HIWORD(FlashState);
1338 FlashState = MAKELONG(LOWORD(FlashState),0);
1339 }
1340 else
1341 {
1342 // Clean out the trash! Fix SeaMonkey crash after restart.
1343 FlashState = 0;
1344 }
1345 }
1346
1347 if (FlashState == 0)
1348 { // First time in cycle, setup flash state.
1349 if ( pWnd->state & WNDS_ACTIVEFRAME ||
1350 (pfwi->dwFlags & FLASHW_CAPTION && pWnd->style & (WS_BORDER|WS_DLGFRAME)))
1351 {
1352 FlashState = FLASHW_STARTED|FLASHW_ACTIVE;
1353 }
1354 }
1355
1356 // Set previous window state.
1357 Ret = !!(FlashState & FLASHW_ACTIVE);
1358
1359 if ( (pfwi->dwFlags & FLASHW_TIMERNOFG) == FLASHW_TIMERNOFG &&
1360 gpqForeground == pWnd->head.pti->MessageQueue )
1361 {
1362 // Flashing until foreground, set this to Stop.
1363 pfwi->dwFlags = FLASHW_STOP;
1364 }
1365 }
1366
1367 // Toggle activate flag.
1368 if ( pfwi->dwFlags == FLASHW_STOP )
1369 {
1370 if (gpqForeground && gpqForeground->spwndActive == pWnd)
1371 Activate = TRUE;
1372 else
1373 Activate = FALSE;
1374 }
1375 else
1376 {
1377 Activate = (FlashState & FLASHW_ACTIVE) == 0;
1378 }
1379
1380 if ( pfwi->dwFlags == FLASHW_STOP || pfwi->dwFlags & FLASHW_CAPTION )
1381 {
1382 co_IntSendMessage(UserHMGetHandle(pWnd), WM_NCACTIVATE, Activate, 0);
1383 }
1384
1385 // FIXME: Check for a Stop Sign here.
1386 if ( pfwi->dwFlags & FLASHW_TRAY )
1387 {
1388 // Need some shell work here too.
1389 TRACE("FIXME: Flash window no Tray support!\n");
1390 }
1391
1392 if ( pfwi->dwFlags == FLASHW_STOP )
1393 {
1394 if (FlashState & FLASHW_KILLSYSTIMER)
1395 {
1397 }
1398
1400 }
1401 else
1402 { // Have a count and started, set timer.
1403 if ( uCount )
1404 {
1405 FlashState |= FLASHW_COUNT;
1406
1407 if (!(Activate ^ !!(FlashState & FLASHW_STARTED)))
1408 uCount--;
1409
1410 if (!(FlashState & FLASHW_KILLSYSTIMER))
1411 pfwi->dwFlags |= FLASHW_TIMER;
1412 }
1413
1414 if (pfwi->dwFlags & FLASHW_TIMER)
1415 {
1416 FlashState |= FLASHW_KILLSYSTIMER;
1417
1418 IntSetTimer( pWnd,
1420 pfwi->dwTimeout ? pfwi->dwTimeout : gpsi->dtCaretBlink,
1422 TMRF_SYSTEM );
1423 }
1424
1425 if (FlashState & FLASHW_COUNT && uCount == 0)
1426 {
1427 // Keep spinning? Nothing else to do.
1428 FlashState = FLASHW_FINISHED;
1429 }
1430 else
1431 {
1432 // Save state and flags so this can be restored next time through.
1433 FlashState ^= (FlashState ^ -!!(Activate)) & FLASHW_ACTIVE;
1434 FlashState ^= (FlashState ^ pfwi->dwFlags) & (FLASHW_MASK & ~FLASHW_TIMER);
1435 }
1436 FlashState = MAKELONG(LOWORD(FlashState),uCount);
1437 UserSetProp(pWnd, AtomFlashWndState, (HANDLE)FlashState, TRUE);
1438 }
1439 return Ret;
1440}
PUSER_MESSAGE_QUEUE gpqForeground
Definition: focus.c:13
unsigned int UINT
Definition: sysinfo.c:13
PSERVERINFO gpsi
Definition: imm.c:18
#define WNDS_ACTIVEFRAME
Definition: ntuser.h:611
#define ASSERT(a)
Definition: mode.c:44
ATOM AtomFlashWndState
Definition: ntuser.c:22
#define FLASHW_FINISHED
Definition: painting.h:5
#define FLASHW_STARTED
Definition: painting.h:6
#define FLASHW_COUNT
Definition: painting.h:7
#define FLASHW_ACTIVE
Definition: painting.h:9
#define FLASHW_SYSTIMER
Definition: painting.h:4
#define FLASHW_MASK
Definition: painting.h:3
#define FLASHW_KILLSYSTIMER
Definition: painting.h:8
#define LOWORD(l)
Definition: pedump.c:82
#define WS_BORDER
Definition: pedump.c:625
#define WS_DLGFRAME
Definition: pedump.c:626
#define DWORD_PTR
Definition: treelist.c:76
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define HIWORD(l)
Definition: typedefs.h:247
HANDLE FASTCALL UserGetProp(_In_ PWND Window, _In_ ATOM Atom, _In_ BOOLEAN SystemProp)
Definition: prop.c:46
HANDLE FASTCALL UserRemoveProp(_In_ PWND Window, _In_ ATOM Atom, _In_ BOOLEAN SystemProp)
VOID CALLBACK SystemTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
Definition: timer.c:286
BOOL FASTCALL IntKillTimer(PWND Window, UINT_PTR IDEvent, BOOL SystemTimer)
Definition: timer.c:579
UINT_PTR FASTCALL IntSetTimer(PWND Window, UINT_PTR IDEvent, UINT Elapse, TIMERPROC TimerFunc, INT Type)
Definition: timer.c:182
#define TMRF_SYSTEM
Definition: timer.h:20
#define ID_EVENT_SYSTIMER_FLASHWIN
Definition: timer.h:28
#define WM_NCACTIVATE
Definition: winuser.h:1716

Referenced by DefWndHandleSetCursor(), NtUserFlashWindowEx(), and SystemTimerProc().

◆ IntGetNCUpdateRgn()

HRGN FASTCALL IntGetNCUpdateRgn ( PWND  Window,
BOOL  Validate 
)

Definition at line 260 of file painting.c.

261{
262 HRGN hRgnNonClient;
263 HRGN hRgnWindow;
264 UINT RgnType, NcType;
265 RECT update;
266
267 if (Window->hrgnUpdate != NULL &&
268 Window->hrgnUpdate != HRGN_WINDOW)
269 {
270 hRgnNonClient = IntCalcWindowRgn(Window, FALSE);
271
272 /*
273 * If region creation fails it's safe to fallback to whole
274 * window region.
275 */
276 if (hRgnNonClient == NULL)
277 {
278 return HRGN_WINDOW;
279 }
280
281 hRgnWindow = IntCalcWindowRgn(Window, TRUE);
282 if (hRgnWindow == NULL)
283 {
284 GreDeleteObject(hRgnNonClient);
285 return HRGN_WINDOW;
286 }
287
288 NcType = IntGdiGetRgnBox(Window->hrgnUpdate, &update);
289
290 RgnType = NtGdiCombineRgn(hRgnNonClient, hRgnNonClient, hRgnWindow, RGN_DIFF);
291 if ((RgnType != ERROR) && (RgnType != NULLREGION))
292 RgnType = NtGdiCombineRgn(hRgnNonClient, hRgnNonClient, Window->hrgnUpdate, RGN_AND);
293
294 if (RgnType == ERROR)
295 {
296 GreDeleteObject(hRgnWindow);
297 GreDeleteObject(hRgnNonClient);
298 return HRGN_WINDOW;
299 }
300 else if (RgnType == NULLREGION)
301 {
302 GreDeleteObject(hRgnWindow);
303 GreDeleteObject(hRgnNonClient);
304 Window->state &= ~WNDS_UPDATEDIRTY;
305 return NULL;
306 }
307
308 /*
309 * Remove the nonclient region from the standard update region if
310 * we were asked for it.
311 */
312
313 if (Validate)
314 {
315 if (NtGdiCombineRgn(Window->hrgnUpdate, Window->hrgnUpdate, hRgnWindow, RGN_AND) == NULLREGION)
316 {
318 GreDeleteObject(Window->hrgnUpdate);
319 Window->state &= ~WNDS_UPDATEDIRTY;
320 Window->hrgnUpdate = NULL;
321 if (!(Window->state & WNDS_INTERNALPAINT))
322 MsqDecPaintCountQueue(Window->head.pti);
323 }
324 }
325
326 /* check if update rgn contains complete nonclient area */
327 if (NcType == SIMPLEREGION)
328 {
329 RECT window;
331
332 if (IntEqualRect( &window, &update ))
333 {
334 GreDeleteObject(hRgnNonClient);
335 hRgnNonClient = HRGN_WINDOW;
336 }
337 }
338
339 GreDeleteObject(hRgnWindow);
340
341 return hRgnNonClient;
342 }
343 else
344 {
345 return Window->hrgnUpdate;
346 }
347}
static IHTMLWindow2 * window
Definition: events.c:77
BOOL FASTCALL IntGetWindowRect(PWND Wnd, RECTL *Rect)
Definition: winpos.c:121
HRGN FASTCALL IntCalcWindowRgn(PWND Wnd, BOOL Client)
Definition: painting.c:209
FORCEINLINE BOOL IntEqualRect(RECTL *lprc1, RECTL *lprc2)
Definition: winpos.h:48

Referenced by co_IntPaintWindows(), and IntBeginPaint().

◆ IntGetPaintMessage()

BOOL FASTCALL IntGetPaintMessage ( PWND  Window,
UINT  MsgFilterMin,
UINT  MsgFilterMax,
PTHREADINFO  Thread,
MSG Message,
BOOL  Remove 
)

Definition at line 1193 of file painting.c.

1200{
1201 PWND PaintWnd, StartWnd;
1202
1203 if ((MsgFilterMin != 0 || MsgFilterMax != 0) &&
1204 (MsgFilterMin > WM_PAINT || MsgFilterMax < WM_PAINT))
1205 return FALSE;
1206
1207 if (Thread->TIF_flags & TIF_SYSTEMTHREAD )
1208 {
1209 ERR("WM_PAINT is in a System Thread!\n");
1210 }
1211
1212 StartWnd = UserGetDesktopWindow();
1213 PaintWnd = IntFindWindowToRepaint(StartWnd, Thread);
1214
1215 Message->hwnd = PaintWnd ? UserHMGetHandle(PaintWnd) : NULL;
1216
1217 if (Message->hwnd == NULL && Thread->cPaintsReady)
1218 {
1219 // Find note in window.c:"PAINTING BUG".
1220 ERR("WARNING SOMETHING HAS GONE WRONG: Thread marked as containing dirty windows, but no dirty windows found! Counts %u\n",Thread->cPaintsReady);
1221 /* Hack to stop spamming the debug log ! */
1222 Thread->cPaintsReady = 0;
1223 return FALSE;
1224 }
1225
1226 if (Message->hwnd == NULL)
1227 return FALSE;
1228
1229 if (!(Window == NULL ||
1230 PaintWnd == Window ||
1231 IntIsChildWindow(Window, PaintWnd))) /* check that it is a child of the specified parent */
1232 return FALSE;
1233
1234 if (PaintWnd->state & WNDS_INTERNALPAINT)
1235 {
1236 PaintWnd->state &= ~WNDS_INTERNALPAINT;
1237 if (!PaintWnd->hrgnUpdate)
1239 }
1240 PaintWnd->state2 &= ~WNDS2_STARTPAINT;
1241 PaintWnd->state &= ~WNDS_UPDATEDIRTY;
1242
1243 Window = PaintWnd;
1244 while (Window && !UserIsDesktopWindow(Window))
1245 {
1246 // Role back and check for clip children, do not set if any.
1247 if (Window->spwndParent && !(Window->spwndParent->style & WS_CLIPCHILDREN))
1248 {
1249 PaintWnd->state2 |= WNDS2_WMPAINTSENT;
1250 }
1251 Window = Window->spwndParent;
1252 }
1253
1254 Message->wParam = Message->lParam = 0;
1255 Message->message = WM_PAINT;
1256 return TRUE;
1257}
static const WCHAR Message[]
Definition: register.c:74
#define TIF_SYSTEMTHREAD
Definition: ntuser.h:265
BOOL FASTCALL IntIsChildWindow(PWND Parent, PWND BaseWindow)
Definition: window.c:929

Referenced by co_IntPeekMessage().

◆ IntIntersectWithParents()

BOOL FASTCALL IntIntersectWithParents ( PWND  Child,
RECTL WindowRect 
)

Definition at line 35 of file painting.c.

36{
37 PWND ParentWnd;
38
39 if (Child->ExStyle & WS_EX_REDIRECTED)
40 return TRUE;
41
42 ParentWnd = Child->spwndParent;
43 while (ParentWnd != NULL)
44 {
45 if (!(ParentWnd->style & WS_VISIBLE) ||
46 (ParentWnd->style & WS_MINIMIZE) ||
47 !RECTL_bIntersectRect(WindowRect, WindowRect, &ParentWnd->rcClient) )
48 {
49 return FALSE;
50 }
51
52 if (ParentWnd->ExStyle & WS_EX_REDIRECTED)
53 return TRUE;
54
55 ParentWnd = ParentWnd->spwndParent;
56 }
57
58 return TRUE;
59}
struct _WND * spwndParent
Definition: ntuser.h:713
#define WS_EX_REDIRECTED
Definition: undocuser.h:27

Referenced by co_IntGetUpdateRgn(), co_UserGetUpdateRect(), co_UserGetUpdateRgn(), and IntValidateParents().

◆ IntInvalidateWindows()

VOID FASTCALL IntInvalidateWindows ( PWND  Wnd,
PREGION  Rgn,
ULONG  Flags 
)

Definition at line 645 of file painting.c.

646{
647 INT RgnType = NULLREGION;
648 BOOL HadPaintMessage;
649
650 TRACE("IntInvalidateWindows start Rgn %p\n",Rgn);
651
652 if ( Rgn > PRGN_WINDOW )
653 {
654 /*
655 * If the nonclient is not to be redrawn, clip the region to the client
656 * rect
657 */
658 if ((Flags & RDW_INVALIDATE) != 0 && (Flags & RDW_FRAME) == 0)
659 {
660 PREGION RgnClient;
661
662 RgnClient = IntSysCreateRectpRgnIndirect(&Wnd->rcClient);
663 if (RgnClient)
664 {
665 RgnType = IntGdiCombineRgn(Rgn, Rgn, RgnClient, RGN_AND);
666 REGION_Delete(RgnClient);
667 }
668 }
669
670 /*
671 * Clip the given region with window rectangle (or region)
672 */
673
674 if (!Wnd->hrgnClip || (Wnd->style & WS_MINIMIZE))
675 {
677 if (RgnWindow)
678 {
679 RgnType = IntGdiCombineRgn(Rgn, Rgn, RgnWindow, RGN_AND);
680 REGION_Delete(RgnWindow);
681 }
682 }
683 else
684 {
685 PREGION RgnClip = REGION_LockRgn(Wnd->hrgnClip);
686 if (RgnClip)
687 {
689 -Wnd->rcWindow.left,
690 -Wnd->rcWindow.top);
691 RgnType = IntGdiCombineRgn(Rgn, Rgn, RgnClip, RGN_AND);
693 Wnd->rcWindow.left,
694 Wnd->rcWindow.top);
695 REGION_UnlockRgn(RgnClip);
696 }
697 }
698 }
699 else
700 {
701 RgnType = NULLREGION;
702 }
703
704 /* Nothing to paint, just return */
705 if ((RgnType == NULLREGION && (Flags & RDW_INVALIDATE)) || RgnType == ERROR)
706 {
707 return;
708 }
709
710 /*
711 * Save current state of pending updates
712 */
713
714 HadPaintMessage = IntIsWindowDirty(Wnd);
715
716 /*
717 * Update the region and flags
718 */
719
720 // The following flags are used to invalidate the window.
722 {
724 {
726 }
727
728 if (Flags & RDW_INVALIDATE )
729 {
730 PREGION RgnUpdate;
731
732 Wnd->state &= ~WNDS_NONCPAINT;
733
734 /* If not the same thread set it dirty. */
735 if (Wnd->head.pti != PsGetCurrentThreadWin32Thread())
736 {
737 Wnd->state |= WNDS_UPDATEDIRTY;
738 if (Wnd->state2 & WNDS2_WMPAINTSENT)
740 }
741
742 if (Flags & RDW_FRAME)
743 Wnd->state |= WNDS_SENDNCPAINT;
744
745 if (Flags & RDW_ERASE)
747
748 if (RgnType != NULLREGION && Rgn > PRGN_WINDOW)
749 {
750 if (Wnd->hrgnUpdate == NULL)
751 {
752 Wnd->hrgnUpdate = NtGdiCreateRectRgn(0, 0, 0, 0);
754 }
755
756 if (Wnd->hrgnUpdate != HRGN_WINDOW)
757 {
758 RgnUpdate = REGION_LockRgn(Wnd->hrgnUpdate);
759 if (RgnUpdate)
760 {
761 RgnType = IntGdiCombineRgn(RgnUpdate, RgnUpdate, Rgn, RGN_OR);
762 REGION_UnlockRgn(RgnUpdate);
763 if (RgnType == NULLREGION)
764 {
767 Wnd->hrgnUpdate = NULL;
768 }
769 }
770 }
771 }
772
773 Flags |= RDW_ERASE|RDW_FRAME; // For children.
774
775 }
776
777 if (!HadPaintMessage && IntIsWindowDirty(Wnd))
778 {
779 MsqIncPaintCountQueue(Wnd->head.pti);
780 }
781
782 } // The following flags are used to validate the window.
784 {
786 return;
787
789 {
790 Wnd->state &= ~WNDS_INTERNALPAINT;
791 }
792
793 if (Flags & RDW_VALIDATE)
794 {
795 if (Flags & RDW_NOFRAME)
796 Wnd->state &= ~WNDS_SENDNCPAINT;
797
798 if (Flags & RDW_NOERASE)
800
801 if (Wnd->hrgnUpdate > HRGN_WINDOW && RgnType != NULLREGION && Rgn > PRGN_WINDOW)
802 {
803 PREGION RgnUpdate = REGION_LockRgn(Wnd->hrgnUpdate);
804
805 if (RgnUpdate)
806 {
807 RgnType = IntGdiCombineRgn(RgnUpdate, RgnUpdate, Rgn, RGN_DIFF);
808 REGION_UnlockRgn(RgnUpdate);
809
810 if (RgnType == NULLREGION)
811 {
814 Wnd->hrgnUpdate = NULL;
815 }
816 }
817 }
818 // If update is null, do not erase.
819 if (Wnd->hrgnUpdate == NULL)
820 {
822 }
823 }
824
825 if (HadPaintMessage && !IntIsWindowDirty(Wnd))
826 {
827 MsqDecPaintCountQueue(Wnd->head.pti);
828 }
829 }
830
831 /*
832 * Process children if needed
833 */
834
835 if (!(Flags & RDW_NOCHILDREN) &&
836 !(Wnd->style & WS_MINIMIZE) &&
837 ((Flags & RDW_ALLCHILDREN) || !(Wnd->style & WS_CLIPCHILDREN)))
838 {
839 PWND Child;
840
841 for (Child = Wnd->spwndChild; Child; Child = Child->spwndNext)
842 {
843 if (Child->style & WS_VISIBLE)
844 {
845 /*
846 * Recursive call to update children hrgnUpdate
847 */
848 PREGION RgnTemp = IntSysCreateRectpRgn(0, 0, 0, 0);
849 if (RgnTemp)
850 {
851 if (Rgn > PRGN_WINDOW) IntGdiCombineRgn(RgnTemp, Rgn, 0, RGN_COPY);
852 IntInvalidateWindows(Child, ((Rgn > PRGN_WINDOW)?RgnTemp:Rgn), Flags);
853 REGION_Delete(RgnTemp);
854 }
855 }
856 }
857 }
858 TRACE("IntInvalidateWindows exit\n");
859}
VOID FASTCALL MsqIncPaintCountQueue(PTHREADINFO pti)
Definition: msgqueue.c:501
#define GDI_OBJ_HMGR_PUBLIC
Definition: ntgdihdl.h:116
#define RDW_NOUPDATEDIRTY
Definition: painting.h:16
PREGION FASTCALL REGION_LockRgn(_In_ HRGN hrgn)
Definition: region.c:2358
VOID FASTCALL REGION_UnlockRgn(_In_ PREGION prgn)
Definition: region.c:2373
#define RDW_ERASE
Definition: winuser.h:1222
#define RDW_NOERASE
Definition: winuser.h:1226

Referenced by co_UserRedrawWindow(), co_WinPosSetWindowPos(), IntInvalidateWindows(), IntValidateParent(), IntValidateParents(), PaintSuspendedWindow(), and UserRedrawDesktop().

◆ IntIsWindowDirty()

BOOL FASTCALL IntIsWindowDirty ( PWND  Wnd)

Definition at line 1127 of file painting.c.

1128{
1129 return ( Wnd->style & WS_VISIBLE &&
1130 ( Wnd->hrgnUpdate != NULL ||
1131 Wnd->state & WNDS_INTERNALPAINT ) );
1132}

Referenced by IntFindWindowToRepaint(), and IntInvalidateWindows().

◆ IntIsWindowDrawable()

BOOL FASTCALL IntIsWindowDrawable ( PWND  Wnd)

Definition at line 870 of file painting.c.

871{
872 PWND WndObject;
873
874 for (WndObject = Wnd; WndObject != NULL; WndObject = WndObject->spwndParent)
875 {
876 if ( WndObject->state2 & WNDS2_INDESTROY ||
877 WndObject->state & WNDS_DESTROYED ||
878 !WndObject ||
879 !(WndObject->style & WS_VISIBLE) ||
880 ((WndObject->style & WS_MINIMIZE) && (WndObject != Wnd)))
881 {
882 return FALSE;
883 }
884 }
885
886 return TRUE;
887}
#define WNDS_DESTROYED
Definition: ntuser.h:636
#define WNDS2_INDESTROY
Definition: ntuser.h:648

Referenced by co_UserRedrawWindow(), IntScrollWindowEx(), and NtUserScrollWindowEx().

◆ IntPaintWindow()

VOID FASTCALL IntPaintWindow ( PWND  Window)

Definition at line 1186 of file painting.c.

1187{
1188 // Handle normal painting.
1190}

Referenced by IntDispatchMessage().

◆ IntPrintWindow()

BOOL FASTCALL IntPrintWindow ( PWND  pwnd,
HDC  hdcBlt,
UINT  nFlags 
)

Definition at line 1261 of file painting.c.

1265{
1266 HDC hdcSrc;
1267 INT cx, cy, xSrc, ySrc;
1268
1269 if ( nFlags & PW_CLIENTONLY)
1270 {
1271 cx = pwnd->rcClient.right - pwnd->rcClient.left;
1272 cy = pwnd->rcClient.bottom - pwnd->rcClient.top;
1273 xSrc = pwnd->rcClient.left - pwnd->rcWindow.left;
1274 ySrc = pwnd->rcClient.top - pwnd->rcWindow.top;
1275 }
1276 else
1277 {
1278 cx = pwnd->rcWindow.right - pwnd->rcWindow.left;
1279 cy = pwnd->rcWindow.bottom - pwnd->rcWindow.top;
1280 xSrc = 0;
1281 ySrc = 0;
1282 }
1283
1284 // TODO: Setup Redirection for Print.
1285 return FALSE;
1286
1287 /* Update the window just incase. */
1289
1291 /* Print window to printer context. */
1292 NtGdiBitBlt( hdcBlt,
1293 0,
1294 0,
1295 cx,
1296 cy,
1297 hdcSrc,
1298 xSrc,
1299 ySrc,
1300 SRCCOPY,
1302 0);
1303
1304 UserReleaseDC( pwnd, hdcSrc, FALSE);
1305
1306 // TODO: Release Redirection from Print.
1307
1308 return TRUE;
1309}
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
__kernel_entry W32KAPI BOOL APIENTRY NtGdiBitBlt(_In_ HDC hdcDst, _In_ INT x, _In_ INT y, _In_ INT cx, _In_ INT cy, _In_opt_ HDC hdcSrc, _In_ INT xSrc, _In_ INT ySrc, _In_ DWORD rop4, _In_ DWORD crBackColor, _In_ FLONG fl)
#define CLR_INVALID
Definition: wingdi.h:883
#define SRCCOPY
Definition: wingdi.h:333
#define DCX_WINDOW
Definition: winuser.h:2149
static HDC hdcSrc
Definition: xlate.c:32

Referenced by NtUserPrintWindow().

◆ IntSendChildNCPaint()

VOID FASTCALL IntSendChildNCPaint ( PWND  pWnd)

Definition at line 372 of file painting.c.

373{
374 pWnd = pWnd->spwndChild;
375 while (pWnd)
376 {
377 if ((pWnd->hrgnUpdate == NULL) && (pWnd->state & WNDS_SENDNCPAINT))
378 {
379 PWND Next;
381
382 /* Reference, IntSendNCPaint leaves win32k */
383 UserRefObjectCo(pWnd, &Ref);
385
386 /* Make sure to grab next one before dereferencing/freeing */
387 Next = pWnd->spwndNext;
388 UserDerefObjectCo(pWnd);
389 pWnd = Next;
390 }
391 else
392 {
393 pWnd = pWnd->spwndNext;
394 }
395 }
396}

Referenced by IntBeginPaint().

◆ IntSendNCPaint()

VOID FASTCALL IntSendNCPaint ( PWND  pWnd,
HRGN  hRgn 
)

Definition at line 350 of file painting.c.

351{
352 pWnd->state &= ~WNDS_SENDNCPAINT;
353
354 if ( pWnd == GetW32ThreadInfo()->MessageQueue->spwndActive &&
355 !(pWnd->state & WNDS_ACTIVEFRAME))
356 {
357 pWnd->state |= WNDS_ACTIVEFRAME;
358 pWnd->state &= ~WNDS_NONCPAINT;
360 }
361
363 {
364 pWnd->state2 &= ~WNDS2_FORCEFULLNCPAINTCLIPRGN;
366 }
367
369}
#define WNDS2_FORCEFULLNCPAINTCLIPRGN
Definition: ntuser.h:664
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:806
#define WM_NCPAINT
Definition: winuser.h:1715

Referenced by co_IntPaintWindows(), co_WinPosSetWindowPos(), ForceNCPaintErase(), IntBeginPaint(), and IntSendChildNCPaint().

◆ IntSendSyncPaint()

VOID FASTCALL IntSendSyncPaint ( PWND  Wnd,
ULONG  Flags 
)

Definition at line 132 of file painting.c.

133{
134 PTHREADINFO ptiCur, ptiWnd;
137 BOOL bSend = TRUE;
138
139 ptiWnd = Wnd->head.pti;
141 /*
142 Not the current thread, Wnd is in send Nonclient paint also in send erase background and it is visiable.
143 */
144 if ( Wnd->head.pti != ptiCur &&
145 Wnd->state & WNDS_SENDNCPAINT &&
147 Wnd->style & WS_VISIBLE)
148 {
149 // For testing, if you see this, break out the Champagne and have a party!
150 TRACE("SendSyncPaint Wnd in State!\n");
151 if (!IsListEmpty(&ptiWnd->SentMessagesListHead))
152 {
153 // Scan sent queue messages to see if we received sync paint messages.
156 do
157 {
158 TRACE("LOOP it\n");
159 if (Message->Msg.message == WM_SYNCPAINT &&
160 Message->Msg.hwnd == UserHMGetHandle(Wnd))
161 { // Already received so exit out.
162 ERR("SendSyncPaint Found one in the Sent Msg Queue!\n");
163 bSend = FALSE;
164 break;
165 }
166 Entry = Message->ListEntry.Flink;
168 }
169 while (Entry != &ptiWnd->SentMessagesListHead);
170 }
171 if (bSend)
172 {
173 TRACE("Sending WM_SYNCPAINT\n");
174 // This message has no parameters. But it does! Pass Flags along.
177 }
178 }
179
180 // Send to all the children if this is the desktop window.
181 if (UserIsDesktopWindow(Wnd))
182 {
183 if ( Flags & RDW_ALLCHILDREN ||
184 ( !(Flags & RDW_NOCHILDREN) && Wnd->style & WS_CLIPCHILDREN))
185 {
186 PWND spwndChild = Wnd->spwndChild;
187 while(spwndChild)
188 {
189 if ( spwndChild->style & WS_CHILD &&
190 spwndChild->head.pti != ptiCur)
191 {
192 spwndChild = spwndChild->spwndNext;
193 continue;
194 }
195 IntSendSyncPaint( spwndChild, Flags );
196 spwndChild = spwndChild->spwndNext;
197 }
198 }
199 }
200}
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define WNDS_SYNCPAINTPENDING
Definition: ntuser.h:628
Entry
Definition: section.c:5216
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY SentMessagesListHead
Definition: win32.h:100
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
VOID FASTCALL IntSendSyncPaint(PWND Wnd, ULONG Flags)
Definition: painting.c:132
LRESULT FASTCALL co_IntSendMessageNoWait(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1763
#define WM_SYNCPAINT
Definition: winuser.h:1718

Referenced by IntSendSyncPaint(), and UserSyncAndPaintWindows().

◆ IntValidateParents()

BOOL FASTCALL IntValidateParents ( PWND  Child,
BOOL  Recurse 
)

Definition at line 62 of file painting.c.

63{
64 RECTL ParentRect, Rect;
65 BOOL Start, Ret = TRUE;
66 PWND ParentWnd = Child;
67 PREGION Rgn = NULL;
68
69 if (ParentWnd->style & WS_CHILD)
70 {
71 do
72 ParentWnd = ParentWnd->spwndParent;
73 while (ParentWnd->style & WS_CHILD);
74 }
75
76 // No pending nonclient paints.
77 if (!(ParentWnd->state & WNDS_SYNCPAINTPENDING)) Recurse = FALSE;
78
79 Start = TRUE;
80 ParentWnd = Child->spwndParent;
81 while (ParentWnd)
82 {
83 if (ParentWnd->style & WS_CLIPCHILDREN)
84 break;
85
86 if (ParentWnd->hrgnUpdate != 0)
87 {
88 if (Recurse)
89 {
90 Ret = FALSE;
91 break;
92 }
93 // Start with child clipping.
94 if (Start)
95 {
96 Start = FALSE;
97
98 Rect = Child->rcWindow;
99
100 if (!IntIntersectWithParents(Child, &Rect)) break;
101
103
104 if (Child->hrgnClip)
105 {
106 PREGION RgnClip = REGION_LockRgn(Child->hrgnClip);
107 IntGdiCombineRgn(Rgn, Rgn, RgnClip, RGN_AND);
108 REGION_UnlockRgn(RgnClip);
109 }
110 }
111
112 ParentRect = ParentWnd->rcWindow;
113
114 if (!IntIntersectWithParents(ParentWnd, &ParentRect)) break;
115
116 IntInvalidateWindows( ParentWnd,
117 Rgn,
119 }
120 ParentWnd = ParentWnd->spwndParent;
121 }
122
123 if (Rgn) REGION_Delete(Rgn);
124
125 return Ret;
126}
return pTarget Start()

Referenced by co_IntUpdateWindows().

◆ NtUserBeginPaint()

HDC APIENTRY NtUserBeginPaint ( HWND  hWnd,
PAINTSTRUCT UnsafePs 
)

Definition at line 1614 of file painting.c.

1615{
1616 PWND Window;
1617 PAINTSTRUCT Ps;
1619 HDC hDC;
1621 HDC Ret = NULL;
1622
1623 TRACE("Enter NtUserBeginPaint\n");
1625
1627 {
1628 goto Cleanup; // Return NULL
1629 }
1630
1631 UserRefObjectCo(Window, &Ref);
1632
1633 hDC = IntBeginPaint(Window, &Ps);
1634
1635 Status = MmCopyToCaller(UnsafePs, &Ps, sizeof(PAINTSTRUCT));
1636 if (! NT_SUCCESS(Status))
1637 {
1639 goto Cleanup; // Return NULL
1640 }
1641
1642 Ret = hDC;
1643
1644Cleanup:
1646
1647 TRACE("Leave NtUserBeginPaint, ret=%p\n", Ret);
1648 UserLeave();
1649 return Ret;
1650}
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
static const WCHAR Cleanup[]
Definition: register.c:80
Status
Definition: gdiplustypes.h:24
#define MmCopyToCaller(x, y, z)
Definition: mmcopy.h:19
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
HDC FASTCALL IntBeginPaint(PWND Window, PPAINTSTRUCT Ps)
Definition: painting.c:1443
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
Definition: error.c:30

Referenced by BeginPaint().

◆ NtUserDrawCaption()

BOOL APIENTRY NtUserDrawCaption ( HWND  hWnd,
HDC  hDC,
LPCRECT  lpRc,
UINT  uFlags 
)

Definition at line 2456 of file painting.c.

2460{
2461 return NtUserDrawCaptionTemp(hWnd, hDC, lpRc, 0, 0, NULL, uFlags);
2462}
UINT uFlags
Definition: api.c:59
BOOL APIENTRY NtUserDrawCaptionTemp(HWND hWnd, HDC hDC, LPCRECT lpRc, HFONT hFont, HICON hIcon, const PUNICODE_STRING str, UINT uFlags)
Definition: painting.c:2373

Referenced by DrawCaption(), RealUserDrawCaption(), and UserPaintCaption().

◆ NtUserDrawCaptionTemp()

BOOL APIENTRY NtUserDrawCaptionTemp ( HWND  hWnd,
HDC  hDC,
LPCRECT  lpRc,
HFONT  hFont,
HICON  hIcon,
const PUNICODE_STRING  str,
UINT  uFlags 
)

Definition at line 2373 of file painting.c.

2381{
2382 PWND pWnd = NULL;
2383 UNICODE_STRING SafeStr = {0};
2385 RECTL SafeRect;
2386 BOOL Ret;
2387
2389
2390 if (hWnd != NULL)
2391 {
2392 if(!(pWnd = UserGetWindowObject(hWnd)))
2393 {
2394 UserLeave();
2395 return FALSE;
2396 }
2397 }
2398
2399 _SEH2_TRY
2400 {
2401 ProbeForRead(lpRc, sizeof(RECTL), sizeof(ULONG));
2402 RtlCopyMemory(&SafeRect, lpRc, sizeof(RECTL));
2403 if (str != NULL)
2404 {
2405 SafeStr = ProbeForReadUnicodeString(str);
2406 if (SafeStr.Length != 0)
2407 {
2408 ProbeForRead( SafeStr.Buffer,
2409 SafeStr.Length,
2410 sizeof(WCHAR));
2411 }
2412 }
2413 }
2415 {
2417 }
2418 _SEH2_END;
2419
2420 if (Status != STATUS_SUCCESS)
2421 {
2423 UserLeave();
2424 return FALSE;
2425 }
2426
2427 if (str != NULL)
2428 Ret = UserDrawCaption(pWnd, hDC, &SafeRect, hFont, hIcon, &SafeStr, uFlags);
2429 else
2430 {
2431 if ( RECTL_bIsEmptyRect(&SafeRect) && hFont == 0 && hIcon == 0 )
2432 {
2433 Ret = TRUE;
2435 {
2436 ERR("NC Caption Mode\n");
2438 goto Exit;
2439 }
2440 else if (uFlags & DC_DRAWFRAMEMD)
2441 {
2442 ERR("NC Paint Mode\n");
2443 NC_DoNCPaint(pWnd, hDC, uFlags); // Update Menus too!
2444 goto Exit;
2445 }
2446 }
2447 Ret = UserDrawCaption(pWnd, hDC, &SafeRect, hFont, hIcon, NULL, uFlags);
2448 }
2449Exit:
2450 UserLeave();
2451 return Ret;
2452}
HFONT hFont
Definition: main.c:53
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
HICON hIcon
Definition: msconfig.c:44
short WCHAR
Definition: pedump.c:58
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:204
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:104
#define _SEH2_END
Definition: pseh2_64.h:194
#define _SEH2_TRY
Definition: pseh2_64.h:93
const WCHAR * str
#define ProbeForReadUnicodeString(Ptr)
Definition: probe.h:77
#define STATUS_SUCCESS
Definition: shellext.h:65
static void Exit(void)
Definition: sock.c:1330
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG
Definition: typedefs.h:59
#define DC_DRAWCAPTIONMD
Definition: undocuser.h:152
#define DC_DRAWFRAMEMD
Definition: undocuser.h:154
BOOL UserDrawCaption(PWND pWnd, HDC hDc, RECTL *lpRc, HFONT hFont, HICON hIcon, const PUNICODE_STRING Str, UINT uFlags)
Definition: painting.c:2191
VOID UserDrawCaptionBar(PWND pWnd, HDC hDC, INT Flags)
Definition: nonclient.c:965
LRESULT NC_DoNCPaint(PWND pWnd, HDC hDC, INT Flags)
Definition: nonclient.c:1107

Referenced by DrawCaptionTempW(), and NtUserDrawCaption().

◆ NtUserEndPaint()

BOOL APIENTRY NtUserEndPaint ( HWND  hWnd,
CONST PAINTSTRUCT pUnsafePs 
)

Definition at line 1660 of file painting.c.

1661{
1663 PWND Window;
1664 PAINTSTRUCT Ps;
1666 BOOL Ret = FALSE;
1667
1668 TRACE("Enter NtUserEndPaint\n");
1670
1672 {
1673 goto Cleanup; // Return FALSE
1674 }
1675
1676 UserRefObjectCo(Window, &Ref); // Here for the exception.
1677
1678 _SEH2_TRY
1679 {
1680 ProbeForRead(pUnsafePs, sizeof(*pUnsafePs), 1);
1681 RtlCopyMemory(&Ps, pUnsafePs, sizeof(PAINTSTRUCT));
1682 }
1684 {
1686 }
1687 _SEH2_END
1688 if (!NT_SUCCESS(Status))
1689 {
1690 goto Cleanup; // Return FALSE
1691 }
1692
1693 Ret = IntEndPaint(Window, &Ps);
1694
1695Cleanup:
1697
1698 TRACE("Leave NtUserEndPaint, ret=%i\n", Ret);
1699 UserLeave();
1700 return Ret;
1701}
BOOL FASTCALL IntEndPaint(PWND Wnd, PPAINTSTRUCT Ps)
Definition: painting.c:1539

Referenced by EndPaint().

◆ NtUserExcludeUpdateRgn()

INT APIENTRY NtUserExcludeUpdateRgn ( HDC  hDC,
HWND  hWnd 
)

Definition at line 2518 of file painting.c.

2521{
2522 INT ret = ERROR;
2523 PWND pWnd;
2524
2525 TRACE("Enter NtUserExcludeUpdateRgn\n");
2527
2528 pWnd = UserGetWindowObject(hWnd);
2529
2530 if (hDC && pWnd)
2532
2533 TRACE("Leave NtUserExcludeUpdateRgn, ret=%i\n", ret);
2534
2535 UserLeave();
2536 return ret;
2537}
INT FASTCALL co_UserExcludeUpdateRgn(HDC hDC, PWND Window)
Definition: painting.c:2465

Referenced by ExcludeUpdateRgn().

◆ NtUserFillWindow()

BOOL APIENTRY NtUserFillWindow ( HWND  hWndParent,
HWND  hWnd,
HDC  hDC,
HBRUSH  hBrush 
)

Definition at line 1710 of file painting.c.

1714{
1715 BOOL ret = FALSE;
1716 PWND pWnd, pWndParent = NULL;
1718
1719 TRACE("Enter NtUserFillWindow\n");
1721
1722 if (!hDC)
1723 {
1724 goto Exit;
1725 }
1726
1727 if (!(pWnd = UserGetWindowObject(hWnd)))
1728 {
1729 goto Exit;
1730 }
1731
1732 if (hWndParent && !(pWndParent = UserGetWindowObject(hWndParent)))
1733 {
1734 goto Exit;
1735 }
1736
1737 UserRefObjectCo(pWnd, &Ref);
1738 ret = IntFillWindow( pWndParent, pWnd, hDC, hBrush );
1739 UserDerefObjectCo(pWnd);
1740
1741Exit:
1742 TRACE("Leave NtUserFillWindow, ret=%i\n",ret);
1743 UserLeave();
1744 return ret;
1745}
BOOL FASTCALL IntFillWindow(PWND pWndParent, PWND pWnd, HDC hDC, HBRUSH hBrush)
Definition: painting.c:1561

◆ NtUserFlashWindowEx()

BOOL APIENTRY NtUserFlashWindowEx ( IN PFLASHWINFO  pfwi)

Definition at line 1751 of file painting.c.

1752{
1753 PWND pWnd;
1754 FLASHWINFO finfo = {0};
1755 BOOL Ret = FALSE;
1756
1758
1759 _SEH2_TRY
1760 {
1761 ProbeForRead(pfwi, sizeof(FLASHWINFO), 1);
1762 RtlCopyMemory(&finfo, pfwi, sizeof(FLASHWINFO));
1763 }
1765 {
1767 _SEH2_YIELD(goto Exit);
1768 }
1769 _SEH2_END
1770
1771 if (!( pWnd = ValidateHwndNoErr(finfo.hwnd)) ||
1772 finfo.cbSize != sizeof(FLASHWINFO) ||
1773 finfo.dwFlags & ~(FLASHW_ALL|FLASHW_TIMER|FLASHW_TIMERNOFG) )
1774 {
1776 goto Exit;
1777 }
1778
1779 Ret = IntFlashWindowEx(pWnd, &finfo);
1780
1781Exit:
1782 UserLeave();
1783 return Ret;
1784}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:207
BOOL FASTCALL IntFlashWindowEx(PWND pWnd, PFLASHWINFO pfwi)
Definition: painting.c:1313
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:97
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:21

Referenced by FlashWindow(), and FlashWindowEx().

◆ NtUserGetUpdateRect()

BOOL APIENTRY NtUserGetUpdateRect ( HWND  hWnd,
LPRECT  UnsafeRect,
BOOL  bErase 
)

Definition at line 1961 of file painting.c.

1962{
1963 PWND Window;
1964 RECTL Rect;
1966 BOOL Ret = FALSE;
1967
1968 TRACE("Enter NtUserGetUpdateRect\n");
1970
1972 {
1973 goto Exit; // Return FALSE
1974 }
1975
1976 Ret = co_UserGetUpdateRect(Window, &Rect, bErase);
1977
1978 if (UnsafeRect != NULL)
1979 {
1980 Status = MmCopyToCaller(UnsafeRect, &Rect, sizeof(RECTL));
1981 if (!NT_SUCCESS(Status))
1982 {
1984 Ret = FALSE;
1985 }
1986 }
1987
1988Exit:
1989 TRACE("Leave NtUserGetUpdateRect, ret=%i\n", Ret);
1990 UserLeave();
1991 return Ret;
1992}
BOOL FASTCALL co_UserGetUpdateRect(PWND Window, PRECT pRect, BOOL bErase)
Definition: painting.c:1862

Referenced by GetUpdateRect().

◆ NtUserGetUpdateRgn()

INT APIENTRY NtUserGetUpdateRgn ( HWND  hWnd,
HRGN  hRgn,
BOOL  bErase 
)

Definition at line 1934 of file painting.c.

1935{
1936 PWND Window;
1937 INT ret = ERROR;
1938
1939 TRACE("Enter NtUserGetUpdateRgn\n");
1941
1943 if (Window)
1944 {
1945 ret = co_UserGetUpdateRgn(Window, hRgn, bErase);
1946 }
1947
1948 TRACE("Leave NtUserGetUpdateRgn, ret=%i\n", ret);
1949 UserLeave();
1950 return ret;
1951}
INT FASTCALL co_UserGetUpdateRgn(PWND Window, HRGN hRgn, BOOL bErase)
Definition: painting.c:1790

Referenced by GetUpdateRgn().

◆ NtUserInvalidateRect()

BOOL APIENTRY NtUserInvalidateRect ( HWND  hWnd,
CONST RECT lpUnsafeRect,
BOOL  bErase 
)

Definition at line 2541 of file painting.c.

2545{
2546 UINT flags = RDW_INVALIDATE | (bErase ? RDW_ERASE : 0);
2547 if (!hWnd)
2548 {
2550 lpUnsafeRect = NULL;
2551 }
2552 return NtUserRedrawWindow(hWnd, lpUnsafeRect, NULL, flags);
2553}
GLbitfield flags
Definition: glext.h:7161
BOOL APIENTRY NtUserRedrawWindow(HWND hWnd, CONST RECT *lprcUpdate, HRGN hrgnUpdate, UINT flags)
Definition: painting.c:2002

Referenced by ComboWndProc_common(), and InvalidateRect().

◆ NtUserInvalidateRgn()

BOOL APIENTRY NtUserInvalidateRgn ( HWND  hWnd,
HRGN  hRgn,
BOOL  bErase 
)

Definition at line 2557 of file painting.c.

2561{
2562 if (!hWnd)
2563 {
2565 return FALSE;
2566 }
2567 return NtUserRedrawWindow(hWnd, NULL, hRgn, RDW_INVALIDATE | (bErase? RDW_ERASE : 0));
2568}
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:1226

Referenced by InvalidateRgn().

◆ NtUserPrintWindow()

BOOL APIENTRY NtUserPrintWindow ( HWND  hwnd,
HDC  hdcBlt,
UINT  nFlags 
)

Definition at line 2572 of file painting.c.

2576{
2577 PWND Window;
2578 BOOL Ret = FALSE;
2579
2581
2582 if (hwnd)
2583 {
2584 if (!(Window = UserGetWindowObject(hwnd)) ||
2586 {
2587 goto Exit;
2588 }
2589
2590 if ( Window )
2591 {
2592 /* Validate flags and check it as a mask for 0 or 1. */
2593 if ( (nFlags & PW_CLIENTONLY) == nFlags)
2594 Ret = IntPrintWindow( Window, hdcBlt, nFlags);
2595 else
2597 }
2598 }
2599Exit:
2600 UserLeave();
2601 return Ret;
2602}
#define UserIsMessageWindow(pWnd)
Definition: desktop.h:197
BOOL FASTCALL IntPrintWindow(PWND pwnd, HDC hdcBlt, UINT nFlags)
Definition: painting.c:1261
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

◆ NtUserRedrawWindow()

BOOL APIENTRY NtUserRedrawWindow ( HWND  hWnd,
CONST RECT lprcUpdate,
HRGN  hrgnUpdate,
UINT  flags 
)

Definition at line 2002 of file painting.c.

2007{
2008 RECTL SafeUpdateRect;
2009 PWND Wnd;
2010 BOOL Ret = FALSE;
2013 PREGION RgnUpdate = NULL;
2014
2015 TRACE("Enter NtUserRedrawWindow\n");
2017
2019 {
2020 goto Exit; // Return FALSE
2021 }
2022
2023 if (lprcUpdate)
2024 {
2025 _SEH2_TRY
2026 {
2027 ProbeForRead(lprcUpdate, sizeof(RECTL), 1);
2028 RtlCopyMemory(&SafeUpdateRect, lprcUpdate, sizeof(RECTL));
2029 }
2031 {
2033 }
2034 _SEH2_END
2035 if (!NT_SUCCESS(Status))
2036 {
2038 goto Exit; // Return FALSE
2039 }
2040 }
2041
2045 {
2046 /* RedrawWindow fails only in case that flags are invalid */
2048 goto Exit; // Return FALSE
2049 }
2050
2051 /* We can't hold lock on GDI objects while doing roundtrips to user mode,
2052 * so it will be copied.
2053 */
2054 if (hrgnUpdate > HRGN_WINDOW)
2055 {
2056 RgnUpdate = REGION_LockRgn(hrgnUpdate);
2057 if (!RgnUpdate)
2058 {
2060 goto Exit; // Return FALSE
2061 }
2062 REGION_UnlockRgn(RgnUpdate);
2063 }
2064 else if (hrgnUpdate == HRGN_WINDOW) // Trap it out.
2065 {
2066 ERR("NTRW: Caller is passing Window Region 1\n");
2067 }
2068
2069 UserRefObjectCo(Wnd, &Ref);
2070
2071 Ret = co_UserRedrawWindow( Wnd,
2072 lprcUpdate ? &SafeUpdateRect : NULL,
2073 RgnUpdate,
2074 flags);
2075
2076 UserDerefObjectCo(Wnd);
2077
2078Exit:
2079 TRACE("Leave NtUserRedrawWindow, ret=%i\n", Ret);
2080 UserLeave();
2081 return Ret;
2082}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
BOOL FASTCALL co_UserRedrawWindow(PWND Window, const RECTL *UpdateRect, PREGION UpdateRgn, ULONG Flags)
Definition: painting.c:897
HWND FASTCALL IntGetDesktopWindow(VOID)
Definition: desktop.c:1397
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
#define ERROR_INVALID_FLAGS
Definition: winerror.h:907

Referenced by NtUserInvalidateRect(), NtUserInvalidateRgn(), NtUserValidateRect(), RedrawWindow(), SpiSetWallpaper(), START_TEST(), UpdateWindow(), and ValidateRgn().

◆ NtUserValidateRect()

BOOL APIENTRY NtUserValidateRect ( HWND  hWnd,
const RECT lpRect 
)

Definition at line 2608 of file painting.c.

2611{
2613 if (!hWnd)
2614 {
2616 lpRect = NULL;
2617 }
2618 return NtUserRedrawWindow(hWnd, lpRect, NULL, flags);
2619}

◆ PaintSuspendedWindow()

VOID FASTCALL PaintSuspendedWindow ( PWND  pwnd,
HRGN  hrgnOrig 
)

Definition at line 1027 of file painting.c.

1028{
1029 if (pwnd->hrgnUpdate)
1030 {
1031 HDC hDC;
1033 HRGN hrgnTemp;
1034 RECT Rect;
1035 INT type;
1036 PREGION prgn;
1037
1038 if (pwnd->hrgnUpdate > HRGN_WINDOW)
1039 {
1040 hrgnTemp = NtGdiCreateRectRgn(0, 0, 0, 0);
1041 type = NtGdiCombineRgn( hrgnTemp, pwnd->hrgnUpdate, 0, RGN_COPY);
1042 if (type == ERROR)
1043 {
1044 GreDeleteObject(hrgnTemp);
1045 hrgnTemp = HRGN_WINDOW;
1046 }
1047 }
1048 else
1049 {
1050 hrgnTemp = GreCreateRectRgnIndirect(&pwnd->rcWindow);
1051 }
1052
1053 if ( hrgnOrig &&
1054 hrgnTemp > HRGN_WINDOW &&
1055 NtGdiCombineRgn(hrgnTemp, hrgnTemp, hrgnOrig, RGN_AND) == NULLREGION)
1056 {
1057 GreDeleteObject(hrgnTemp);
1058 return;
1059 }
1060
1062
1063 Rect = pwnd->rcWindow;
1064 RECTL_vOffsetRect(&Rect, -pwnd->rcWindow.left, -pwnd->rcWindow.top);
1065
1066 // Clear out client area!
1068
1069 NC_DoNCPaint(pwnd, hDC, Flags); // Redraw without MENUs.
1070
1071 UserReleaseDC(pwnd, hDC, FALSE);
1072
1073 prgn = REGION_LockRgn(hrgnTemp);
1075 REGION_UnlockRgn(prgn);
1076
1077 // Set updates for this window.
1079
1080 // DCX_KEEPCLIPRGN is set. Check it anyway.
1081 if (hrgnTemp > HRGN_WINDOW && GreIsHandleValid(hrgnTemp)) GreDeleteObject(hrgnTemp);
1082 }
1083}
HGDIOBJ FASTCALL IntGetSysColorBrush(INT Object)
Definition: stockobj.c:317
#define DC_NOSENDMSG
Definition: undocuser.h:149
#define COLOR_WINDOW
Definition: winuser.h:929
#define DC_NC
Definition: winuser.h:440

Referenced by UpdateTheadChildren().

◆ UpdateTheadChildren()

VOID FASTCALL UpdateTheadChildren ( PWND  pWnd,
HRGN  hRgn 
)

Definition at line 1086 of file painting.c.

1087{
1088 PaintSuspendedWindow( pWnd, hRgn );
1089
1090 if (!(pWnd->style & WS_CLIPCHILDREN))
1091 return;
1092
1093 pWnd = pWnd->spwndChild; // invalidate children if any.
1094 while (pWnd)
1095 {
1096 UpdateTheadChildren( pWnd, hRgn );
1097 pWnd = pWnd->spwndNext;
1098 }
1099}
VOID FASTCALL PaintSuspendedWindow(PWND pwnd, HRGN hrgnOrig)
Definition: painting.c:1027
VOID FASTCALL UpdateTheadChildren(PWND pWnd, HRGN hRgn)
Definition: painting.c:1086

Referenced by UpdateTheadChildren(), and UpdateThreadWindows().

◆ UpdateThreadWindows()

VOID FASTCALL UpdateThreadWindows ( PWND  pWnd,
PTHREADINFO  pti,
HRGN  hRgn 
)

Definition at line 1102 of file painting.c.

1103{
1104 PWND pwndTemp;
1105
1106 for ( pwndTemp = pWnd;
1107 pwndTemp;
1108 pwndTemp = pwndTemp->spwndNext )
1109 {
1110 if (pwndTemp->head.pti == pti)
1111 {
1113 }
1114 else
1115 {
1116 if (IsThreadSuspended(pwndTemp->head.pti) || MsqIsHung(pwndTemp->head.pti, MSQ_HUNG))
1117 {
1118 UpdateTheadChildren(pwndTemp, hRgn);
1119 }
1120 else
1122 }
1123 }
1124}
BOOL FASTCALL IsThreadSuspended(PTHREADINFO pti)
Definition: msgqueue.c:2180
BOOL FASTCALL MsqIsHung(PTHREADINFO pti, DWORD TimeOut)
Definition: msgqueue.c:2149
#define MSQ_HUNG
Definition: msgqueue.h:3

Referenced by DefWndDoSizeMove().

◆ UserDrawCaption()

BOOL UserDrawCaption ( PWND  pWnd,
HDC  hDc,
RECTL lpRc,
HFONT  hFont,
HICON  hIcon,
const PUNICODE_STRING  Str,
UINT  uFlags 
)

Definition at line 2191 of file painting.c.

2199{
2200 BOOL Ret = FALSE;
2201 HBRUSH hBgBrush, hOldBrush = NULL;
2202 RECTL Rect = *lpRc;
2203 BOOL HasIcon;
2204
2206
2207 /* Determine whether the icon needs to be displayed */
2208 if (!hIcon && pWnd != NULL)
2209 {
2210 HasIcon = (uFlags & DC_ICON) && !(uFlags & DC_SMALLCAP) &&
2211 (pWnd->style & WS_SYSMENU) && !(pWnd->ExStyle & WS_EX_TOOLWINDOW);
2212 }
2213 else
2214 HasIcon = (hIcon != NULL);
2215
2216 // Draw the caption background
2217 if((uFlags & DC_GRADIENT) && !(uFlags & DC_INBUTTON))
2218 {
2219 static GRADIENT_RECT gcap = {0, 1};
2220 TRIVERTEX Vertices[2];
2221 COLORREF Colors[2];
2222
2225
2228
2229 Vertices[0].x = Rect.left;
2230 Vertices[0].y = Rect.top;
2231 Vertices[0].Red = (WORD)Colors[0]<<8;
2232 Vertices[0].Green = (WORD)Colors[0] & 0xFF00;
2233 Vertices[0].Blue = (WORD)(Colors[0]>>8) & 0xFF00;
2234 Vertices[0].Alpha = 0;
2235
2236 Vertices[1].x = Rect.right;
2237 Vertices[1].y = Rect.bottom;
2238 Vertices[1].Red = (WORD)Colors[1]<<8;
2239 Vertices[1].Green = (WORD)Colors[1] & 0xFF00;
2240 Vertices[1].Blue = (WORD)(Colors[1]>>8) & 0xFF00;
2241 Vertices[1].Alpha = 0;
2242
2243 if(!GreGradientFill(hDc, Vertices, 2, &gcap, 1, GRADIENT_FILL_RECT_H))
2244 {
2245 ERR("GreGradientFill() failed!\n");
2246 goto cleanup;
2247 }
2248 }
2249 else
2250 {
2251 if(uFlags & DC_INBUTTON)
2253 else if(uFlags & DC_ACTIVE)
2255 else
2257
2258 hOldBrush = NtGdiSelectBrush(hDc, hBgBrush);
2259
2260 if(!hOldBrush)
2261 {
2262 ERR("NtGdiSelectBrush() failed!\n");
2263 goto cleanup;
2264 }
2265
2266 if(!NtGdiPatBlt(hDc, Rect.left, Rect.top,
2267 Rect.right - Rect.left,
2268 Rect.bottom - Rect.top,
2269 PATCOPY))
2270 {
2271 ERR("NtGdiPatBlt() failed!\n");
2272 goto cleanup;
2273 }
2274 }
2275
2276 /* Draw icon */
2277 if (HasIcon)
2278 {
2279 PCURICON_OBJECT pIcon = NULL;
2280
2281 if (hIcon)
2282 {
2283 pIcon = UserGetCurIconObject(hIcon);
2284 }
2285 else if (pWnd)
2286 {
2287 pIcon = NC_IconForWindow(pWnd);
2288 // FIXME: NC_IconForWindow should reference it for us */
2289 if (pIcon)
2290 UserReferenceObject(pIcon);
2291 }
2292
2293 if (pIcon)
2294 {
2297 LONG x = Rect.left - cx/2 + 1 + (Rect.bottom - Rect.top)/2; // this is really what Window does
2298 LONG y = (Rect.top + Rect.bottom - cy)/2; // center
2299 UserDrawIconEx(hDc, x, y, pIcon, cx, cy, 0, NULL, DI_NORMAL);
2300 UserDereferenceObject(pIcon);
2301 }
2302 else
2303 {
2304 HasIcon = FALSE;
2305 }
2306 }
2307
2308 if (HasIcon)
2309 Rect.left += Rect.bottom - Rect.top;
2310
2311 if((uFlags & DC_TEXT))
2312 {
2313 BOOL Set = FALSE;
2314 Rect.left += 2;
2315
2316 if (Str)
2317 Set = UserDrawCaptionText(pWnd, hDc, Str, &Rect, uFlags, hFont);
2318 else if (pWnd != NULL) // FIXME: Windows does not do that
2319 {
2320 UNICODE_STRING ustr;
2321 ustr.Buffer = pWnd->strName.Buffer; // FIXME: LARGE_STRING truncated!
2322 ustr.Length = (USHORT)min(pWnd->strName.Length, MAXUSHORT);
2324 Set = UserDrawCaptionText(pWnd, hDc, &ustr, &Rect, uFlags, hFont);
2325 }
2326 if (pWnd)
2327 {
2328 if (Set)
2329 pWnd->state2 &= ~WNDS2_CAPTIONTEXTTRUNCATED;
2330 else
2332 }
2333 }
2334
2335 Ret = TRUE;
2336
2337cleanup:
2338 if (hOldBrush) NtGdiSelectBrush(hDc, hOldBrush);
2339
2340 return Ret;
2341}
Colors
Definition: ansiprsr.h:4
#define DC_ACTIVE
Definition: dc21x4.h:120
static void cleanup(void)
Definition: main.c:1335
unsigned short WORD
Definition: ntddk_ex.h:93
BOOL NTAPI GreGradientFill(HDC hdc, PTRIVERTEX pVertex, ULONG nVertex, PVOID pMesh, ULONG nMesh, ULONG ulMode)
Definition: fillshap.c:951
#define WNDS2_CAPTIONTEXTTRUNCATED
Definition: ntuser.h:666
DWORD FASTCALL IntGetSysColor(INT nIndex)
Definition: stockobj.c:323
#define min(a, b)
Definition: monoChain.cc:55
static BOOL Set
Definition: pageheap.c:10
#define WS_SYSMENU
Definition: pedump.c:629
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
__kernel_entry W32KAPI HBRUSH APIENTRY NtGdiSelectBrush(_In_ HDC hdc, _In_ HBRUSH hbrush)
__kernel_entry W32KAPI BOOL APIENTRY NtGdiPatBlt(_In_ HDC hdcDest, _In_ INT x, _In_ INT y, _In_ INT cx, _In_ INT cy, _In_ DWORD dwRop)
Definition: bitblt.c:988
COLOR16 Red
Definition: wingdi.h:3232
LONG y
Definition: wingdi.h:3231
COLOR16 Green
Definition: wingdi.h:3233
COLOR16 Alpha
Definition: wingdi.h:3235
COLOR16 Blue
Definition: wingdi.h:3234
LONG x
Definition: wingdi.h:3230
USHORT MaximumLength
Definition: env_spec_w32.h:370
LARGE_UNICODE_STRING strName
Definition: ntuser.h:736
#define MAXUSHORT
Definition: typedefs.h:83
BOOL UserDrawCaptionText(PWND pWnd, HDC hDc, const PUNICODE_STRING Text, const RECTL *lpRc, UINT uFlags, HFONT hFont)
Definition: painting.c:2085
VOID FASTCALL RECTL_vMakeWellOrdered(_Inout_ RECTL *prcl)
Definition: rect.c:81
PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon)
Definition: cursoricon.c:200
BOOL UserDrawIconEx(HDC hDc, INT xLeft, INT yTop, PCURICON_OBJECT pIcon, INT cxWidth, INT cyHeight, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags)
Definition: cursoricon.c:1691
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:209
PCURICON_OBJECT FASTCALL NC_IconForWindow(PWND pWnd)
Definition: nonclient.c:746
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:643
VOID FASTCALL UserReferenceObject(PVOID obj)
Definition: object.c:730
DWORD COLORREF
Definition: windef.h:100
#define DI_NORMAL
Definition: wingdi.h:72
#define PATCOPY
Definition: wingdi.h:335
#define DC_INBUTTON
Definition: winuser.h:431
#define COLOR_GRADIENTINACTIVECAPTION
Definition: winuser.h:956
#define COLOR_ACTIVECAPTION
Definition: winuser.h:926
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
#define SM_CYSMICON
Definition: winuser.h:1024
#define COLOR_INACTIVECAPTION
Definition: winuser.h:927
#define COLOR_GRADIENTACTIVECAPTION
Definition: winuser.h:955
#define SM_CXSMICON
Definition: winuser.h:1023
#define DC_TEXT
Definition: winuser.h:430
#define DC_ICON
Definition: winuser.h:429
#define DC_SMALLCAP
Definition: winuser.h:428
#define COLOR_3DFACE
Definition: winuser.h:940

Referenced by NC_DoNCPaint(), NtUserDrawCaptionTemp(), and UserDrawCaptionBar().

◆ UserDrawCaptionText()

BOOL UserDrawCaptionText ( PWND  pWnd,
HDC  hDc,
const PUNICODE_STRING  Text,
const RECTL lpRc,
UINT  uFlags,
HFONT  hFont 
)

Definition at line 2085 of file painting.c.

2092{
2093 HFONT hOldFont = NULL;
2094 COLORREF OldTextColor;
2095 NONCLIENTMETRICSW nclm;
2097 BOOLEAN bDeleteFont = FALSE;
2098 SIZE Size;
2099 BOOL Ret = TRUE;
2100 ULONG fit = 0, Length;
2101 RECTL r = *lpRc;
2102
2103 TRACE("UserDrawCaptionText: %wZ\n", Text);
2104
2105 nclm.cbSize = sizeof(nclm);
2106 if (!UserSystemParametersInfo(SPI_GETNONCLIENTMETRICS, nclm.cbSize, &nclm, 0))
2107 {
2108 ERR("UserSystemParametersInfo() failed!\n");
2109 return FALSE;
2110 }
2111
2112 if (!hFont)
2113 {
2114 if(uFlags & DC_SMALLCAP)
2115 Status = TextIntCreateFontIndirect(&nclm.lfSmCaptionFont, &hFont);
2116 else
2117 Status = TextIntCreateFontIndirect(&nclm.lfCaptionFont, &hFont);
2118
2119 if(!NT_SUCCESS(Status))
2120 {
2121 ERR("TextIntCreateFontIndirect() failed! Status: 0x%x\n", Status);
2122 return FALSE;
2123 }
2124
2125 bDeleteFont = TRUE;
2126 }
2127
2129
2130 hOldFont = NtGdiSelectFont(hDc, hFont);
2131
2132 if(uFlags & DC_INBUTTON)
2133 OldTextColor = IntGdiSetTextColor(hDc, IntGetSysColor(COLOR_BTNTEXT));
2134 else
2135 OldTextColor = IntGdiSetTextColor(hDc,
2137
2138 // Adjust for system menu.
2139 if (pWnd && pWnd->style & WS_SYSMENU)
2140 {
2141 r.right -= UserGetSystemMetrics(SM_CYCAPTION) - 1;
2142 if ((pWnd->style & (WS_MAXIMIZEBOX | WS_MINIMIZEBOX)) && !(pWnd->ExStyle & WS_EX_TOOLWINDOW))
2143 {
2144 r.right -= UserGetSystemMetrics(SM_CXSIZE) + 1;
2145 r.right -= UserGetSystemMetrics(SM_CXSIZE) + 1;
2146 }
2147 }
2148
2149 GreGetTextExtentExW(hDc, Text->Buffer, Text->Length/sizeof(WCHAR), r.right - r.left, &fit, 0, &Size, 0);
2150
2151 Length = (Text->Length/sizeof(WCHAR) == fit ? fit : fit+1);
2152
2153 if (Text->Length/sizeof(WCHAR) > Length)
2154 {
2155 Ret = FALSE;
2156 }
2157
2158 if (Ret)
2159 { // Faster while in setup.
2160 UserExtTextOutW( hDc,
2161 lpRc->left,
2162 lpRc->top + (lpRc->bottom - lpRc->top - Size.cy) / 2, // DT_SINGLELINE && DT_VCENTER
2164 (RECTL *)lpRc,
2165 Text->Buffer,
2166 Length);
2167 }
2168 else
2169 {
2170 DrawTextW( hDc,
2171 Text->Buffer,
2172 Text->Length/sizeof(WCHAR),
2173 (RECTL *)&r,
2175 }
2176
2177 IntGdiSetTextColor(hDc, OldTextColor);
2178
2179 if (hOldFont)
2180 NtGdiSelectFont(hDc, hOldFont);
2181
2182 if (bDeleteFont)
2184
2185 return Ret;
2186}
unsigned char BOOLEAN
Definition: actypes.h:127
char * Text
Definition: combotst.c:136
COLORREF FASTCALL IntGdiSetTextColor(HDC hDC, COLORREF color)
Definition: dcutil.c:172
INT FASTCALL IntGdiSetBkMode(HDC hDC, INT backgroundMode)
Definition: dcutil.c:124
NTSTATUS FASTCALL TextIntCreateFontIndirect(CONST LPLOGFONTW lf, HFONT *NewFont)
Definition: freetype.c:2612
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:16
#define WS_MAXIMIZEBOX
Definition: pedump.c:632
#define WS_MINIMIZEBOX
Definition: pedump.c:631
__kernel_entry W32KAPI HFONT APIENTRY NtGdiSelectFont(_In_ HDC hdc, _In_ HFONT hf)
Definition: dcobjs.c:597
long bottom
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
BOOL UserExtTextOutW(HDC hdc, INT x, INT y, UINT flags, PRECTL lprc, LPCWSTR lpString, UINT count)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
BOOL FASTCALL GreGetTextExtentExW(_In_ HDC hDC, _In_ PCWCH String, _In_ ULONG Count, _In_ ULONG MaxExtent, _Out_opt_ PULONG Fit, _Out_writes_to_opt_(Count, *Fit) PULONG Dx, _Out_ PSIZE pSize, _In_ FLONG fl)
Definition: text.c:133
BOOL FASTCALL UserSystemParametersInfo(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni)
Definition: sysparams.c:2123
#define TRANSPARENT
Definition: wingdi.h:950
#define ETO_CLIPPED
Definition: wingdi.h:648
#define DT_NOPREFIX
Definition: winuser.h:537
#define COLOR_BTNTEXT
Definition: winuser.h:944
#define COLOR_INACTIVECAPTIONTEXT
Definition: winuser.h:945
#define DT_END_ELLIPSIS
Definition: winuser.h:529
#define DT_SINGLELINE
Definition: winuser.h:540
#define SM_CXSIZE
Definition: winuser.h:1002
#define DT_LEFT
Definition: winuser.h:534
#define DT_VCENTER
Definition: winuser.h:543
#define COLOR_CAPTIONTEXT
Definition: winuser.h:933
#define SM_CYCAPTION
Definition: winuser.h:974

Referenced by UserDrawCaption().

◆ UserExtTextOutW()

BOOL UserExtTextOutW ( HDC  hdc,
INT  x,
INT  y,
UINT  flags,
PRECTL  lprc,
LPCWSTR  lpString,
UINT  count 
)

◆ UserRealizePalette()

INT FASTCALL UserRealizePalette ( HDC  hdc)

Definition at line 2345 of file painting.c.

2346{
2347 HWND hWnd, hWndDesktop;
2348 DWORD Ret;
2349
2351 if (Ret) // There was a change.
2352 {
2354 if (hWnd) // Send broadcast if dc is associated with a window.
2355 { // FYI: Thread locked in CallOneParam.
2356 hWndDesktop = IntGetDesktopWindow();
2357 if ( hWndDesktop != hWnd )
2358 {
2359 PWND pWnd = UserGetWindowObject(hWndDesktop);
2360 ERR("RealizePalette Desktop.\n");
2361 hdc = UserGetWindowDC(pWnd);
2363 UserReleaseDC(pWnd,hdc,FALSE);
2364 }
2366 }
2367 }
2368 return Ret;
2369}
UINT FASTCALL IntGdiRealizePalette(HDC)
Definition: palette.c:749
HWND FASTCALL IntWindowFromDC(HDC hDc)
Definition: windc.c:894
unsigned long DWORD
Definition: ntddk_ex.h:95
HDC FASTCALL UserGetWindowDC(PWND Wnd)
Definition: windc.c:947
BOOL FASTCALL IntPaintDesktop(HDC hDC)
Definition: desktop.c:1852
BOOL FASTCALL UserSendNotifyMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:2090
#define HWND_BROADCAST
Definition: winuser.h:1215
#define WM_PALETTECHANGED
Definition: winuser.h:1905

◆ UserSyncAndPaintWindows()

VOID FASTCALL UserSyncAndPaintWindows ( PWND  pWnd,
ULONG  Flags 
)

Definition at line 623 of file painting.c.

624{
625 PWND Parent = pWnd;
626 // Find parent, if it needs to be painted, leave.
627 while(TRUE)
628 {
629 if ((Parent = Parent->spwndParent) == NULL) break;
630 if ( Parent->style & WS_CLIPCHILDREN ) break;
631 if ( Parent->hrgnUpdate != NULL || Parent->state & WNDS_INTERNALPAINT ) return;
632 }
633
634 IntSendSyncPaint(pWnd, Flags);
636}
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:732

Referenced by co_UserRedrawWindow(), and co_WinPosSetWindowPos().

◆ UserUpdateWindows()

VOID FASTCALL UserUpdateWindows ( PWND  pWnd,
ULONG  Flags 
)

Definition at line 601 of file painting.c.

602{
603 // If transparent and any sibling windows below needs to be painted, leave.
604 if (pWnd->ExStyle & WS_EX_TRANSPARENT)
605 {
606 PWND Next = pWnd->spwndNext;
607
608 while(Next)
609 {
610 if ( Next->head.pti == pWnd->head.pti &&
611 ( Next->hrgnUpdate != NULL || Next->state & WNDS_INTERNALPAINT) )
612 {
613 return;
614 }
615
616 Next = Next->spwndNext;
617 }
618 }
620}

Referenced by co_UserRedrawWindow(), and UpdateThreadWindows().