- Do not store the PDEVOBJ and a fake name in MONITOR struct. Use MONITOR.HDEV instead (which is an opaque pointer to a PDEVOBJ)

svn path=/trunk/; revision=55755
This commit is contained in:
Giannis Adamopoulos 2012-02-20 13:23:32 +00:00
parent 5cce4a8bd0
commit 123637fd96
8 changed files with 49 additions and 76 deletions

View file

@ -21,18 +21,13 @@ typedef struct _MONITOR
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 */

View file

@ -565,9 +565,8 @@ UserGetDesktopDC(ULONG DcType, BOOL EmptyDC, BOOL ValidatehWnd)
}
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 @@ NtUserCreateDesktop(
/*
* Try to open already existing desktop
*/
TRACE("Trying to open desktop (%wZ)\n", &DesktopName);
Status = ObOpenObjectByName(

View file

@ -779,7 +779,7 @@ UserChangeDisplaySettings(
//IntvGetDeviceCaps(&PrimarySurface, &GdiHandleTable->DevCaps);
/* Set new size of the monitor */
IntUpdateMonitorSize(ppdev);
UserUpdateMonitorSize((HDEV)ppdev);
/* Remove all cursor clipping */
UserClipCursor(NULL);

View file

@ -49,9 +49,6 @@ static
void
IntDestroyMonitorObject(IN PMONITOR pMonitor)
{
/* Free monitor name */
RtlFreeUnicodeString(&pMonitor->DeviceName);
/* Remove monitor region */
if (pMonitor->hrgnMonitor)
{
@ -73,7 +70,7 @@ IntDestroyMonitorObject(IN PMONITOR pMonitor)
* hMonitor
* Handle of MONITOR object
*/
PMONITOR FASTCALL
PMONITOR NTAPI
UserGetMonitorObject(IN HMONITOR hMonitor)
{
PMONITOR pMonitor;
@ -94,16 +91,15 @@ UserGetMonitorObject(IN HMONITOR hMonitor)
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 @@ IntGetPrimaryMonitor()
return pMonitor;
}
/* IntAttachMonitor
/* UserAttachMonitor
*
* Creates a new MONITOR and appends it to the list of monitors.
*
@ -129,12 +125,10 @@ IntGetPrimaryMonitor()
* 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 @@ IntAttachMonitor(IN PDEVOBJ *pGdiDevice,
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 @@ IntAttachMonitor(IN PDEVOBJ *pGdiDevice,
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 @@ IntAttachMonitor(IN PDEVOBJ *pGdiDevice,
* 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 @@ IntDetachMonitor(IN PDEVOBJ *pGdiDevice)
return STATUS_SUCCESS;
}
/* IntUpdateMonitorSize
/* UserUpdateMonitorSize
*
* Reset size of the monitor using atached device
*
@ -236,15 +221,16 @@ IntDetachMonitor(IN PDEVOBJ *pGdiDevice)
* 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;
}
@ -254,11 +240,14 @@ IntUpdateMonitorSize(IN PDEVOBJ *pGdiDevice)
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 @@ IntGetMonitorsFromRect(OPTIONAL IN LPCRECTL pRect,
return cMonitors;
}
PMONITOR
FASTCALL
IntMonitorFromRect(
PMONITOR NTAPI
UserMonitorFromRect(
PRECTL pRect,
DWORD dwFlags)
{
@ -703,6 +691,7 @@ NtUserGetMonitorInfo(
MONITORINFOEXW MonitorInfo;
NTSTATUS Status;
BOOL bRet = FALSE;
PWCHAR pwstrDeviceName;
TRACE("Enter NtUserGetMonitorInfo\n");
UserEnterShared();
@ -722,6 +711,8 @@ NtUserGetMonitorInfo(
goto cleanup;
}
pwstrDeviceName = ((PPDEVOBJ)(pMonitor->hDev))->pGraphicsDevice->szWinDeviceName;
/* Get size of pMonitorInfoUnsafe */
Status = MmCopyFromCaller(&MonitorInfo.cbSize, &pMonitorInfoUnsafe->cbSize, sizeof(MonitorInfo.cbSize));
if (!NT_SUCCESS(Status))
@ -750,8 +741,8 @@ NtUserGetMonitorInfo(
{
RtlStringCbCopyNExW(MonitorInfo.szDevice,
sizeof(MonitorInfo.szDevice),
pMonitor->DeviceName.Buffer,
pMonitor->DeviceName.Length,
pwstrDeviceName,
(wcslen(pwstrDeviceName)+1) * sizeof(WCHAR),
NULL, NULL, STRSAFE_FILL_BEHIND_NULL);
}

View file

@ -947,7 +947,7 @@ SpiGetSet(UINT uiAction, UINT uiParam, PVOID pvParam, FLONG fl)
case SPI_GETWORKAREA:
{
PMONITOR pmonitor = IntGetPrimaryMonitor();
PMONITOR pmonitor = UserGetPrimaryMonitor();
if(!pmonitor)
return 0;
@ -959,7 +959,7 @@ SpiGetSet(UINT uiAction, UINT uiParam, PVOID pvParam, FLONG fl)
{
/* 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)

View file

@ -1463,7 +1463,7 @@ IntFixWindowCoordinates(CREATESTRUCTW* Cs, PWND ParentWindow, DWORD* dwShowMode)
PMONITOR pMonitor;
PRTL_USER_PROCESS_PARAMETERS ProcessParams;
pMonitor = IntGetPrimaryMonitor();
pMonitor = UserGetPrimaryMonitor();
/* Check if we don't have a monitor attached yet */
if(pMonitor == NULL)

View file

@ -323,7 +323,7 @@ WinPosInitInternalPos(PWND Wnd, RECTL *RestoreRect)
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 @@ IntGetWindowPlacement(PWND Wnd, WINDOWPLACEMENT *lpwndpl)
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 @@ IntGetWindowPlacement(PWND Wnd, WINDOWPLACEMENT *lpwndpl)
/* 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_WinPosGetMinMaxInfo(PWND Window, POINT* MaxSize, POINT* MaxPos,
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;

View file

@ -30,16 +30,9 @@ IntCreatePrimarySurface()
{
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);
@ -57,11 +50,6 @@ IntCreatePrimarySurface()
// Init Primary Displays Device Capabilities.
PDEVOBJ_vGetDeviceCaps(pPrimarySurface, &GdiHandleTable->DevCaps);
if (!calledFromUser)
{
UserLeave();
}
return TRUE;
}