Avoid a link error from another DLL on FreeBSD.
[wine/hacks.git] / windows / multimon.c
blob67944b3c9e4012269475c07259c84672b248f099
1 /*
2 * Multimonitor APIs
4 * Copyright 1998 Turchanov Sergey
5 */
7 #include "monitor.h"
8 #include "windef.h"
9 #include "wingdi.h"
10 #include "winbase.h"
11 #include "winuser.h"
13 /**********************************************************************/
15 MONITOR_DRIVER *MONITOR_Driver;
17 /**********************************************************************/
19 #define xPRIMARY_MONITOR ((HMONITOR)0x12340042)
21 MONITOR MONITOR_PrimaryMonitor;
23 /***********************************************************************
24 * MONITOR_GetMonitor
26 #if 0
27 static MONITOR *MONITOR_GetMonitor(HMONITOR hMonitor)
29 if(hMonitor == xPRIMARY_MONITOR)
31 return &MONITOR_PrimaryMonitor;
33 else
35 return NULL;
38 #endif
40 /***********************************************************************
41 * MONITOR_Initialize
43 void MONITOR_Initialize(MONITOR *pMonitor)
45 MONITOR_Driver->pInitialize(pMonitor);
48 /***********************************************************************
49 * MONITOR_Finalize
51 void MONITOR_Finalize(MONITOR *pMonitor)
53 MONITOR_Driver->pFinalize(pMonitor);
56 /***********************************************************************
57 * MONITOR_IsSingleWindow
59 BOOL MONITOR_IsSingleWindow(MONITOR *pMonitor)
61 return MONITOR_Driver->pIsSingleWindow(pMonitor);
64 /***********************************************************************
65 * MONITOR_GetWidth
67 int MONITOR_GetWidth(MONITOR *pMonitor)
69 return MONITOR_Driver->pGetWidth(pMonitor);
72 /***********************************************************************
73 * MONITOR_GetHeight
75 int MONITOR_GetHeight(MONITOR *pMonitor)
77 return MONITOR_Driver->pGetHeight(pMonitor);
80 /***********************************************************************
81 * MONITOR_GetDepth
83 int MONITOR_GetDepth(MONITOR *pMonitor)
85 return MONITOR_Driver->pGetDepth(pMonitor);
88 /***********************************************************************
89 * MONITOR_GetScreenSaveActive
91 BOOL MONITOR_GetScreenSaveActive(MONITOR *pMonitor)
93 return MONITOR_Driver->pGetScreenSaveActive(pMonitor);
96 /***********************************************************************
97 * MONITOR_SetScreenSaveActive
99 void MONITOR_SetScreenSaveActive(MONITOR *pMonitor, BOOL bActivate)
101 MONITOR_Driver->pSetScreenSaveActive(pMonitor, bActivate);
104 /***********************************************************************
105 * MONITOR_GetScreenSaveTimeout
107 int MONITOR_GetScreenSaveTimeout(MONITOR *pMonitor)
109 return MONITOR_Driver->pGetScreenSaveTimeout(pMonitor);
112 /***********************************************************************
113 * MONITOR_SetScreenSaveTimeout
115 void MONITOR_SetScreenSaveTimeout(MONITOR *pMonitor, int nTimeout)
117 MONITOR_Driver->pSetScreenSaveTimeout(pMonitor, nTimeout);
121 /**********************************************************************/
123 HMONITOR WINAPI MonitorFromPoint(POINT ptScreenCoords, DWORD dwFlags)
125 if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
126 ((ptScreenCoords.x >= 0) &&
127 (ptScreenCoords.x < GetSystemMetrics(SM_CXSCREEN)) &&
128 (ptScreenCoords.y >= 0) &&
129 (ptScreenCoords.y < GetSystemMetrics(SM_CYSCREEN))))
131 return xPRIMARY_MONITOR;
133 return NULL;
136 HMONITOR WINAPI MonitorFromRect(LPRECT lprcScreenCoords, DWORD dwFlags)
138 if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
139 ((lprcScreenCoords->right > 0) &&
140 (lprcScreenCoords->bottom > 0) &&
141 (lprcScreenCoords->left < GetSystemMetrics(SM_CXSCREEN)) &&
142 (lprcScreenCoords->top < GetSystemMetrics(SM_CYSCREEN))))
144 return xPRIMARY_MONITOR;
146 return NULL;
149 HMONITOR WINAPI MonitorFromWindow(HWND hWnd, DWORD dwFlags)
151 WINDOWPLACEMENT wp;
153 if (dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST))
154 return xPRIMARY_MONITOR;
156 if (IsIconic(hWnd) ?
157 GetWindowPlacement(hWnd, &wp) :
158 GetWindowRect(hWnd, &wp.rcNormalPosition)) {
160 return MonitorFromRect(&wp.rcNormalPosition, dwFlags);
163 return NULL;
166 BOOL WINAPI GetMonitorInfoA(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo)
168 RECT rcWork;
170 if ((hMonitor == xPRIMARY_MONITOR) &&
171 lpMonitorInfo &&
172 (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) &&
173 SystemParametersInfoA(SPI_GETWORKAREA, 0, &rcWork, 0))
175 lpMonitorInfo->rcMonitor.left = 0;
176 lpMonitorInfo->rcMonitor.top = 0;
177 lpMonitorInfo->rcMonitor.right = GetSystemMetrics(SM_CXSCREEN);
178 lpMonitorInfo->rcMonitor.bottom = GetSystemMetrics(SM_CYSCREEN);
179 lpMonitorInfo->rcWork = rcWork;
180 lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY;
182 if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEXA))
183 lstrcpyA(((MONITORINFOEXA*)lpMonitorInfo)->szDevice, "DISPLAY");
185 return TRUE;
188 return FALSE;
191 BOOL WINAPI GetMonitorInfoW(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo)
193 RECT rcWork;
195 if ((hMonitor == xPRIMARY_MONITOR) &&
196 lpMonitorInfo &&
197 (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) &&
198 SystemParametersInfoW(SPI_GETWORKAREA, 0, &rcWork, 0))
200 lpMonitorInfo->rcMonitor.left = 0;
201 lpMonitorInfo->rcMonitor.top = 0;
202 lpMonitorInfo->rcMonitor.right = GetSystemMetrics(SM_CXSCREEN);
203 lpMonitorInfo->rcMonitor.bottom = GetSystemMetrics(SM_CYSCREEN);
204 lpMonitorInfo->rcWork = rcWork;
205 lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY;
207 if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEXW))
208 lstrcpyW(((MONITORINFOEXW*)lpMonitorInfo)->szDevice, (LPCWSTR)"D\0I\0S\0P\0L\0A\0Y\0\0");
210 return TRUE;
213 return FALSE;
216 BOOL WINAPI EnumDisplayMonitors(
217 HDC hdcOptionalForPainting,
218 LPRECT lprcEnumMonitorsThatIntersect,
219 MONITORENUMPROC lpfnEnumProc,
220 LPARAM dwData)
222 RECT rcLimit;
224 if (!lpfnEnumProc)
225 return FALSE;
227 rcLimit.left = 0;
228 rcLimit.top = 0;
229 rcLimit.right = GetSystemMetrics(SM_CXSCREEN);
230 rcLimit.bottom = GetSystemMetrics(SM_CYSCREEN);
232 if (hdcOptionalForPainting)
234 RECT rcClip;
235 POINT ptOrg;
237 switch (GetClipBox(hdcOptionalForPainting, &rcClip))
239 default:
240 if (!GetDCOrgEx(hdcOptionalForPainting, &ptOrg))
241 return FALSE;
243 OffsetRect(&rcLimit, -ptOrg.x, -ptOrg.y);
244 if (IntersectRect(&rcLimit, &rcLimit, &rcClip) &&
245 (!lprcEnumMonitorsThatIntersect ||
246 IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect))) {
248 break;
250 /*fall thru */
251 case NULLREGION:
252 return TRUE;
253 case ERROR:
254 return FALSE;
256 } else {
257 if ( lprcEnumMonitorsThatIntersect &&
258 !IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect)) {
260 return TRUE;
264 return lpfnEnumProc(
265 xPRIMARY_MONITOR,
266 hdcOptionalForPainting,
267 &rcLimit,
268 dwData);