ReactOS 0.4.15-dev-7924-g5949c20
monitor.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _MONITOR
 

Typedefs

typedef struct _MONITOR MONITOR
 
typedef struct _MONITORPMONITOR
 

Functions

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)
 
PMONITOR FASTCALL UserMonitorFromPoint (POINT, DWORD)
 

Typedef Documentation

◆ MONITOR

◆ PMONITOR

Function Documentation

◆ UserAttachMonitor()

NTSTATUS NTAPI UserAttachMonitor ( IN HDEV  hDev)

Definition at line 129 of file monitor.c.

130{
131 PMONITOR pMonitor;
132
133 TRACE("Attaching monitor...\n");
134
135 /* Create new monitor object */
136 pMonitor = IntCreateMonitorObject();
137 if (pMonitor == NULL)
138 {
139 TRACE("Couldnt create monitor object\n");
141 }
142
143 pMonitor->hDev = hDev;
144 pMonitor->cWndStack = 0;
145
146 if (gMonitorList == NULL)
147 {
148 TRACE("Primary monitor is beeing attached\n");
149 pMonitor->IsPrimary = TRUE;
150 gMonitorList = pMonitor;
151 }
152 else
153 {
154 PMONITOR pmonLast = gMonitorList;
155 TRACE("Additional monitor is beeing attached\n");
156 while (pmonLast->pMonitorNext != NULL)
157 pmonLast = pmonLast->pMonitorNext;
158
159 pmonLast->pMonitorNext = pMonitor;
160 }
161
163
164 return STATUS_SUCCESS;
165}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACE(s)
Definition: solgame.cpp:4
SHORT cWndStack
Definition: monitor.h:22
HDEV hDev
Definition: monitor.h:23
DWORD IsPrimary
Definition: monitor.h:15
struct _MONITOR * pMonitorNext
Definition: monitor.h:7
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
static PMONITOR gMonitorList
Definition: monitor.c:19
static PMONITOR IntCreateMonitorObject(VOID)
Definition: monitor.c:33
NTSTATUS NTAPI UserUpdateMonitorSize(IN HDEV hDev)
Definition: monitor.c:225

Referenced by co_IntInitializeDesktopGraphics().

◆ UserDetachMonitor()

NTSTATUS NTAPI UserDetachMonitor ( HDEV  hDev)

◆ UserGetMonitorObject()

PMONITOR NTAPI UserGetMonitorObject ( IN  HMONITOR)

Definition at line 74 of file monitor.c.

75{
76 PMONITOR pMonitor;
77
78 if (!hMonitor)
79 {
81 return NULL;
82 }
83
84 pMonitor = (PMONITOR)UserGetObject(gHandleTable, hMonitor, TYPE_MONITOR);
85 if (!pMonitor)
86 {
88 return NULL;
89 }
90
91 return pMonitor;
92}
@ TYPE_MONITOR
Definition: ntuser.h:52
struct _MONITOR * PMONITOR
PVOID UserGetObject(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
Definition: object.c:495
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:22
#define ERROR_INVALID_MONITOR_HANDLE
Definition: winerror.h:942

Referenced by NtUserGetMonitorInfo(), UserMonitorFromPoint(), and UserMonitorFromRect().

◆ UserGetPrimaryMonitor()

PMONITOR NTAPI UserGetPrimaryMonitor ( VOID  )

Definition at line 102 of file monitor.c.

103{
104 PMONITOR pMonitor;
105
106 /* Find primary monitor */
107 for (pMonitor = gMonitorList; pMonitor != NULL; pMonitor = pMonitor->pMonitorNext)
108 {
109 if (pMonitor->IsPrimary)
110 break;
111 }
112
113 return pMonitor;
114}

Referenced by co_UserExcludeUpdateRgn(), co_WinPosGetMinMaxInfo(), IntFixWindowCoordinates(), IntIsWindowFullscreen(), SpiGetSet(), and UserGetDesktopDC().

◆ UserMonitorFromPoint()

PMONITOR FASTCALL UserMonitorFromPoint ( POINT  ,
DWORD   
)

◆ UserMonitorFromRect()

PMONITOR NTAPI UserMonitorFromRect ( PRECTL  pRect,
DWORD  dwFlags 
)

Definition at line 405 of file monitor.c.

408{
409 ULONG cMonitors, LargestArea = 0, i;
410 PRECTL prcMonitorList = NULL;
411 HMONITOR *phMonitorList = NULL;
412 HMONITOR hMonitor = NULL;
413
414 /* Check if flags are valid */
415 if (dwFlags != MONITOR_DEFAULTTONULL &&
416 dwFlags != MONITOR_DEFAULTTOPRIMARY &&
417 dwFlags != MONITOR_DEFAULTTONEAREST)
418 {
420 return NULL;
421 }
422
423 /* Find intersecting monitors */
424 cMonitors = IntGetMonitorsFromRect(pRect, &hMonitor, NULL, 1, dwFlags);
425 if (cMonitors <= 1)
426 {
427 /* No or one monitor found. Just return handle. */
428 goto cleanup;
429 }
430
431 /* There is more than one monitor. Find monitor with largest intersection.
432 Temporary reset hMonitor */
433 hMonitor = NULL;
434
435 /* Allocate helper buffers */
436 phMonitorList = ExAllocatePoolWithTag(PagedPool,
437 sizeof(HMONITOR) * cMonitors,
439 if (phMonitorList == NULL)
440 {
442 goto cleanup;
443 }
444
445 prcMonitorList = ExAllocatePoolWithTag(PagedPool,
446 sizeof(RECT) * cMonitors,
448 if (prcMonitorList == NULL)
449 {
451 goto cleanup;
452 }
453
454 /* Get intersecting monitors again but now with rectangle list */
455 cMonitors = IntGetMonitorsFromRect(pRect, phMonitorList, prcMonitorList,
456 cMonitors, 0);
457
458 /* Find largest intersection */
459 for (i = 0; i < cMonitors; i++)
460 {
461 ULONG Area = (prcMonitorList[i].right - prcMonitorList[i].left) *
462 (prcMonitorList[i].bottom - prcMonitorList[i].top);
463 if (Area >= LargestArea)
464 {
465 hMonitor = phMonitorList[i];
466 LargestArea = Area;
467 }
468 }
469
470cleanup:
471 if (phMonitorList)
473 if (prcMonitorList)
475
476 return UserGetMonitorObject(hMonitor);
477}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
static void cleanup(void)
Definition: main.c:1335
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLint GLint bottom
Definition: glext.h:7726
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
long right
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
uint32_t ULONG
Definition: typedefs.h:59
PMONITOR NTAPI UserGetMonitorObject(IN HMONITOR hMonitor)
Definition: monitor.c:74
static UINT IntGetMonitorsFromRect(OPTIONAL IN LPCRECTL pRect, OPTIONAL OUT HMONITOR *phMonitorList, OPTIONAL OUT PRECTL prcMonitorList, OPTIONAL IN DWORD dwListSize, OPTIONAL IN DWORD dwFlags)
Definition: monitor.c:310
#define USERTAG_MONITORRECTS
Definition: tags.h:254
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
#define ERROR_INVALID_FLAGS
Definition: winerror.h:583

Referenced by IntGetWindowPlacement(), make_rect_onscreen(), SpiGetSet(), and WinPosInitInternalPos().

◆ UserUpdateMonitorSize()

NTSTATUS NTAPI UserUpdateMonitorSize ( IN HDEV  hDev)

Definition at line 225 of file monitor.c.

226{
227 PMONITOR pMonitor;
228 SIZEL DeviceSize;
229
230 /* Find monitor attached to given device */
231 for (pMonitor = gMonitorList; pMonitor != NULL; pMonitor = pMonitor->pMonitorNext)
232 {
233 if (pMonitor->hDev == hDev)
234 break;
235 }
236
237 if (pMonitor == NULL)
238 {
239 /* No monitor has been found */
241 }
242
243 /* Get the size of the hdev */
244 PDEVOBJ_sizl((PPDEVOBJ)hDev, &DeviceSize);
245
246 /* Update monitor size */
247 pMonitor->rcMonitor.left = 0;
248 pMonitor->rcMonitor.top = 0;
249 pMonitor->rcMonitor.right = pMonitor->rcMonitor.left + DeviceSize.cx;
250 pMonitor->rcMonitor.bottom = pMonitor->rcMonitor.top + DeviceSize.cy;
251 pMonitor->rcWork = pMonitor->rcMonitor;
252
253 /* Destroy monitor region... */
254 if (pMonitor->hrgnMonitor)
255 {
257 GreDeleteObject(pMonitor->hrgnMonitor);
258 }
259
260 /* ...and create new one */
262 pMonitor->rcMonitor.left,
263 pMonitor->rcMonitor.top,
264 pMonitor->rcMonitor.right,
265 pMonitor->rcMonitor.bottom);
266 if (pMonitor->hrgnMonitor)
268
269 //
270 // Should be Virtual accumulation of all the available monitors.
271 //
272 gpsi->rcScreenReal = pMonitor->rcMonitor;
273
274 return STATUS_SUCCESS;
275}
PSERVERINFO gpsi
Definition: imm.c:18
__kernel_entry W32KAPI HRGN APIENTRY NtGdiCreateRectRgn(_In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom)
#define GDI_OBJ_HMGR_POWNED
Definition: ntgdihdl.h:117
#define GDI_OBJ_HMGR_PUBLIC
Definition: ntgdihdl.h:116
PSIZEL FASTCALL PDEVOBJ_sizl(PPDEVOBJ ppdev, PSIZEL psizl)
Definition: pdevobj.c:1375
RECT rcWork
Definition: monitor.h:19
RECT rcMonitor
Definition: monitor.h:18
HRGN hrgnMonitor
Definition: monitor.h:20
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
BOOL NTAPI GreSetObjectOwner(HGDIOBJ hobj, ULONG ulOwner)
Definition: gdiobj.c:1255
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1158
BOOL FASTCALL IntGdiSetRegionOwner(HRGN hRgn, DWORD OwnerMask)
Definition: region.c:2459

Referenced by co_IntInitializeDesktopGraphics(), UserAttachMonitor(), and UserChangeDisplaySettings().