From db066b4f46ca16a5e1d4e726f93fb91a35f7b693 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Fri, 6 Jul 2012 13:55:54 +0200 Subject: [PATCH] Win32 Unicode fixes. --- src/win32_fullscreen.c | 10 +++++++++- src/win32_monitor.c | 10 +++++----- src/win32_platform.h | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/win32_fullscreen.c b/src/win32_fullscreen.c index 682b6757..cf76ead2 100644 --- a/src/win32_fullscreen.c +++ b/src/win32_fullscreen.c @@ -199,7 +199,15 @@ int _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, GLFWvidmode* list, int ma for (;;) { - if (!EnumDisplaySettings(monitor->Win32.name, deviceModeNum, &deviceMode)) + BOOL result; + WCHAR* wideName = _glfwCreateWideStringFromUTF8(monitor->Win32.name); + if (!wideName) + break; + + result = EnumDisplaySettings(wideName, deviceModeNum, &deviceMode); + free(wideName); + + if (!result) break; if (vidModesCount >= maxcount) diff --git a/src/win32_monitor.c b/src/win32_monitor.c index 54516c23..c0cc503e 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -58,21 +58,20 @@ _GLFWmonitor** _glfwCreateMonitor(_GLFWmonitor** current, *current = malloc(sizeof(_GLFWmonitor)); memset(*current, 0, sizeof(_GLFWmonitor)); - dc = CreateDC("DISPLAY", monitor->DeviceString, NULL, NULL); + dc = CreateDC(L"DISPLAY", monitor->DeviceString, NULL, NULL); (*current)->physicalWidth = GetDeviceCaps(dc, HORZSIZE); (*current)->physicalHeight = GetDeviceCaps(dc, VERTSIZE); DeleteDC(dc); - (*current)->name = malloc(strlen(monitor->DeviceName) + 1); - memcpy((*current)->name, monitor->DeviceName, strlen(monitor->DeviceName) + 1); - (*current)->name[strlen(monitor->DeviceName)] = '\0'; + (*current)->name = _glfwCreateUTF8FromWideString(monitor->DeviceName); (*current)->screenX = setting->dmPosition.x; (*current)->screenY = setting->dmPosition.y; - memcpy((*current)->Win32.name, adapter->DeviceName, 32); + (*current)->Win32.name = _glfwCreateUTF8FromWideString(adapter->DeviceName); + return &((*current)->next); } @@ -82,6 +81,7 @@ _GLFWmonitor* _glfwDestroyMonitor(_GLFWmonitor* monitor) result = monitor->next; + free(monitor->Win32.name); free(monitor->name); free(monitor); diff --git a/src/win32_platform.h b/src/win32_platform.h index aa3305ef..714a735e 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -219,7 +219,7 @@ typedef struct _GLFWlibraryWin32 //------------------------------------------------------------------------ typedef struct _GLFWmonitorWin32 { - char name[32]; + char* name; } _GLFWmonitorWin32;