[WIN32K]
[reactos.git] / reactos / subsystems / win32 / win32k / ntuser / monitor.c
index b766e95..935be89 100644 (file)
@@ -101,14 +101,14 @@ UserGetMonitorObject(IN HMONITOR hMonitor)
 
     if (!hMonitor)
     {
-        SetLastWin32Error(ERROR_INVALID_MONITOR_HANDLE);
+        EngSetLastError(ERROR_INVALID_MONITOR_HANDLE);
         return NULL;
     }
 
     Monitor = (PMONITOR)UserGetObject(gHandleTable, hMonitor, otMonitor);
     if (!Monitor)
     {
-        SetLastWin32Error(ERROR_INVALID_MONITOR_HANDLE);
+        EngSetLastError(ERROR_INVALID_MONITOR_HANDLE);
         return NULL;
     }
 
@@ -246,6 +246,54 @@ IntDetachMonitor(IN PDEVOBJ *pGdiDevice)
     return STATUS_SUCCESS;
 }
 
+/* IntResetMonitorSize
+ *
+ * Reset size of the monitor using atached device
+ *
+ * Arguments
+ *
+ *   PMONITOR
+ *      pGdiDevice  Pointer to the PDEVOBJ, which size has changed
+ *
+ * Return value
+ *   Returns a NTSTATUS
+ */
+NTSTATUS
+IntResetMonitorSize(IN PDEVOBJ *pGdiDevice)
+{
+       PMONITOR Monitor;
+
+    for (Monitor = gMonitorList; Monitor != NULL; Monitor = Monitor->Next)
+    {
+        if (Monitor->GdiDevice == pGdiDevice)
+            break;
+    }
+
+    if (Monitor == NULL)
+    {
+        /* no monitor for given device found */
+        return STATUS_INVALID_PARAMETER;
+    }
+
+    Monitor->rcMonitor.left  = 0;
+    Monitor->rcMonitor.top   = 0;
+    Monitor->rcMonitor.right  = Monitor->rcMonitor.left + Monitor->GdiDevice->gdiinfo.ulHorzRes;
+    Monitor->rcMonitor.bottom = Monitor->rcMonitor.top + Monitor->GdiDevice->gdiinfo.ulVertRes;
+    Monitor->rcWork = Monitor->rcMonitor;
+
+    if (Monitor->hrgnMonitor)
+    {
+        GDIOBJ_SetOwnership(Monitor->hrgnMonitor, PsGetCurrentProcess());
+        REGION_FreeRgnByHandle(Monitor->hrgnMonitor);
+    }
+
+    Monitor->hrgnMonitor = IntSysCreateRectRgnIndirect( &Monitor->rcMonitor );
+
+    IntGdiSetRegionOwner(Monitor->hrgnMonitor, GDI_OBJ_HMGR_PUBLIC);
+
+    return STATUS_SUCCESS;
+}
+
 /* IntGetPrimaryMonitor
  *
  * Returns a PMONITOR for the primary monitor
@@ -523,7 +571,7 @@ NtUserEnumDisplayMonitors(
         safeHMonitorList = ExAllocatePoolWithTag(PagedPool, sizeof (HMONITOR) * listSize, USERTAG_MONITORRECTS);
         if (safeHMonitorList == NULL)
         {
-            /* FIXME: SetLastWin32Error? */
+            /* FIXME: EngSetLastError? */
             return -1;
         }
     }
@@ -533,7 +581,7 @@ NtUserEnumDisplayMonitors(
         if (safeRectList == NULL)
         {
             ExFreePoolWithTag(safeHMonitorList, USERTAG_MONITORRECTS);
-            /* FIXME: SetLastWin32Error? */
+            /* FIXME: EngSetLastError? */
             return -1;
         }
     }
@@ -773,7 +821,7 @@ NtUserMonitorFromRect(
                                          USERTAG_MONITORRECTS);
     if (hMonitorList == NULL)
     {
-        /* FIXME: SetLastWin32Error? */
+        /* FIXME: EngSetLastError? */
         return (HMONITOR)NULL;
     }
 
@@ -783,7 +831,7 @@ NtUserMonitorFromRect(
     if (rectList == NULL)
     {
         ExFreePoolWithTag(hMonitorList, USERTAG_MONITORRECTS);
-        /* FIXME: SetLastWin32Error? */
+        /* FIXME: EngSetLastError? */
         return (HMONITOR)NULL;
     }