Browse Source

Fixed an issue to detect the current monitor for DirectX (#487)

Maurice Doison 3 years ago
parent
commit
8be72f5304
1 changed files with 6 additions and 5 deletions
  1. 6 5
      libs/directx/window.c

+ 6 - 5
libs/directx/window.c

@@ -607,13 +607,14 @@ HL_PRIM varray* HL_NAME(win_get_monitors)() {
 	return data.arr;
 }
 
-HL_PRIM wchar_t* HL_NAME(win_get_monitor_from_window)(HWND wnd) {
+HL_PRIM vbyte* HL_NAME(win_get_monitor_from_window)(HWND wnd) {
 	HMONITOR handle = MonitorFromWindow(wnd, MONITOR_DEFAULTTOPRIMARY);
 
-	MONITORINFOEXW info;
-	info.cbSize = sizeof(MONITORINFOEXW);
-	GetMonitorInfoW(handle, (LPMONITORINFO)&info);
-	return info.szDevice;
+	MONITORINFOEX info;
+	info.cbSize = sizeof(MONITORINFOEX);
+	if (!GetMonitorInfo(handle, (LPMONITORINFO)&info))
+		return NULL;
+	return hl_copy_bytes((vbyte*)info.szDevice, (int)(wcslen(info.szDevice) + 1) * 2);
 }
 
 HL_PRIM varray* HL_NAME(win_get_display_settings)(wchar_t* device) {