Mercurial > games > semicongine
comparison fuhtark_test/include/winapi/multimon.h @ 1500:91c8c3b7cbf0
add: futhark tests for generating vulkan api
| author | sam <sam@basx.dev> |
|---|---|
| date | Wed, 26 Nov 2025 21:36:48 +0700 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1499:1f58458b7ef7 | 1500:91c8c3b7cbf0 |
|---|---|
| 1 /** | |
| 2 * This file has no copyright assigned and is placed in the Public Domain. | |
| 3 * This file is part of the w64 mingw-runtime package. | |
| 4 * No warranty is given; refer to the file DISCLAIMER within this package. | |
| 5 */ | |
| 6 #ifdef __cplusplus | |
| 7 extern "C" { | |
| 8 #endif | |
| 9 | |
| 10 #ifndef SM_CMONITORS | |
| 11 #define SM_XVIRTUALSCREEN 76 | |
| 12 #define SM_YVIRTUALSCREEN 77 | |
| 13 #define SM_CXVIRTUALSCREEN 78 | |
| 14 #define SM_CYVIRTUALSCREEN 79 | |
| 15 #define SM_CMONITORS 80 | |
| 16 #define SM_SAMEDISPLAYFORMAT 81 | |
| 17 | |
| 18 #define MONITOR_DEFAULTTONULL 0x00000000 | |
| 19 #define MONITOR_DEFAULTTOPRIMARY 0x00000001 | |
| 20 #define MONITOR_DEFAULTTONEAREST 0x00000002 | |
| 21 | |
| 22 #define MONITORINFOF_PRIMARY 0x00000001 | |
| 23 | |
| 24 typedef struct tagMONITORINFO { | |
| 25 DWORD cbSize; | |
| 26 RECT rcMonitor; | |
| 27 RECT rcWork; | |
| 28 DWORD dwFlags; | |
| 29 } MONITORINFO,*LPMONITORINFO; | |
| 30 | |
| 31 #ifndef CCHDEVICENAME | |
| 32 #define CCHDEVICENAME 32 | |
| 33 #endif | |
| 34 | |
| 35 #ifdef __cplusplus | |
| 36 typedef struct tagMONITORINFOEXA : public tagMONITORINFO { | |
| 37 CHAR szDevice[CCHDEVICENAME]; | |
| 38 } MONITORINFOEXA,*LPMONITORINFOEXA; | |
| 39 | |
| 40 typedef struct tagMONITORINFOEXW : public tagMONITORINFO { | |
| 41 WCHAR szDevice[CCHDEVICENAME]; | |
| 42 } MONITORINFOEXW,*LPMONITORINFOEXW; | |
| 43 #ifdef UNICODE | |
| 44 typedef MONITORINFOEXW MONITORINFOEX; | |
| 45 typedef LPMONITORINFOEXW LPMONITORINFOEX; | |
| 46 #else | |
| 47 typedef MONITORINFOEXA MONITORINFOEX; | |
| 48 typedef LPMONITORINFOEXA LPMONITORINFOEX; | |
| 49 #endif | |
| 50 #else | |
| 51 typedef struct tagMONITORINFOEXA { | |
| 52 MONITORINFO; | |
| 53 CHAR szDevice[CCHDEVICENAME]; | |
| 54 } MONITORINFOEXA,*LPMONITORINFOEXA; | |
| 55 | |
| 56 typedef struct tagMONITORINFOEXW { | |
| 57 MONITORINFO; | |
| 58 WCHAR szDevice[CCHDEVICENAME]; | |
| 59 } MONITORINFOEXW,*LPMONITORINFOEXW; | |
| 60 #ifdef UNICODE | |
| 61 typedef MONITORINFOEXW MONITORINFOEX; | |
| 62 typedef LPMONITORINFOEXW LPMONITORINFOEX; | |
| 63 #else | |
| 64 typedef MONITORINFOEXA MONITORINFOEX; | |
| 65 typedef LPMONITORINFOEXA LPMONITORINFOEX; | |
| 66 #endif | |
| 67 #endif | |
| 68 | |
| 69 typedef WINBOOL (CALLBACK *MONITORENUMPROC)(HMONITOR,HDC,LPRECT,LPARAM); | |
| 70 | |
| 71 #ifndef DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | |
| 72 typedef struct _DISPLAY_DEVICEA { | |
| 73 DWORD cb; | |
| 74 CHAR DeviceName[32]; | |
| 75 CHAR DeviceString[128]; | |
| 76 DWORD StateFlags; | |
| 77 CHAR DeviceID[128]; | |
| 78 CHAR DeviceKey[128]; | |
| 79 } DISPLAY_DEVICEA,*PDISPLAY_DEVICEA,*LPDISPLAY_DEVICEA; | |
| 80 | |
| 81 typedef struct _DISPLAY_DEVICEW { | |
| 82 DWORD cb; | |
| 83 WCHAR DeviceName[32]; | |
| 84 WCHAR DeviceString[128]; | |
| 85 DWORD StateFlags; | |
| 86 WCHAR DeviceID[128]; | |
| 87 WCHAR DeviceKey[128]; | |
| 88 } DISPLAY_DEVICEW,*PDISPLAY_DEVICEW,*LPDISPLAY_DEVICEW; | |
| 89 #ifdef UNICODE | |
| 90 typedef DISPLAY_DEVICEW DISPLAY_DEVICE; | |
| 91 typedef PDISPLAY_DEVICEW PDISPLAY_DEVICE; | |
| 92 typedef LPDISPLAY_DEVICEW LPDISPLAY_DEVICE; | |
| 93 #else | |
| 94 typedef DISPLAY_DEVICEA DISPLAY_DEVICE; | |
| 95 typedef PDISPLAY_DEVICEA PDISPLAY_DEVICE; | |
| 96 typedef LPDISPLAY_DEVICEA LPDISPLAY_DEVICE; | |
| 97 #endif | |
| 98 | |
| 99 #define DISPLAY_DEVICE_ATTACHED_TO_DESKTOP 0x00000001 | |
| 100 #define DISPLAY_DEVICE_MULTI_DRIVER 0x00000002 | |
| 101 #define DISPLAY_DEVICE_PRIMARY_DEVICE 0x00000004 | |
| 102 #define DISPLAY_DEVICE_MIRRORING_DRIVER 0x00000008 | |
| 103 #define DISPLAY_DEVICE_VGA_COMPATIBLE 0x00000010 | |
| 104 #endif | |
| 105 #endif | |
| 106 | |
| 107 #undef GetMonitorInfo | |
| 108 #undef GetSystemMetrics | |
| 109 #undef MonitorFromWindow | |
| 110 #undef MonitorFromRect | |
| 111 #undef MonitorFromPoint | |
| 112 #undef EnumDisplayMonitors | |
| 113 #undef EnumDisplayDevices | |
| 114 | |
| 115 #ifdef COMPILE_MULTIMON_STUBS | |
| 116 | |
| 117 #ifndef MULTIMON_FNS_DEFINED | |
| 118 int (WINAPI *g_pfnGetSystemMetrics)(int) = NULL; | |
| 119 HMONITOR (WINAPI *g_pfnMonitorFromWindow)(HWND,DWORD) = NULL; | |
| 120 HMONITOR (WINAPI *g_pfnMonitorFromRect)(LPCRECT,DWORD) = NULL; | |
| 121 HMONITOR (WINAPI *g_pfnMonitorFromPoint)(POINT,DWORD) = NULL; | |
| 122 WINBOOL (WINAPI *g_pfnGetMonitorInfo)(HMONITOR,LPMONITORINFO) = NULL; | |
| 123 WINBOOL (WINAPI *g_pfnEnumDisplayMonitors)(HDC,LPCRECT,MONITORENUMPROC,LPARAM) = NULL; | |
| 124 WINBOOL (WINAPI *g_pfnEnumDisplayDevices)(PVOID,DWORD,PDISPLAY_DEVICE,DWORD) = NULL; | |
| 125 WINBOOL g_fMultiMonInitDone = FALSE; | |
| 126 WINBOOL g_fMultimonPlatformNT = FALSE; | |
| 127 #endif | |
| 128 | |
| 129 WINBOOL IsPlatformNT() { | |
| 130 OSVERSIONINFOA osvi = {0}; | |
| 131 osvi.dwOSVersionInfoSize = sizeof(osvi); | |
| 132 GetVersionExA((OSVERSIONINFOA*)&osvi); | |
| 133 return (VER_PLATFORM_WIN32_NT==osvi.dwPlatformId); | |
| 134 } | |
| 135 | |
| 136 WINBOOL InitMultipleMonitorStubs(void) { | |
| 137 HMODULE hUser32; | |
| 138 if(g_fMultiMonInitDone) return g_pfnGetMonitorInfo!=NULL; | |
| 139 g_fMultimonPlatformNT = IsPlatformNT(); | |
| 140 hUser32 = GetModuleHandle(TEXT("USER32")); | |
| 141 if(hUser32 && | |
| 142 (*(FARPROC*)&g_pfnGetSystemMetrics = GetProcAddress(hUser32,"GetSystemMetrics"))!=NULL && | |
| 143 (*(FARPROC*)&g_pfnMonitorFromWindow = GetProcAddress(hUser32,"MonitorFromWindow"))!=NULL && | |
| 144 (*(FARPROC*)&g_pfnMonitorFromRect = GetProcAddress(hUser32,"MonitorFromRect"))!=NULL && | |
| 145 (*(FARPROC*)&g_pfnMonitorFromPoint = GetProcAddress(hUser32,"MonitorFromPoint"))!=NULL && | |
| 146 (*(FARPROC*)&g_pfnEnumDisplayMonitors = GetProcAddress(hUser32,"EnumDisplayMonitors"))!=NULL && | |
| 147 #ifdef UNICODE | |
| 148 (*(FARPROC*)&g_pfnEnumDisplayDevices = GetProcAddress(hUser32,"EnumDisplayDevicesW"))!=NULL && | |
| 149 (*(FARPROC*)&g_pfnGetMonitorInfo = g_fMultimonPlatformNT ? GetProcAddress(hUser32,"GetMonitorInfoW") : | |
| 150 GetProcAddress(hUser32,"GetMonitorInfoA"))!=NULL | |
| 151 #else | |
| 152 (*(FARPROC*)&g_pfnGetMonitorInfo = GetProcAddress(hUser32,"GetMonitorInfoA"))!=NULL && | |
| 153 (*(FARPROC*)&g_pfnEnumDisplayDevices = GetProcAddress(hUser32,"EnumDisplayDevicesA"))!=NULL | |
| 154 #endif | |
| 155 ) { | |
| 156 g_fMultiMonInitDone = TRUE; | |
| 157 return TRUE; | |
| 158 } else { | |
| 159 g_pfnGetSystemMetrics = NULL; | |
| 160 g_pfnMonitorFromWindow = NULL; | |
| 161 g_pfnMonitorFromRect = NULL; | |
| 162 g_pfnMonitorFromPoint = NULL; | |
| 163 g_pfnGetMonitorInfo = NULL; | |
| 164 g_pfnEnumDisplayMonitors = NULL; | |
| 165 g_pfnEnumDisplayDevices = NULL; | |
| 166 g_fMultiMonInitDone = TRUE; | |
| 167 return FALSE; | |
| 168 } | |
| 169 } | |
| 170 | |
| 171 int WINAPI xGetSystemMetrics(int nIndex) { | |
| 172 if(InitMultipleMonitorStubs()) return g_pfnGetSystemMetrics(nIndex); | |
| 173 switch(nIndex) { | |
| 174 case SM_CMONITORS: | |
| 175 case SM_SAMEDISPLAYFORMAT: | |
| 176 return 1; | |
| 177 case SM_XVIRTUALSCREEN: | |
| 178 case SM_YVIRTUALSCREEN: | |
| 179 return 0; | |
| 180 case SM_CXVIRTUALSCREEN: | |
| 181 nIndex = SM_CXSCREEN; | |
| 182 break; | |
| 183 case SM_CYVIRTUALSCREEN: | |
| 184 nIndex = SM_CYSCREEN; | |
| 185 break; | |
| 186 } | |
| 187 return GetSystemMetrics(nIndex); | |
| 188 } | |
| 189 | |
| 190 #define xPRIMARY_MONITOR ((HMONITOR)0x12340042) | |
| 191 | |
| 192 HMONITOR WINAPI xMonitorFromPoint(POINT ptScreenCoords,DWORD dwFlags) { | |
| 193 if(InitMultipleMonitorStubs()) return g_pfnMonitorFromPoint(ptScreenCoords,dwFlags); | |
| 194 if((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) || | |
| 195 ((ptScreenCoords.x >= 0) && | |
| 196 (ptScreenCoords.x < GetSystemMetrics(SM_CXSCREEN)) && | |
| 197 (ptScreenCoords.y >= 0) && | |
| 198 (ptScreenCoords.y < GetSystemMetrics(SM_CYSCREEN)))) | |
| 199 { | |
| 200 return xPRIMARY_MONITOR; | |
| 201 } | |
| 202 return NULL; | |
| 203 } | |
| 204 | |
| 205 HMONITOR WINAPI xMonitorFromRect(LPCRECT lprcScreenCoords,DWORD dwFlags) | |
| 206 { | |
| 207 if(InitMultipleMonitorStubs()) return g_pfnMonitorFromRect(lprcScreenCoords,dwFlags); | |
| 208 if((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) || | |
| 209 ((lprcScreenCoords->right > 0) && | |
| 210 (lprcScreenCoords->bottom > 0) && | |
| 211 (lprcScreenCoords->left < GetSystemMetrics(SM_CXSCREEN)) && | |
| 212 (lprcScreenCoords->top < GetSystemMetrics(SM_CYSCREEN)))) | |
| 213 { | |
| 214 return xPRIMARY_MONITOR; | |
| 215 } | |
| 216 return NULL; | |
| 217 } | |
| 218 | |
| 219 HMONITOR WINAPI xMonitorFromWindow(HWND hWnd,DWORD dwFlags) { | |
| 220 WINDOWPLACEMENT wp; | |
| 221 if(InitMultipleMonitorStubs()) return g_pfnMonitorFromWindow(hWnd,dwFlags); | |
| 222 if(dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) return xPRIMARY_MONITOR; | |
| 223 if(IsIconic(hWnd) ? GetWindowPlacement(hWnd,&wp) : GetWindowRect(hWnd,&wp.rcNormalPosition)) return xMonitorFromRect(&wp.rcNormalPosition,dwFlags); | |
| 224 return NULL; | |
| 225 } | |
| 226 | |
| 227 WINBOOL WINAPI xGetMonitorInfo(HMONITOR hMonitor,LPMONITORINFO lpMonitorInfo) { | |
| 228 RECT rcWork; | |
| 229 if(InitMultipleMonitorStubs()) { | |
| 230 WINBOOL f = g_pfnGetMonitorInfo(hMonitor,lpMonitorInfo); | |
| 231 #ifdef UNICODE | |
| 232 if(f && !g_fMultimonPlatformNT && (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEX))) { | |
| 233 MultiByteToWideChar(CP_ACP,0,(LPSTR)((MONITORINFOEX*)lpMonitorInfo)->szDevice,-1,((MONITORINFOEX*)lpMonitorInfo)->szDevice,(sizeof(((MONITORINFOEX*)lpMonitorInfo)->szDevice)/sizeof(TCHAR))); | |
| 234 } | |
| 235 #endif | |
| 236 return f; | |
| 237 } | |
| 238 if((hMonitor==xPRIMARY_MONITOR) && | |
| 239 lpMonitorInfo && | |
| 240 (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) && | |
| 241 SystemParametersInfoA(SPI_GETWORKAREA,0,&rcWork,0)) | |
| 242 { | |
| 243 lpMonitorInfo->rcMonitor.left = 0; | |
| 244 lpMonitorInfo->rcMonitor.top = 0; | |
| 245 lpMonitorInfo->rcMonitor.right = GetSystemMetrics(SM_CXSCREEN); | |
| 246 lpMonitorInfo->rcMonitor.bottom = GetSystemMetrics(SM_CYSCREEN); | |
| 247 lpMonitorInfo->rcWork = rcWork; | |
| 248 lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY; | |
| 249 if(lpMonitorInfo->cbSize >= sizeof(MONITORINFOEX)) { | |
| 250 #ifdef UNICODE | |
| 251 MultiByteToWideChar(CP_ACP,0,"DISPLAY",-1,((MONITORINFOEX*)lpMonitorInfo)->szDevice,(sizeof(((MONITORINFOEX*)lpMonitorInfo)->szDevice)/sizeof(TCHAR))); | |
| 252 #else | |
| 253 lstrcpyn(((MONITORINFOEX*)lpMonitorInfo)->szDevice,TEXT("DISPLAY"),(sizeof(((MONITORINFOEX*)lpMonitorInfo)->szDevice)/sizeof(TCHAR))); | |
| 254 #endif | |
| 255 } | |
| 256 | |
| 257 return TRUE; | |
| 258 } | |
| 259 | |
| 260 return FALSE; | |
| 261 } | |
| 262 | |
| 263 WINBOOL WINAPI | |
| 264 xEnumDisplayMonitors(HDC hdcOptionalForPainting,LPCRECT lprcEnumMonitorsThatIntersect,MONITORENUMPROC lpfnEnumProc,LPARAM dwData) | |
| 265 { | |
| 266 RECT rcLimit; | |
| 267 | |
| 268 if(InitMultipleMonitorStubs()) { | |
| 269 return g_pfnEnumDisplayMonitors(hdcOptionalForPainting,lprcEnumMonitorsThatIntersect,lpfnEnumProc,dwData); | |
| 270 } | |
| 271 | |
| 272 if(!lpfnEnumProc) | |
| 273 return FALSE; | |
| 274 | |
| 275 rcLimit.left = 0; | |
| 276 rcLimit.top = 0; | |
| 277 rcLimit.right = GetSystemMetrics(SM_CXSCREEN); | |
| 278 rcLimit.bottom = GetSystemMetrics(SM_CYSCREEN); | |
| 279 | |
| 280 if(hdcOptionalForPainting) | |
| 281 { | |
| 282 RECT rcClip; | |
| 283 POINT ptOrg; | |
| 284 | |
| 285 switch (GetClipBox(hdcOptionalForPainting,&rcClip)) | |
| 286 { | |
| 287 default: | |
| 288 if(!GetDCOrgEx(hdcOptionalForPainting,&ptOrg)) | |
| 289 return FALSE; | |
| 290 | |
| 291 OffsetRect(&rcLimit,-ptOrg.x,-ptOrg.y); | |
| 292 if(IntersectRect(&rcLimit,&rcLimit,&rcClip) && | |
| 293 (!lprcEnumMonitorsThatIntersect || | |
| 294 IntersectRect(&rcLimit,&rcLimit,lprcEnumMonitorsThatIntersect))) { | |
| 295 | |
| 296 break; | |
| 297 } | |
| 298 | |
| 299 case NULLREGION: | |
| 300 return TRUE; | |
| 301 case ERROR: | |
| 302 return FALSE; | |
| 303 } | |
| 304 } else { | |
| 305 if(lprcEnumMonitorsThatIntersect && | |
| 306 !IntersectRect(&rcLimit,&rcLimit,lprcEnumMonitorsThatIntersect)) { | |
| 307 | |
| 308 return TRUE; | |
| 309 } | |
| 310 } | |
| 311 | |
| 312 return lpfnEnumProc(xPRIMARY_MONITOR,hdcOptionalForPainting,&rcLimit,dwData); | |
| 313 } | |
| 314 | |
| 315 WINBOOL WINAPI | |
| 316 xEnumDisplayDevices(PVOID Unused,DWORD iDevNum,PDISPLAY_DEVICE lpDisplayDevice,DWORD dwFlags) | |
| 317 { | |
| 318 if(InitMultipleMonitorStubs()) | |
| 319 return g_pfnEnumDisplayDevices(Unused,iDevNum,lpDisplayDevice,dwFlags); | |
| 320 | |
| 321 if(Unused!=NULL) | |
| 322 return FALSE; | |
| 323 | |
| 324 if(iDevNum!=0) | |
| 325 return FALSE; | |
| 326 | |
| 327 if(!lpDisplayDevice || lpDisplayDevice->cb < sizeof(DISPLAY_DEVICE)) | |
| 328 return FALSE; | |
| 329 | |
| 330 #ifdef UNICODE | |
| 331 MultiByteToWideChar(CP_ACP,0,"DISPLAY",-1,lpDisplayDevice->DeviceName,(sizeof(lpDisplayDevice->DeviceName)/sizeof(TCHAR))); | |
| 332 MultiByteToWideChar(CP_ACP,0,"DISPLAY",-1,lpDisplayDevice->DeviceString,(sizeof(lpDisplayDevice->DeviceString)/sizeof(TCHAR))); | |
| 333 #else | |
| 334 lstrcpyn((LPTSTR)lpDisplayDevice->DeviceName,TEXT("DISPLAY"),(sizeof(lpDisplayDevice->DeviceName)/sizeof(TCHAR))); | |
| 335 lstrcpyn((LPTSTR)lpDisplayDevice->DeviceString,TEXT("DISPLAY"),(sizeof(lpDisplayDevice->DeviceString)/sizeof(TCHAR))); | |
| 336 #endif | |
| 337 lpDisplayDevice->StateFlags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE; | |
| 338 return TRUE; | |
| 339 } | |
| 340 | |
| 341 #undef xPRIMARY_MONITOR | |
| 342 #undef COMPILE_MULTIMON_STUBS | |
| 343 #else | |
| 344 | |
| 345 extern int WINAPI xGetSystemMetrics(int); | |
| 346 extern HMONITOR WINAPI xMonitorFromWindow(HWND,DWORD); | |
| 347 extern HMONITOR WINAPI xMonitorFromRect(LPCRECT,DWORD); | |
| 348 extern HMONITOR WINAPI xMonitorFromPoint(POINT,DWORD); | |
| 349 extern WINBOOL WINAPI xGetMonitorInfo(HMONITOR,LPMONITORINFO); | |
| 350 extern WINBOOL WINAPI xEnumDisplayMonitors(HDC,LPCRECT,MONITORENUMPROC,LPARAM); | |
| 351 extern WINBOOL WINAPI xEnumDisplayDevices(PVOID,DWORD,PDISPLAY_DEVICE,DWORD); | |
| 352 #endif | |
| 353 | |
| 354 #define GetSystemMetrics xGetSystemMetrics | |
| 355 #define MonitorFromWindow xMonitorFromWindow | |
| 356 #define MonitorFromRect xMonitorFromRect | |
| 357 #define MonitorFromPoint xMonitorFromPoint | |
| 358 #define GetMonitorInfo xGetMonitorInfo | |
| 359 #define EnumDisplayMonitors xEnumDisplayMonitors | |
| 360 #define EnumDisplayDevices xEnumDisplayDevices | |
| 361 | |
| 362 #ifdef __cplusplus | |
| 363 } | |
| 364 #endif |
