Author: gadamopoulos Date: Mon Feb 20 13:23:32 2012 New Revision: 55755
URL: http://svn.reactos.org/svn/reactos?rev=55755&view=rev Log: [win32k] - Do not store the PDEVOBJ and a fake name in MONITOR struct. Use MONITOR.HDEV instead (which is an opaque pointer to a PDEVOBJ)
Modified: trunk/reactos/subsystems/win32/win32k/include/monitor.h trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c trunk/reactos/subsystems/win32/win32k/ntuser/display.c trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c trunk/reactos/subsystems/win32/win32k/ntuser/sysparams.c trunk/reactos/subsystems/win32/win32k/ntuser/window.c trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c trunk/reactos/subsystems/win32/win32k/objects/device.c
Modified: trunk/reactos/subsystems/win32/win32k/include/monitor.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/inc... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/monitor.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/include/monitor.h [iso-8859-1] Mon Feb 20 13:23:32 2012 @@ -21,18 +21,13 @@ SHORT cFullScreen; SHORT cWndStack; HDEV hDev; - - // ReactOS specific fields: - UNICODE_STRING DeviceName; /* Name of the monitor */ - PDEVOBJ *GdiDevice; /* Pointer to the GDI device to - which this monitor is attached */ } MONITOR, *PMONITOR;
-NTSTATUS IntAttachMonitor(PDEVOBJ *pGdiDevice, ULONG DisplayNumber); -NTSTATUS IntDetachMonitor(PDEVOBJ *pGdiDevice); -NTSTATUS IntUpdateMonitorSize(IN PDEVOBJ *pGdiDevice); -PMONITOR FASTCALL UserGetMonitorObject(IN HMONITOR); -PMONITOR FASTCALL IntGetPrimaryMonitor(VOID); -PMONITOR FASTCALL IntMonitorFromRect(PRECTL,DWORD); +NTSTATUS NTAPI UserAttachMonitor(IN HDEV hDev); +NTSTATUS NTAPI UserDetachMonitor(HDEV hDev); +NTSTATUS NTAPI UserUpdateMonitorSize(IN HDEV hDev); +PMONITOR NTAPI UserGetMonitorObject(IN HMONITOR); +PMONITOR NTAPI UserGetPrimaryMonitor(VOID); +PMONITOR NTAPI UserMonitorFromRect(PRECTL,DWORD);
/* EOF */
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c [iso-8859-1] Mon Feb 20 13:23:32 2012 @@ -565,9 +565,8 @@ } else { - HDEV hDev; - hDev = (HDEV)pPrimarySurface; - DesktopHDC = IntGdiCreateDisplayDC(hDev, DcType, EmptyDC); + PMONITOR pMonitor = UserGetPrimaryMonitor(); + DesktopHDC = IntGdiCreateDisplayDC(pMonitor->hDev, DcType, EmptyDC); }
return DesktopHDC; @@ -860,7 +859,7 @@ /* * Try to open already existing desktop */ - + TRACE("Trying to open desktop (%wZ)\n", &DesktopName);
Status = ObOpenObjectByName(
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/display.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/display.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/display.c [iso-8859-1] Mon Feb 20 13:23:32 2012 @@ -779,7 +779,7 @@ //IntvGetDeviceCaps(&PrimarySurface, &GdiHandleTable->DevCaps);
/* Set new size of the monitor */ - IntUpdateMonitorSize(ppdev); + UserUpdateMonitorSize((HDEV)ppdev);
/* Remove all cursor clipping */ UserClipCursor(NULL);
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c [iso-8859-1] Mon Feb 20 13:23:32 2012 @@ -49,9 +49,6 @@ void IntDestroyMonitorObject(IN PMONITOR pMonitor) { - /* Free monitor name */ - RtlFreeUnicodeString(&pMonitor->DeviceName); - /* Remove monitor region */ if (pMonitor->hrgnMonitor) { @@ -73,7 +70,7 @@ * hMonitor * Handle of MONITOR object */ -PMONITOR FASTCALL +PMONITOR NTAPI UserGetMonitorObject(IN HMONITOR hMonitor) { PMONITOR pMonitor; @@ -94,16 +91,15 @@ return pMonitor; }
-/* IntGetPrimaryMonitor +/* UserGetPrimaryMonitor * * Returns a PMONITOR for the primary monitor * * Return value * PMONITOR */ -PMONITOR -FASTCALL -IntGetPrimaryMonitor() +PMONITOR NTAPI +UserGetPrimaryMonitor() { PMONITOR pMonitor;
@@ -117,7 +113,7 @@ return pMonitor; }
-/* IntAttachMonitor +/* UserAttachMonitor * * Creates a new MONITOR and appends it to the list of monitors. * @@ -129,12 +125,10 @@ * Return value * Returns a NTSTATUS */ -NTSTATUS -IntAttachMonitor(IN PDEVOBJ *pGdiDevice, - IN ULONG DisplayNumber) +NTSTATUS NTAPI +UserAttachMonitor(IN HDEV hDev) { PMONITOR pMonitor; - WCHAR Buffer[CCHDEVICENAME];
TRACE("Attaching monitor...\n");
@@ -145,17 +139,8 @@ TRACE("Couldnt create monitor object\n"); return STATUS_INSUFFICIENT_RESOURCES; } - - _snwprintf(Buffer, CCHDEVICENAME, L"\\.\DISPLAY%d", DisplayNumber + 1); - if (!RtlCreateUnicodeString(&pMonitor->DeviceName, Buffer)) - { - TRACE("Couldn't duplicate monitor name!\n"); - UserDereferenceObject(pMonitor); - UserDeleteObject(UserHMGetHandle(pMonitor), otMonitor); - return STATUS_INSUFFICIENT_RESOURCES; - } - - pMonitor->GdiDevice = pGdiDevice; + + pMonitor->hDev = hDev; pMonitor->cWndStack = 0;
if (gMonitorList == NULL) @@ -174,12 +159,12 @@ pmonLast->pMonitorNext = pMonitor; }
- IntUpdateMonitorSize(pGdiDevice); + UserUpdateMonitorSize(hDev);
return STATUS_SUCCESS; }
-/* IntDetachMonitor +/* UserDetachMonitor * * Deletes a MONITOR and removes it from the list of monitors. * @@ -190,15 +175,15 @@ * Return value * Returns a NTSTATUS */ -NTSTATUS -IntDetachMonitor(IN PDEVOBJ *pGdiDevice) +NTSTATUS NTAPI +UserDetachMonitor(IN HDEV hDev) { PMONITOR pMonitor = gMonitorList, *pLink = &gMonitorList;
/* Find monitor attached to given device */ while (pMonitor != NULL) { - if (pMonitor->GdiDevice == pGdiDevice) + if (pMonitor->hDev == hDev) break;
pLink = &pMonitor->pMonitorNext; @@ -224,7 +209,7 @@ return STATUS_SUCCESS; }
-/* IntUpdateMonitorSize +/* UserUpdateMonitorSize * * Reset size of the monitor using atached device * @@ -236,15 +221,16 @@ * Return value * Returns a NTSTATUS */ -NTSTATUS -IntUpdateMonitorSize(IN PDEVOBJ *pGdiDevice) +NTSTATUS NTAPI +UserUpdateMonitorSize(IN HDEV hDev) { PMONITOR pMonitor; + SIZEL DeviceSize;
/* Find monitor attached to given device */ for (pMonitor = gMonitorList; pMonitor != NULL; pMonitor = pMonitor->pMonitorNext) { - if (pMonitor->GdiDevice == pGdiDevice) + if (pMonitor->hDev == hDev) break; }
@@ -253,12 +239,15 @@ /* No monitor has been found */ return STATUS_INVALID_PARAMETER; } + + /* Get the size of the hdev */ + PDEVOBJ_sizl((PPDEVOBJ)hDev, &DeviceSize);
/* Update monitor size */ pMonitor->rcMonitor.left = 0; pMonitor->rcMonitor.top = 0; - pMonitor->rcMonitor.right = pMonitor->rcMonitor.left + pMonitor->GdiDevice->gdiinfo.ulHorzRes; - pMonitor->rcMonitor.bottom = pMonitor->rcMonitor.top + pMonitor->GdiDevice->gdiinfo.ulVertRes; + pMonitor->rcMonitor.right = pMonitor->rcMonitor.left + DeviceSize.cx; + pMonitor->rcMonitor.bottom = pMonitor->rcMonitor.top + DeviceSize.cy; pMonitor->rcWork = pMonitor->rcMonitor;
/* Destroy monitor region... */ @@ -403,9 +392,8 @@ return cMonitors; }
-PMONITOR -FASTCALL -IntMonitorFromRect( +PMONITOR NTAPI +UserMonitorFromRect( PRECTL pRect, DWORD dwFlags) { @@ -703,6 +691,7 @@ MONITORINFOEXW MonitorInfo; NTSTATUS Status; BOOL bRet = FALSE; + PWCHAR pwstrDeviceName;
TRACE("Enter NtUserGetMonitorInfo\n"); UserEnterShared(); @@ -721,6 +710,8 @@ SetLastNtError(STATUS_INVALID_PARAMETER); goto cleanup; } + + pwstrDeviceName = ((PPDEVOBJ)(pMonitor->hDev))->pGraphicsDevice->szWinDeviceName;
/* Get size of pMonitorInfoUnsafe */ Status = MmCopyFromCaller(&MonitorInfo.cbSize, &pMonitorInfoUnsafe->cbSize, sizeof(MonitorInfo.cbSize)); @@ -750,8 +741,8 @@ { RtlStringCbCopyNExW(MonitorInfo.szDevice, sizeof(MonitorInfo.szDevice), - pMonitor->DeviceName.Buffer, - pMonitor->DeviceName.Length, + pwstrDeviceName, + (wcslen(pwstrDeviceName)+1) * sizeof(WCHAR), NULL, NULL, STRSAFE_FILL_BEHIND_NULL); }
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/sysparams.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/sysparams.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/sysparams.c [iso-8859-1] Mon Feb 20 13:23:32 2012 @@ -947,7 +947,7 @@
case SPI_GETWORKAREA: { - PMONITOR pmonitor = IntGetPrimaryMonitor(); + PMONITOR pmonitor = UserGetPrimaryMonitor();
if(!pmonitor) return 0; @@ -959,7 +959,7 @@ { /* FIXME: We should set the work area of the monitor that contains the specified rectangle */ - PMONITOR pmonitor = IntGetPrimaryMonitor(); + PMONITOR pmonitor = UserGetPrimaryMonitor(); RECT rcWorkArea;
if(!pmonitor)
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/window.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] Mon Feb 20 13:23:32 2012 @@ -1463,7 +1463,7 @@ PMONITOR pMonitor; PRTL_USER_PROCESS_PARAMETERS ProcessParams;
- pMonitor = IntGetPrimaryMonitor(); + pMonitor = UserGetPrimaryMonitor();
/* Check if we don't have a monitor attached yet */ if(pMonitor == NULL)
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/winpos.c [iso-8859-1] Mon Feb 20 13:23:32 2012 @@ -323,7 +323,7 @@ else { RECTL WorkArea; - PMONITOR pmonitor = IntMonitorFromRect(&Rect, MONITOR_DEFAULTTOPRIMARY ); + PMONITOR pmonitor = UserMonitorFromRect(&Rect, MONITOR_DEFAULTTOPRIMARY );
// FIXME: support DPI aware, rcWorkDPI/Real etc.. if (!(Wnd->style & WS_MAXIMIZEBOX) || (Wnd->state & WNDS_HASCAPTION) || pmonitor->cFullScreen) @@ -389,7 +389,7 @@ if ( Wnd->spwndParent == Wnd->head.rpdesk->pDeskInfo->spwnd && !(Wnd->ExStyle & WS_EX_TOOLWINDOW)) { - PMONITOR pmonitor = IntMonitorFromRect(&lpwndpl->rcNormalPosition, MONITOR_DEFAULTTOPRIMARY ); + PMONITOR pmonitor = UserMonitorFromRect(&lpwndpl->rcNormalPosition, MONITOR_DEFAULTTOPRIMARY );
// FIXME: support DPI aware, rcWorkDPI/Real etc.. if (Wnd->InternalPos.flags & WPF_MININIT) @@ -414,7 +414,7 @@ /* make sure the specified rect is visible on screen */ static void make_rect_onscreen( RECT *rect ) { - PMONITOR pmonitor = IntMonitorFromRect( rect, MONITOR_DEFAULTTONEAREST ); // Wine uses this. + PMONITOR pmonitor = UserMonitorFromRect( rect, MONITOR_DEFAULTTONEAREST ); // Wine uses this.
// FIXME: support DPI aware, rcWorkDPI/Real etc.. if (!pmonitor) return; @@ -744,7 +744,7 @@ co_IntSendMessage(Window->head.h, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax);
/* if the app didn't change the values, adapt them for the current monitor */ - if ((monitor = IntGetPrimaryMonitor())) + if ((monitor = UserGetPrimaryMonitor())) { RECT rc_work;
Modified: trunk/reactos/subsystems/win32/win32k/objects/device.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/obj... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/device.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/device.c [iso-8859-1] Mon Feb 20 13:23:32 2012 @@ -30,16 +30,9 @@ { SIZEL SurfSize; SURFOBJ *pso; - BOOL calledFromUser; - - calledFromUser = UserIsEntered(); // FIXME: Possibly upgrade a shared lock - if (!calledFromUser) - { - UserEnterExclusive(); - }
/* Attach monitor */ - IntAttachMonitor(gppdevPrimary, 0); + UserAttachMonitor((HDEV)gppdevPrimary);
DPRINT("IntCreatePrimarySurface, pPrimarySurface=%p, pPrimarySurface->pSurface = %p\n", pPrimarySurface, pPrimarySurface->pSurface); @@ -56,11 +49,6 @@
// Init Primary Displays Device Capabilities. PDEVOBJ_vGetDeviceCaps(pPrimarySurface, &GdiHandleTable->DevCaps); - - if (!calledFromUser) - { - UserLeave(); - }
return TRUE; }