- 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 cFullScreen;
SHORT cWndStack; SHORT cWndStack;
HDEV hDev; 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; } MONITOR, *PMONITOR;
NTSTATUS IntAttachMonitor(PDEVOBJ *pGdiDevice, ULONG DisplayNumber); NTSTATUS NTAPI UserAttachMonitor(IN HDEV hDev);
NTSTATUS IntDetachMonitor(PDEVOBJ *pGdiDevice); NTSTATUS NTAPI UserDetachMonitor(HDEV hDev);
NTSTATUS IntUpdateMonitorSize(IN PDEVOBJ *pGdiDevice); NTSTATUS NTAPI UserUpdateMonitorSize(IN HDEV hDev);
PMONITOR FASTCALL UserGetMonitorObject(IN HMONITOR); PMONITOR NTAPI UserGetMonitorObject(IN HMONITOR);
PMONITOR FASTCALL IntGetPrimaryMonitor(VOID); PMONITOR NTAPI UserGetPrimaryMonitor(VOID);
PMONITOR FASTCALL IntMonitorFromRect(PRECTL,DWORD); PMONITOR NTAPI UserMonitorFromRect(PRECTL,DWORD);
/* EOF */ /* EOF */

View file

@ -565,9 +565,8 @@ UserGetDesktopDC(ULONG DcType, BOOL EmptyDC, BOOL ValidatehWnd)
} }
else else
{ {
HDEV hDev; PMONITOR pMonitor = UserGetPrimaryMonitor();
hDev = (HDEV)pPrimarySurface; DesktopHDC = IntGdiCreateDisplayDC(pMonitor->hDev, DcType, EmptyDC);
DesktopHDC = IntGdiCreateDisplayDC(hDev, DcType, EmptyDC);
} }
return DesktopHDC; return DesktopHDC;

View file

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

View file

@ -49,9 +49,6 @@ static
void void
IntDestroyMonitorObject(IN PMONITOR pMonitor) IntDestroyMonitorObject(IN PMONITOR pMonitor)
{ {
/* Free monitor name */
RtlFreeUnicodeString(&pMonitor->DeviceName);
/* Remove monitor region */ /* Remove monitor region */
if (pMonitor->hrgnMonitor) if (pMonitor->hrgnMonitor)
{ {
@ -73,7 +70,7 @@ IntDestroyMonitorObject(IN PMONITOR pMonitor)
* hMonitor * hMonitor
* Handle of MONITOR object * Handle of MONITOR object
*/ */
PMONITOR FASTCALL PMONITOR NTAPI
UserGetMonitorObject(IN HMONITOR hMonitor) UserGetMonitorObject(IN HMONITOR hMonitor)
{ {
PMONITOR pMonitor; PMONITOR pMonitor;
@ -94,16 +91,15 @@ UserGetMonitorObject(IN HMONITOR hMonitor)
return pMonitor; return pMonitor;
} }
/* IntGetPrimaryMonitor /* UserGetPrimaryMonitor
* *
* Returns a PMONITOR for the primary monitor * Returns a PMONITOR for the primary monitor
* *
* Return value * Return value
* PMONITOR * PMONITOR
*/ */
PMONITOR PMONITOR NTAPI
FASTCALL UserGetPrimaryMonitor()
IntGetPrimaryMonitor()
{ {
PMONITOR pMonitor; PMONITOR pMonitor;
@ -117,7 +113,7 @@ IntGetPrimaryMonitor()
return pMonitor; return pMonitor;
} }
/* IntAttachMonitor /* UserAttachMonitor
* *
* Creates a new MONITOR and appends it to the list of monitors. * Creates a new MONITOR and appends it to the list of monitors.
* *
@ -129,12 +125,10 @@ IntGetPrimaryMonitor()
* Return value * Return value
* Returns a NTSTATUS * Returns a NTSTATUS
*/ */
NTSTATUS NTSTATUS NTAPI
IntAttachMonitor(IN PDEVOBJ *pGdiDevice, UserAttachMonitor(IN HDEV hDev)
IN ULONG DisplayNumber)
{ {
PMONITOR pMonitor; PMONITOR pMonitor;
WCHAR Buffer[CCHDEVICENAME];
TRACE("Attaching monitor...\n"); TRACE("Attaching monitor...\n");
@ -146,16 +140,7 @@ IntAttachMonitor(IN PDEVOBJ *pGdiDevice,
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
_snwprintf(Buffer, CCHDEVICENAME, L"\\\\.\\DISPLAY%d", DisplayNumber + 1); pMonitor->hDev = hDev;
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->cWndStack = 0; pMonitor->cWndStack = 0;
if (gMonitorList == NULL) if (gMonitorList == NULL)
@ -174,12 +159,12 @@ IntAttachMonitor(IN PDEVOBJ *pGdiDevice,
pmonLast->pMonitorNext = pMonitor; pmonLast->pMonitorNext = pMonitor;
} }
IntUpdateMonitorSize(pGdiDevice); UserUpdateMonitorSize(hDev);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
/* IntDetachMonitor /* UserDetachMonitor
* *
* Deletes a MONITOR and removes it from the list of monitors. * Deletes a MONITOR and removes it from the list of monitors.
* *
@ -190,15 +175,15 @@ IntAttachMonitor(IN PDEVOBJ *pGdiDevice,
* Return value * Return value
* Returns a NTSTATUS * Returns a NTSTATUS
*/ */
NTSTATUS NTSTATUS NTAPI
IntDetachMonitor(IN PDEVOBJ *pGdiDevice) UserDetachMonitor(IN HDEV hDev)
{ {
PMONITOR pMonitor = gMonitorList, *pLink = &gMonitorList; PMONITOR pMonitor = gMonitorList, *pLink = &gMonitorList;
/* Find monitor attached to given device */ /* Find monitor attached to given device */
while (pMonitor != NULL) while (pMonitor != NULL)
{ {
if (pMonitor->GdiDevice == pGdiDevice) if (pMonitor->hDev == hDev)
break; break;
pLink = &pMonitor->pMonitorNext; pLink = &pMonitor->pMonitorNext;
@ -224,7 +209,7 @@ IntDetachMonitor(IN PDEVOBJ *pGdiDevice)
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
/* IntUpdateMonitorSize /* UserUpdateMonitorSize
* *
* Reset size of the monitor using atached device * Reset size of the monitor using atached device
* *
@ -236,15 +221,16 @@ IntDetachMonitor(IN PDEVOBJ *pGdiDevice)
* Return value * Return value
* Returns a NTSTATUS * Returns a NTSTATUS
*/ */
NTSTATUS NTSTATUS NTAPI
IntUpdateMonitorSize(IN PDEVOBJ *pGdiDevice) UserUpdateMonitorSize(IN HDEV hDev)
{ {
PMONITOR pMonitor; PMONITOR pMonitor;
SIZEL DeviceSize;
/* Find monitor attached to given device */ /* Find monitor attached to given device */
for (pMonitor = gMonitorList; pMonitor != NULL; pMonitor = pMonitor->pMonitorNext) for (pMonitor = gMonitorList; pMonitor != NULL; pMonitor = pMonitor->pMonitorNext)
{ {
if (pMonitor->GdiDevice == pGdiDevice) if (pMonitor->hDev == hDev)
break; break;
} }
@ -254,11 +240,14 @@ IntUpdateMonitorSize(IN PDEVOBJ *pGdiDevice)
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
} }
/* Get the size of the hdev */
PDEVOBJ_sizl((PPDEVOBJ)hDev, &DeviceSize);
/* Update monitor size */ /* Update monitor size */
pMonitor->rcMonitor.left = 0; pMonitor->rcMonitor.left = 0;
pMonitor->rcMonitor.top = 0; pMonitor->rcMonitor.top = 0;
pMonitor->rcMonitor.right = pMonitor->rcMonitor.left + pMonitor->GdiDevice->gdiinfo.ulHorzRes; pMonitor->rcMonitor.right = pMonitor->rcMonitor.left + DeviceSize.cx;
pMonitor->rcMonitor.bottom = pMonitor->rcMonitor.top + pMonitor->GdiDevice->gdiinfo.ulVertRes; pMonitor->rcMonitor.bottom = pMonitor->rcMonitor.top + DeviceSize.cy;
pMonitor->rcWork = pMonitor->rcMonitor; pMonitor->rcWork = pMonitor->rcMonitor;
/* Destroy monitor region... */ /* Destroy monitor region... */
@ -403,9 +392,8 @@ IntGetMonitorsFromRect(OPTIONAL IN LPCRECTL pRect,
return cMonitors; return cMonitors;
} }
PMONITOR PMONITOR NTAPI
FASTCALL UserMonitorFromRect(
IntMonitorFromRect(
PRECTL pRect, PRECTL pRect,
DWORD dwFlags) DWORD dwFlags)
{ {
@ -703,6 +691,7 @@ NtUserGetMonitorInfo(
MONITORINFOEXW MonitorInfo; MONITORINFOEXW MonitorInfo;
NTSTATUS Status; NTSTATUS Status;
BOOL bRet = FALSE; BOOL bRet = FALSE;
PWCHAR pwstrDeviceName;
TRACE("Enter NtUserGetMonitorInfo\n"); TRACE("Enter NtUserGetMonitorInfo\n");
UserEnterShared(); UserEnterShared();
@ -722,6 +711,8 @@ NtUserGetMonitorInfo(
goto cleanup; goto cleanup;
} }
pwstrDeviceName = ((PPDEVOBJ)(pMonitor->hDev))->pGraphicsDevice->szWinDeviceName;
/* Get size of pMonitorInfoUnsafe */ /* Get size of pMonitorInfoUnsafe */
Status = MmCopyFromCaller(&MonitorInfo.cbSize, &pMonitorInfoUnsafe->cbSize, sizeof(MonitorInfo.cbSize)); Status = MmCopyFromCaller(&MonitorInfo.cbSize, &pMonitorInfoUnsafe->cbSize, sizeof(MonitorInfo.cbSize));
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
@ -750,8 +741,8 @@ NtUserGetMonitorInfo(
{ {
RtlStringCbCopyNExW(MonitorInfo.szDevice, RtlStringCbCopyNExW(MonitorInfo.szDevice,
sizeof(MonitorInfo.szDevice), sizeof(MonitorInfo.szDevice),
pMonitor->DeviceName.Buffer, pwstrDeviceName,
pMonitor->DeviceName.Length, (wcslen(pwstrDeviceName)+1) * sizeof(WCHAR),
NULL, NULL, STRSAFE_FILL_BEHIND_NULL); NULL, NULL, STRSAFE_FILL_BEHIND_NULL);
} }

View file

@ -947,7 +947,7 @@ SpiGetSet(UINT uiAction, UINT uiParam, PVOID pvParam, FLONG fl)
case SPI_GETWORKAREA: case SPI_GETWORKAREA:
{ {
PMONITOR pmonitor = IntGetPrimaryMonitor(); PMONITOR pmonitor = UserGetPrimaryMonitor();
if(!pmonitor) if(!pmonitor)
return 0; 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 /* FIXME: We should set the work area of the monitor
that contains the specified rectangle */ that contains the specified rectangle */
PMONITOR pmonitor = IntGetPrimaryMonitor(); PMONITOR pmonitor = UserGetPrimaryMonitor();
RECT rcWorkArea; RECT rcWorkArea;
if(!pmonitor) if(!pmonitor)

View file

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

View file

@ -323,7 +323,7 @@ WinPosInitInternalPos(PWND Wnd, RECTL *RestoreRect)
else else
{ {
RECTL WorkArea; RECTL WorkArea;
PMONITOR pmonitor = IntMonitorFromRect(&Rect, MONITOR_DEFAULTTOPRIMARY ); PMONITOR pmonitor = UserMonitorFromRect(&Rect, MONITOR_DEFAULTTOPRIMARY );
// FIXME: support DPI aware, rcWorkDPI/Real etc.. // FIXME: support DPI aware, rcWorkDPI/Real etc..
if (!(Wnd->style & WS_MAXIMIZEBOX) || (Wnd->state & WNDS_HASCAPTION) || pmonitor->cFullScreen) 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 && if ( Wnd->spwndParent == Wnd->head.rpdesk->pDeskInfo->spwnd &&
!(Wnd->ExStyle & WS_EX_TOOLWINDOW)) !(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.. // FIXME: support DPI aware, rcWorkDPI/Real etc..
if (Wnd->InternalPos.flags & WPF_MININIT) if (Wnd->InternalPos.flags & WPF_MININIT)
@ -414,7 +414,7 @@ IntGetWindowPlacement(PWND Wnd, WINDOWPLACEMENT *lpwndpl)
/* make sure the specified rect is visible on screen */ /* make sure the specified rect is visible on screen */
static void make_rect_onscreen( RECT *rect ) 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.. // FIXME: support DPI aware, rcWorkDPI/Real etc..
if (!pmonitor) return; 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); 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 the app didn't change the values, adapt them for the current monitor */
if ((monitor = IntGetPrimaryMonitor())) if ((monitor = UserGetPrimaryMonitor()))
{ {
RECT rc_work; RECT rc_work;

View file

@ -30,16 +30,9 @@ IntCreatePrimarySurface()
{ {
SIZEL SurfSize; SIZEL SurfSize;
SURFOBJ *pso; SURFOBJ *pso;
BOOL calledFromUser;
calledFromUser = UserIsEntered(); // FIXME: Possibly upgrade a shared lock
if (!calledFromUser)
{
UserEnterExclusive();
}
/* Attach monitor */ /* Attach monitor */
IntAttachMonitor(gppdevPrimary, 0); UserAttachMonitor((HDEV)gppdevPrimary);
DPRINT("IntCreatePrimarySurface, pPrimarySurface=%p, pPrimarySurface->pSurface = %p\n", DPRINT("IntCreatePrimarySurface, pPrimarySurface=%p, pPrimarySurface->pSurface = %p\n",
pPrimarySurface, pPrimarySurface->pSurface); pPrimarySurface, pPrimarySurface->pSurface);
@ -57,11 +50,6 @@ IntCreatePrimarySurface()
// Init Primary Displays Device Capabilities. // Init Primary Displays Device Capabilities.
PDEVOBJ_vGetDeviceCaps(pPrimarySurface, &GdiHandleTable->DevCaps); PDEVOBJ_vGetDeviceCaps(pPrimarySurface, &GdiHandleTable->DevCaps);
if (!calledFromUser)
{
UserLeave();
}
return TRUE; return TRUE;
} }