Author: tkreuzer
Date: Sat Apr 3 19:30:00 2010
New Revision: 46701
URL:
http://svn.reactos.org/svn/reactos?rev=46701&view=rev
Log:
[WIN32K]
- use a macro in RegReadDisplaySettings to make things smaller
- Send WM_DISPLAYCHANGE to all toplevel windows when changing mode
- leave UserChangeDisplaySettings when mode switching failed
Modified:
branches/reactos-yarotows/subsystems/win32/win32k/ntuser/display.c
Modified: branches/reactos-yarotows/subsystems/win32/win32k/ntuser/display.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/ntuser/display.c [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/ntuser/display.c [iso-8859-1] Sat
Apr 3 19:30:00 2010
@@ -78,68 +78,30 @@
{
DWORD dwValue;
+ /* Zero out the structure */
RtlZeroMemory(pdm, sizeof(DEVMODEW));
- if (RegReadDWORD(hkey, L"DefaultSettings.BitsPerPel", &dwValue))
- {
- pdm->dmBitsPerPel = dwValue;
- pdm->dmFields |= DM_BITSPERPEL;
- }
- if (RegReadDWORD(hkey, L"DefaultSettings.XResolution", &dwValue))
- {
- pdm->dmPelsWidth = dwValue;
-// pdm->dmFields |= DM_XRESOLUTION;
- }
- if (RegReadDWORD(hkey, L"DefaultSettings.YResolution", &dwValue))
- {
- pdm->dmPelsHeight = dwValue;
- pdm->dmFields |= DM_YRESOLUTION;
- }
- if (RegReadDWORD(hkey, L"DefaultSettings.Flags", &dwValue))
- {
- pdm->dmDisplayFlags = dwValue;
- pdm->dmFields |= DM_BITSPERPEL;
- }
- if (RegReadDWORD(hkey, L"DefaultSettings.VRefresh", &dwValue))
- {
- pdm->dmDisplayFrequency = dwValue;
- pdm->dmFields |= DM_DISPLAYFREQUENCY;
- }
- if (RegReadDWORD(hkey, L"DefaultSettings.XPanning", &dwValue))
- {
- pdm->dmPanningWidth = dwValue;
- pdm->dmFields |= DM_PANNINGWIDTH;
- }
- if (RegReadDWORD(hkey, L"DefaultSettings.YPanning", &dwValue))
- {
- pdm->dmPanningHeight = dwValue;
- pdm->dmFields |= DM_PANNINGHEIGHT;
- }
- if (RegReadDWORD(hkey, L"DefaultSettings.Orientation", &dwValue))
- {
- pdm->dmDisplayOrientation = dwValue;
- pdm->dmFields |= DM_DISPLAYORIENTATION;
- }
- if (RegReadDWORD(hkey, L"DefaultSettings.FixedOutput", &dwValue))
- {
- pdm->dmDisplayFixedOutput = dwValue;
- pdm->dmFields |= DM_BITSPERPEL;
- }
- if (RegReadDWORD(hkey, L"Attach.RelativeX", &dwValue))
- {
- pdm->dmPosition.x = dwValue;
- pdm->dmFields |= DM_POSITION;
- }
- if (RegReadDWORD(hkey, L"Attach.RelativeY", &dwValue))
- {
- pdm->dmPosition.y = dwValue;
- pdm->dmFields |= DM_POSITION;
- }
-// RegReadDWORD(hkey, L"Attach.ToDesktop, pdm->dmBitsPerPel",
&pdm->);
-
-}
-
-
+/* Helper macro */
+#define READ(field, str, flag) \
+ if (RegReadDWORD(hkey, L##str, &dwValue)) \
+ { \
+ pdm->field = dwValue; \
+ pdm->dmFields |= flag; \
+ }
+
+ /* Read all present settings */
+ READ(dmBitsPerPel, "DefaultSettings.BitsPerPel", DM_BITSPERPEL);
+ READ(dmPelsWidth, "DefaultSettings.XResolution", DM_YRESOLUTION); //
DM_XRESOLUTION?
+ READ(dmPelsHeight, "DefaultSettings.YResolution", DM_YRESOLUTION);
+ READ(dmDisplayFlags, "DefaultSettings.Flags", DM_DISPLAYFLAGS);
+ READ(dmDisplayFrequency, "DefaultSettings.VRefresh", DM_DISPLAYFREQUENCY);
+ READ(dmPanningWidth, "DefaultSettings.XPanning", DM_PANNINGWIDTH);
+ READ(dmPanningHeight, "DefaultSettings.YPanning", DM_PANNINGHEIGHT);
+ READ(dmDisplayOrientation, "DefaultSettings.Orientation",
DM_DISPLAYORIENTATION);
+ READ(dmDisplayFixedOutput, "DefaultSettings.FixedOutput",
DM_DISPLAYFIXEDOUTPUT);
+ READ(dmPosition.x, "Attach.RelativeX", DM_POSITION);
+ READ(dmPosition.y, "Attach.RelativeY", DM_POSITION);
+}
enum
@@ -794,6 +756,8 @@
DPRINT1("failed to set mode\n");
lResult = (lResult == DISP_CHANGE_NOTUPDATED) ?
DISP_CHANGE_FAILED : DISP_CHANGE_RESTART;
+
+ goto leave;
}
/* Update the system metrics */
@@ -801,19 +765,27 @@
/* Remove all cursor clipping */
UserClipCursor(NULL);
+
+ //IntvGetDeviceCaps(&PrimarySurface, &GdiHandleTable->DevCaps);
pdesk = IntGetActiveDesktop();
IntHideDesktop(pdesk);
co_IntShowDesktop(pdesk, ppdev->gdiinfo.ulHorzRes,
ppdev->gdiinfo.ulVertRes);
- //UserRedrawDesktop();
-
- //IntvGetDeviceCaps(&PrimarySurface, &GdiHandleTable->DevCaps);
-
- /* Send message */
-
+
+ UserRedrawDesktop();
+
+ /* Send WM_DISPLAYCHANGE to all toplevel windows */
+ co_IntSendMessageTimeout(HWND_BROADCAST,
+ WM_DISPLAYCHANGE,
+ (WPARAM)ppdev->gdiinfo.cBitsPixel,
+ (LPARAM)(ppdev->gdiinfo.ulHorzRes +
(ppdev->gdiinfo.ulHorzRes << 16)),
+ SMTO_NORMAL,
+ 100,
+ &ulResult);
}
leave:
+ /* Release the PDEV */
PDEVOBJ_vRelease(ppdev);
return lResult;
@@ -831,7 +803,7 @@
WCHAR awcDevice[CCHDEVICENAME];
UNICODE_STRING ustrDevice;
DEVMODEW dmLocal;
- LONG Ret;
+ LONG lRet;
/* Check arguments */
if ((dwflags != CDS_VIDEOPARAMETERS && lParam != NULL) ||
@@ -864,6 +836,7 @@
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
+ /* Set and return error */
SetLastNtError(_SEH2_GetExceptionCode());
_SEH2_YIELD(return DISP_CHANGE_BADPARAM);
}
@@ -877,35 +850,48 @@
{
_SEH2_TRY
{
+ /* Probe the size field of the structure */
ProbeForRead(lpDevMode, sizeof(dmLocal.dmSize), 1);
+
+ /* Calculate usable size */
dmLocal.dmSize = min(sizeof(dmLocal), lpDevMode->dmSize);
+
+ /* Probe and copy the full DEVMODE */
ProbeForRead(lpDevMode, dmLocal.dmSize, 1);
RtlCopyMemory(&dmLocal, lpDevMode, dmLocal.dmSize);
dmLocal.dmSize = sizeof(dmLocal);
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
+ /* Set and return error */
SetLastNtError(_SEH2_GetExceptionCode());
_SEH2_YIELD(return DISP_CHANGE_BADPARAM);
}
_SEH2_END
+ /* Check for extra parameters */
if (dmLocal.dmDriverExtra > 0)
{
+ /* FIXME: TODO */
DPRINT1("lpDevMode->dmDriverExtra is IGNORED!\n");
dmLocal.dmDriverExtra = 0;
}
+
+ /* Use the local structure */
lpDevMode = &dmLocal;
}
// FIXME: Copy videoparameters
+
+ /* Acquire global USER lock */
UserEnterExclusive();
/* Call internal function */
- Ret = UserChangeDisplaySettings(pustrDevice, lpDevMode, hwnd, dwflags, NULL);
-
+ lRet = UserChangeDisplaySettings(pustrDevice, lpDevMode, hwnd, dwflags, NULL);
+
+ /* Release lock */
UserLeave();
- return Ret;
-}
-
+ return lRet;
+}
+