Created include/Makefile.in to separate header file installation from
[wine/testsucceed.git] / windows / multimon.c
blob6938c25adadc9e370f9d4e0dc17844154729c747
1 /*
2 * Multimonitor APIs
4 * Copyright 1998 Turchanov Sergey
5 */
7 #include "monitor.h"
8 #include "windows.h"
10 /**********************************************************************/
12 #define xPRIMARY_MONITOR ((HMONITOR)0x12340042)
14 MONITOR MONITOR_PrimaryMonitor;
16 /***********************************************************************
17 * MONITOR_Initialize
19 void MONITOR_Initialize(MONITOR *pMonitor)
21 pMonitor->pDriver->pInitialize(pMonitor);
24 /***********************************************************************
25 * MONITOR_Finalize
27 void MONITOR_Finalize(MONITOR *pMonitor)
29 pMonitor->pDriver->pFinalize(pMonitor);
32 /***********************************************************************
33 * MONITOR_GetWidth
35 int MONITOR_GetWidth(MONITOR *pMonitor)
37 return pMonitor->pDriver->pGetWidth(pMonitor);
40 /***********************************************************************
41 * MONITOR_GetHeight
43 int MONITOR_GetHeight(MONITOR *pMonitor)
45 return pMonitor->pDriver->pGetHeight(pMonitor);
48 /***********************************************************************
49 * MONITOR_GetDepth
51 int MONITOR_GetDepth(MONITOR *pMonitor)
53 return pMonitor->pDriver->pGetDepth(pMonitor);
56 /**********************************************************************/
58 HMONITOR WINAPI MonitorFromPoint(POINT32 ptScreenCoords, DWORD dwFlags)
60 if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
61 ((ptScreenCoords.x >= 0) &&
62 (ptScreenCoords.x < GetSystemMetrics32(SM_CXSCREEN)) &&
63 (ptScreenCoords.y >= 0) &&
64 (ptScreenCoords.y < GetSystemMetrics32(SM_CYSCREEN))))
66 return xPRIMARY_MONITOR;
68 return NULL;
71 HMONITOR WINAPI MonitorFromRect(LPRECT32 lprcScreenCoords, DWORD dwFlags)
73 if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
74 ((lprcScreenCoords->right > 0) &&
75 (lprcScreenCoords->bottom > 0) &&
76 (lprcScreenCoords->left < GetSystemMetrics32(SM_CXSCREEN)) &&
77 (lprcScreenCoords->top < GetSystemMetrics32(SM_CYSCREEN))))
79 return xPRIMARY_MONITOR;
81 return NULL;
84 HMONITOR WINAPI MonitorFromWindow(HWND32 hWnd, DWORD dwFlags)
86 WINDOWPLACEMENT32 wp;
88 if (dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST))
89 return xPRIMARY_MONITOR;
91 if (IsIconic32(hWnd) ?
92 GetWindowPlacement32(hWnd, &wp) :
93 GetWindowRect32(hWnd, &wp.rcNormalPosition)) {
95 return MonitorFromRect(&wp.rcNormalPosition, dwFlags);
98 return NULL;
101 BOOL32 WINAPI GetMonitorInfo32A(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo)
103 RECT32 rcWork;
105 if ((hMonitor == xPRIMARY_MONITOR) &&
106 lpMonitorInfo &&
107 (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) &&
108 SystemParametersInfo32A(SPI_GETWORKAREA, 0, &rcWork, 0))
110 lpMonitorInfo->rcMonitor.left = 0;
111 lpMonitorInfo->rcMonitor.top = 0;
112 lpMonitorInfo->rcMonitor.right = GetSystemMetrics32(SM_CXSCREEN);
113 lpMonitorInfo->rcMonitor.bottom = GetSystemMetrics32(SM_CYSCREEN);
114 lpMonitorInfo->rcWork = rcWork;
115 lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY;
117 if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEX32A))
118 lstrcpy32A(((MONITORINFOEX32A*)lpMonitorInfo)->szDevice, "DISPLAY");
120 return TRUE;
123 return FALSE;
126 BOOL32 WINAPI GetMonitorInfo32W(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo)
128 RECT32 rcWork;
130 if ((hMonitor == xPRIMARY_MONITOR) &&
131 lpMonitorInfo &&
132 (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) &&
133 SystemParametersInfo32W(SPI_GETWORKAREA, 0, &rcWork, 0))
135 lpMonitorInfo->rcMonitor.left = 0;
136 lpMonitorInfo->rcMonitor.top = 0;
137 lpMonitorInfo->rcMonitor.right = GetSystemMetrics32(SM_CXSCREEN);
138 lpMonitorInfo->rcMonitor.bottom = GetSystemMetrics32(SM_CYSCREEN);
139 lpMonitorInfo->rcWork = rcWork;
140 lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY;
142 if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEX32W))
143 lstrcpy32W(((MONITORINFOEX32W*)lpMonitorInfo)->szDevice, (LPCWSTR)"D\0I\0S\0P\0L\0A\0Y\0\0");
145 return TRUE;
148 return FALSE;
151 BOOL32 WINAPI EnumDisplayMonitors(
152 HDC32 hdcOptionalForPainting,
153 LPRECT32 lprcEnumMonitorsThatIntersect,
154 MONITORENUMPROC lpfnEnumProc,
155 LPARAM dwData)
157 RECT32 rcLimit;
159 if (!lpfnEnumProc)
160 return FALSE;
162 rcLimit.left = 0;
163 rcLimit.top = 0;
164 rcLimit.right = GetSystemMetrics32(SM_CXSCREEN);
165 rcLimit.bottom = GetSystemMetrics32(SM_CYSCREEN);
167 if (hdcOptionalForPainting)
169 RECT32 rcClip;
170 POINT32 ptOrg;
172 switch (GetClipBox32(hdcOptionalForPainting, &rcClip))
174 default:
175 if (!GetDCOrgEx(hdcOptionalForPainting, &ptOrg))
176 return FALSE;
178 OffsetRect32(&rcLimit, -ptOrg.x, -ptOrg.y);
179 if (IntersectRect32(&rcLimit, &rcLimit, &rcClip) &&
180 (!lprcEnumMonitorsThatIntersect ||
181 IntersectRect32(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect))) {
183 break;
185 /*fall thru */
186 case NULLREGION:
187 return TRUE;
188 case ERROR:
189 return FALSE;
191 } else {
192 if ( lprcEnumMonitorsThatIntersect &&
193 !IntersectRect32(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect)) {
195 return TRUE;
199 return lpfnEnumProc(
200 xPRIMARY_MONITOR,
201 hdcOptionalForPainting,
202 &rcLimit,
203 dwData);