예제 #1
0
BOOL FASTCALL
co_IntInitializeDesktopGraphics(VOID)
{
   TEXTMETRICW tmw;
   UNICODE_STRING DriverName = RTL_CONSTANT_STRING(L"DISPLAY");
   PDESKTOP pdesk;

   ScreenDeviceContext = IntGdiCreateDC(&DriverName, NULL, NULL, NULL, FALSE);
   if (NULL == ScreenDeviceContext)
   {
      IntDestroyPrimarySurface();
      return FALSE;
   }
   GreSetDCOwner(ScreenDeviceContext, GDI_OBJ_HMGR_PUBLIC);

   if (! IntCreatePrimarySurface())
   {
      return FALSE;
   }

   hSystemBM = NtGdiCreateCompatibleDC(ScreenDeviceContext);

   NtGdiSelectFont(hSystemBM, NtGdiGetStockObject(SYSTEM_FONT));
   GreSetDCOwner(hSystemBM, GDI_OBJ_HMGR_PUBLIC);

   /* Update the SERVERINFO */
   gpsi->aiSysMet[SM_CXSCREEN] = gppdevPrimary->gdiinfo.ulHorzRes;
   gpsi->aiSysMet[SM_CYSCREEN] = gppdevPrimary->gdiinfo.ulVertRes;
   gpsi->Planes        = NtGdiGetDeviceCaps(ScreenDeviceContext, PLANES);
   gpsi->BitsPixel     = NtGdiGetDeviceCaps(ScreenDeviceContext, BITSPIXEL);
   gpsi->BitCount      = gpsi->Planes * gpsi->BitsPixel;
   gpsi->dmLogPixels   = NtGdiGetDeviceCaps(ScreenDeviceContext, LOGPIXELSY);
   if (NtGdiGetDeviceCaps(ScreenDeviceContext, RASTERCAPS) & RC_PALETTE)
   {
      gpsi->PUSIFlags |= PUSIF_PALETTEDISPLAY;
   }
   else
      gpsi->PUSIFlags &= ~PUSIF_PALETTEDISPLAY;
   // Font is realized and this dc was previously set to internal DC_ATTR.
   gpsi->cxSysFontChar = IntGetCharDimensions(hSystemBM, &tmw, (DWORD*)&gpsi->cySysFontChar);
   gpsi->tmSysFont     = tmw;

   /* Put the pointer in the center of the screen */
   gpsi->ptCursor.x = gpsi->aiSysMet[SM_CXSCREEN] / 2;
   gpsi->ptCursor.y = gpsi->aiSysMet[SM_CYSCREEN] / 2;

   /* Attach monitor */
   UserAttachMonitor((HDEV)gppdevPrimary);

   /* Setup the cursor */
   co_IntLoadDefaultCursors();

   /* Show the desktop */
   pdesk = IntGetActiveDesktop();
   ASSERT(pdesk);
   co_IntShowDesktop(pdesk, gpsi->aiSysMet[SM_CXSCREEN], gpsi->aiSysMet[SM_CYSCREEN], TRUE);

   return TRUE;
}
예제 #2
0
파일: winsta.c 프로젝트: reactos/reactos
VOID FASTCALL
IntEndDesktopGraphics(VOID)
{
    if (NULL != ScreenDeviceContext)
    {  // No need to allocate a new dcattr.
        GreSetDCOwner(ScreenDeviceContext, GDI_OBJ_HMGR_POWNED);
        GreDeleteObject(ScreenDeviceContext);
        ScreenDeviceContext = NULL;
    }
    IntHideDesktop(IntGetActiveDesktop());
    IntDestroyPrimarySurface();
}