Author: jimtabor
Date: Tue Jun 2 10:50:36 2009
New Revision: 41250
URL:
http://svn.reactos.org/svn/reactos?rev=41250&view=rev
Log:
- Hax-implement NtGdiSetPixelFormat and add a support function UserGethWnd with some code
cleanup.
Modified:
trunk/reactos/subsystems/win32/win32k/include/dce.h
trunk/reactos/subsystems/win32/win32k/ntuser/painting.c
trunk/reactos/subsystems/win32/win32k/ntuser/windc.c
trunk/reactos/subsystems/win32/win32k/objects/wingl.c
Modified: trunk/reactos/subsystems/win32/win32k/include/dce.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/dce.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/dce.h [iso-8859-1] Tue Jun 2 10:50:36
2009
@@ -56,5 +56,6 @@
void FASTCALL DceEmptyCache(void);
VOID FASTCALL DceResetActiveDCEs(PWINDOW_OBJECT Window);
void FASTCALL DceFreeClassDCE(HDC);
+HWND FASTCALL UserGethWnd(HDC,PWNDOBJ*);
#endif /* _WIN32K_DCE_H */
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/painting.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/painting.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/painting.c [iso-8859-1] Tue Jun 2
10:50:36 2009
@@ -1922,18 +1922,18 @@
ProbeForRead(lpRc, sizeof(RECTL), sizeof(ULONG));
RtlCopyMemory(&SafeRect, lpRc, sizeof(RECTL));
if (str != NULL)
- {
- SafeStr = ProbeForReadUnicodeString(str);
- if (SafeStr.Length != 0)
- {
- ProbeForRead(SafeStr.Buffer,
- SafeStr.Length,
- sizeof(WCHAR));
- }
- Ret = UserDrawCaption(pWnd, hDC, &SafeRect, hFont, hIcon, &SafeStr, uFlags);
- }
- else
- Ret = UserDrawCaption(pWnd, hDC, &SafeRect, hFont, hIcon, NULL, uFlags);
+ {
+ SafeStr = ProbeForReadUnicodeString(str);
+ if (SafeStr.Length != 0)
+ {
+ ProbeForRead( SafeStr.Buffer,
+ SafeStr.Length,
+ sizeof(WCHAR));
+ }
+ Ret = UserDrawCaption(pWnd, hDC, &SafeRect, hFont, hIcon, &SafeStr,
uFlags);
+ }
+ else
+ Ret = UserDrawCaption(pWnd, hDC, &SafeRect, hFont, hIcon, NULL, uFlags);
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/windc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/windc.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/windc.c [iso-8859-1] Tue Jun 2 10:50:36
2009
@@ -864,6 +864,36 @@
UserGetWindowDC(PWINDOW_OBJECT Wnd)
{
return UserGetDCEx(Wnd, 0, DCX_USESTYLE | DCX_WINDOW);
+}
+
+HWND FASTCALL
+UserGethWnd( HDC hdc, PWNDOBJ *pwndo)
+{
+ PWNDGDI pWndgdi;
+ PWINDOW_OBJECT Wnd = NULL;
+ HWND hWnd;
+ BOOL Hit = FALSE;
+ PLIST_ENTRY Entry;
+ hWnd = IntWindowFromDC(hdc);
+
+ if (hWnd && !(Wnd = UserGetWindowObject(hWnd)))
+ {
+ KeEnterCriticalRegion();
+ Entry = Wnd->WndObjListHead.Flink;
+ while (Entry != &Wnd->WndObjListHead)
+ {
+ pWndgdi = (PWNDGDI)Entry;
+ if (pWndgdi->Hwnd == hWnd)
+ {
+ Hit = TRUE;
+ break;
+ }
+ Entry = Entry->Flink;
+ }
+ if (pwndo && Hit) *pwndo = (PWNDOBJ)pWndgdi;
+ KeLeaveCriticalRegion();
+ }
+ return hWnd;
}
HDC APIENTRY
Modified: trunk/reactos/subsystems/win32/win32k/objects/wingl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/wingl.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/wingl.c [iso-8859-1] Tue Jun 2 10:50:36
2009
@@ -38,7 +38,6 @@
if (ppdev->DriverFunctions.DescribePixelFormat)
{
-
Ret = ppdev->DriverFunctions.DescribePixelFormat(
ppdev->hPDev,
1,
@@ -94,7 +93,6 @@
if (ppdev->DriverFunctions.DescribePixelFormat)
{
-
Ret = ppdev->DriverFunctions.DescribePixelFormat(
ppdev->hPDev,
PixelFormat,
@@ -129,8 +127,77 @@
IN HDC hdc,
IN INT ipfd)
{
- UNIMPLEMENTED;
- return FALSE;
+ PDC pdc;
+ PPDEVOBJ ppdev;
+ HWND hWnd;
+ PWNDOBJ pWndObj;
+ SURFOBJ *pso = NULL;
+ BOOL Ret = FALSE;
+
+ pdc = DC_LockDc(hdc);
+ if (!pdc)
+ {
+ SetLastWin32Error(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+
+ if (!pdc->ipfdDevMax) IntGetipfdDevMax(pdc);
+
+ if ( ipfd < 1 ||
+ ipfd > pdc->ipfdDevMax )
+ {
+ SetLastWin32Error(ERROR_INVALID_PARAMETER);
+ goto Exit;
+ }
+
+ UserEnterExclusive();
+ hWnd = UserGethWnd(hdc, &pWndObj);
+ UserLeave();
+
+ if (!hWnd)
+ {
+ SetLastWin32Error(ERROR_INVALID_WINDOW_STYLE);
+ goto Exit;
+ }
+
+ ppdev = pdc->ppdev;
+
+ if (pWndObj) pso = pWndObj->psoOwner;
+ else
+ {
+ SetLastWin32Error(ERROR_INVALID_PIXEL_FORMAT);
+ goto Exit;
+ }
+
+ if (!pso)
+ {
+ /*
+ Based on some rules! InfoDC to DC or, based on wiki information!
+ All pointers, it's a "must be!", (CONTAINING_RECORD +10h = SURFOBJ),
the
+ pointer will start at SURFOBJ of the SURFACE structure.
+ */
+ pso = (SURFOBJ *)pdc->dclevel.pSurface;
+ if (!pso) pso = pdc->pSurfInfo;
+ if (!pso) pso = ppdev->pSurface;
+ }
+
+ if (ppdev->flFlags & PDEV_META_DEVICE)
+ {
+ UNIMPLEMENTED;
+ goto Exit;
+ }
+
+ if (ppdev->DriverFunctions.SetPixelFormat)
+ {
+ Ret = ppdev->DriverFunctions.SetPixelFormat(
+ pso,
+ ipfd,
+ hWnd);
+ }
+
+Exit:
+ DC_UnlockDc(pdc);
+ return Ret;
}
BOOL