mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2025-02-08 22:20:05 +01:00
video/windows: ANSI/UNICODE updates (cf. bug 5435):
- explicitly use UNICODE versions of DrawText, EnumDisplaySettings, EnumDisplayDevices, and CreateDC: the underlying structures have WCHAR strings. - change WIN_UpdateDisplayMode and WIN_GetDisplayMode() to accept LPCWSTR instead of LPCTSTR for the same reason. - change WIN_StringToUTF8 and WIN_UTF8ToString to the explicit 'W' versions where appropriate.
This commit is contained in:
parent
265a1cc97a
commit
76295cecf3
@ -749,7 +749,7 @@ static void
|
|||||||
IME_SendInputEvent(SDL_VideoData *videodata)
|
IME_SendInputEvent(SDL_VideoData *videodata)
|
||||||
{
|
{
|
||||||
char *s = 0;
|
char *s = 0;
|
||||||
s = WIN_StringToUTF8(videodata->ime_composition);
|
s = WIN_StringToUTF8W(videodata->ime_composition);
|
||||||
SDL_SendKeyboardText(s);
|
SDL_SendKeyboardText(s);
|
||||||
SDL_free(s);
|
SDL_free(s);
|
||||||
|
|
||||||
@ -774,7 +774,7 @@ IME_SendEditingEvent(SDL_VideoData *videodata)
|
|||||||
else {
|
else {
|
||||||
SDL_wcslcpy(buffer, videodata->ime_composition, size);
|
SDL_wcslcpy(buffer, videodata->ime_composition, size);
|
||||||
}
|
}
|
||||||
s = WIN_StringToUTF8(buffer);
|
s = WIN_StringToUTF8W(buffer);
|
||||||
SDL_SendEditingText(s, videodata->ime_cursor + (int)SDL_wcslen(videodata->ime_readingstring), 0);
|
SDL_SendEditingText(s, videodata->ime_cursor + (int)SDL_wcslen(videodata->ime_readingstring), 0);
|
||||||
SDL_free(s);
|
SDL_free(s);
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ static SDL_bool AddDialogString(WIN_DialogData *dialog, const char *string)
|
|||||||
string = "";
|
string = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring = WIN_UTF8ToString(string);
|
wstring = WIN_UTF8ToStringW(string);
|
||||||
if (!wstring) {
|
if (!wstring) {
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
@ -645,9 +645,9 @@ WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Measure the *pixel* size of the string. */
|
/* Measure the *pixel* size of the string. */
|
||||||
wmessage = WIN_UTF8ToString(messageboxdata->message);
|
wmessage = WIN_UTF8ToStringW(messageboxdata->message);
|
||||||
SDL_zero(TextSize);
|
SDL_zero(TextSize);
|
||||||
DrawText(FontDC, wmessage, -1, &TextSize, DT_CALCRECT | DT_LEFT | DT_NOPREFIX | DT_EDITCONTROL);
|
DrawTextW(FontDC, wmessage, -1, &TextSize, DT_CALCRECT | DT_LEFT | DT_NOPREFIX | DT_EDITCONTROL);
|
||||||
|
|
||||||
/* Add margins and some padding for hangs, etc. */
|
/* Add margins and some padding for hangs, etc. */
|
||||||
TextSize.left += TextMargin;
|
TextSize.left += TextMargin;
|
||||||
@ -822,8 +822,8 @@ WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
|||||||
ParentWindow = ((SDL_WindowData *) messageboxdata->window->driverdata)->hwnd;
|
ParentWindow = ((SDL_WindowData *) messageboxdata->window->driverdata)->hwnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
wmessage = WIN_UTF8ToString(messageboxdata->message);
|
wmessage = WIN_UTF8ToStringW(messageboxdata->message);
|
||||||
wtitle = WIN_UTF8ToString(messageboxdata->title);
|
wtitle = WIN_UTF8ToStringW(messageboxdata->title);
|
||||||
|
|
||||||
SDL_zero(TaskConfig);
|
SDL_zero(TaskConfig);
|
||||||
TaskConfig.cbSize = sizeof (TASKDIALOGCONFIG);
|
TaskConfig.cbSize = sizeof (TASKDIALOGCONFIG);
|
||||||
@ -872,7 +872,7 @@ WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
|||||||
SDL_free(pButtons);
|
SDL_free(pButtons);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
pButton->pszButtonText = WIN_UTF8ToString(buttontext);
|
pButton->pszButtonText = WIN_UTF8ToStringW(buttontext);
|
||||||
if (messageboxdata->buttons[i].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
|
if (messageboxdata->buttons[i].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
|
||||||
TaskConfig.nDefaultButton = pButton->nButtonID;
|
TaskConfig.nDefaultButton = pButton->nButtonID;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
/* #define DEBUG_MODES */
|
/* #define DEBUG_MODES */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
WIN_UpdateDisplayMode(_THIS, LPCTSTR deviceName, DWORD index, SDL_DisplayMode * mode)
|
WIN_UpdateDisplayMode(_THIS, LPCWSTR deviceName, DWORD index, SDL_DisplayMode * mode)
|
||||||
{
|
{
|
||||||
SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
|
SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
@ -109,14 +109,14 @@ WIN_UpdateDisplayMode(_THIS, LPCTSTR deviceName, DWORD index, SDL_DisplayMode *
|
|||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool
|
static SDL_bool
|
||||||
WIN_GetDisplayMode(_THIS, LPCTSTR deviceName, DWORD index, SDL_DisplayMode * mode)
|
WIN_GetDisplayMode(_THIS, LPCWSTR deviceName, DWORD index, SDL_DisplayMode * mode)
|
||||||
{
|
{
|
||||||
SDL_DisplayModeData *data;
|
SDL_DisplayModeData *data;
|
||||||
DEVMODE devmode;
|
DEVMODE devmode;
|
||||||
|
|
||||||
devmode.dmSize = sizeof(devmode);
|
devmode.dmSize = sizeof(devmode);
|
||||||
devmode.dmDriverExtra = 0;
|
devmode.dmDriverExtra = 0;
|
||||||
if (!EnumDisplaySettings(deviceName, index, &devmode)) {
|
if (!EnumDisplaySettingsW(deviceName, index, &devmode)) {
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,10 +145,10 @@ WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEXW *info, SDL_bool se
|
|||||||
SDL_VideoDisplay display;
|
SDL_VideoDisplay display;
|
||||||
SDL_DisplayData *displaydata;
|
SDL_DisplayData *displaydata;
|
||||||
SDL_DisplayMode mode;
|
SDL_DisplayMode mode;
|
||||||
DISPLAY_DEVICE device;
|
DISPLAY_DEVICEW device;
|
||||||
|
|
||||||
#ifdef DEBUG_MODES
|
#ifdef DEBUG_MODES
|
||||||
SDL_Log("Display: %s\n", WIN_StringToUTF8(info->szDevice));
|
SDL_Log("Display: %s\n", WIN_StringToUTF8W(info->szDevice));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!WIN_GetDisplayMode(_this, info->szDevice, ENUM_CURRENT_SETTINGS, &mode)) {
|
if (!WIN_GetDisplayMode(_this, info->szDevice, ENUM_CURRENT_SETTINGS, &mode)) {
|
||||||
@ -178,8 +178,8 @@ WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEXW *info, SDL_bool se
|
|||||||
|
|
||||||
SDL_zero(display);
|
SDL_zero(display);
|
||||||
device.cb = sizeof(device);
|
device.cb = sizeof(device);
|
||||||
if (EnumDisplayDevices(info->szDevice, 0, &device, 0)) {
|
if (EnumDisplayDevicesW(info->szDevice, 0, &device, 0)) {
|
||||||
display.name = WIN_StringToUTF8(device.DeviceString);
|
display.name = WIN_StringToUTF8W(device.DeviceString);
|
||||||
}
|
}
|
||||||
display.desktop_mode = mode;
|
display.desktop_mode = mode;
|
||||||
display.current_mode = mode;
|
display.current_mode = mode;
|
||||||
@ -383,9 +383,9 @@ WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
|||||||
LONG status;
|
LONG status;
|
||||||
|
|
||||||
if (mode->driverdata == display->desktop_mode.driverdata) {
|
if (mode->driverdata == display->desktop_mode.driverdata) {
|
||||||
status = ChangeDisplaySettingsEx(displaydata->DeviceName, NULL, NULL, CDS_FULLSCREEN, NULL);
|
status = ChangeDisplaySettingsExW(displaydata->DeviceName, NULL, NULL, CDS_FULLSCREEN, NULL);
|
||||||
} else {
|
} else {
|
||||||
status = ChangeDisplaySettingsEx(displaydata->DeviceName, &data->DeviceMode, NULL, CDS_FULLSCREEN, NULL);
|
status = ChangeDisplaySettingsExW(displaydata->DeviceName, &data->DeviceMode, NULL, CDS_FULLSCREEN, NULL);
|
||||||
}
|
}
|
||||||
if (status != DISP_CHANGE_SUCCESSFUL) {
|
if (status != DISP_CHANGE_SUCCESSFUL) {
|
||||||
const char *reason = "Unknown reason";
|
const char *reason = "Unknown reason";
|
||||||
@ -405,7 +405,7 @@ WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
|||||||
}
|
}
|
||||||
return SDL_SetError("ChangeDisplaySettingsEx() failed: %s", reason);
|
return SDL_SetError("ChangeDisplaySettingsEx() failed: %s", reason);
|
||||||
}
|
}
|
||||||
EnumDisplaySettings(displaydata->DeviceName, ENUM_CURRENT_SETTINGS, &data->DeviceMode);
|
EnumDisplaySettingsW(displaydata->DeviceName, ENUM_CURRENT_SETTINGS, &data->DeviceMode);
|
||||||
WIN_UpdateDisplayMode(_this, displaydata->DeviceName, ENUM_CURRENT_SETTINGS, mode);
|
WIN_UpdateDisplayMode(_this, displaydata->DeviceName, ENUM_CURRENT_SETTINGS, mode);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ SDL_Direct3D9GetAdapterIndex(int displayIndex)
|
|||||||
SDL_SetError("Invalid display index");
|
SDL_SetError("Invalid display index");
|
||||||
adapterIndex = -1; /* make sure we return something invalid */
|
adapterIndex = -1; /* make sure we return something invalid */
|
||||||
} else {
|
} else {
|
||||||
char *displayName = WIN_StringToUTF8(pData->DeviceName);
|
char *displayName = WIN_StringToUTF8W(pData->DeviceName);
|
||||||
unsigned int count = IDirect3D9_GetAdapterCount(pD3D);
|
unsigned int count = IDirect3D9_GetAdapterCount(pD3D);
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
for (i=0; i<count; i++) {
|
for (i=0; i<count; i++) {
|
||||||
@ -407,14 +407,14 @@ SDL_DXGIGetOutputInfo(int displayIndex, int *adapterIndex, int *outputIndex)
|
|||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
displayName = WIN_StringToUTF8(pData->DeviceName);
|
displayName = WIN_StringToUTF8W(pData->DeviceName);
|
||||||
nAdapter = 0;
|
nAdapter = 0;
|
||||||
while (*adapterIndex == -1 && SUCCEEDED(IDXGIFactory_EnumAdapters(pDXGIFactory, nAdapter, &pDXGIAdapter))) {
|
while (*adapterIndex == -1 && SUCCEEDED(IDXGIFactory_EnumAdapters(pDXGIFactory, nAdapter, &pDXGIAdapter))) {
|
||||||
nOutput = 0;
|
nOutput = 0;
|
||||||
while (*adapterIndex == -1 && SUCCEEDED(IDXGIAdapter_EnumOutputs(pDXGIAdapter, nOutput, &pDXGIOutput))) {
|
while (*adapterIndex == -1 && SUCCEEDED(IDXGIAdapter_EnumOutputs(pDXGIAdapter, nOutput, &pDXGIOutput))) {
|
||||||
DXGI_OUTPUT_DESC outputDesc;
|
DXGI_OUTPUT_DESC outputDesc;
|
||||||
if (SUCCEEDED(IDXGIOutput_GetDesc(pDXGIOutput, &outputDesc))) {
|
if (SUCCEEDED(IDXGIOutput_GetDesc(pDXGIOutput, &outputDesc))) {
|
||||||
char *outputName = WIN_StringToUTF8(outputDesc.DeviceName);
|
char *outputName = WIN_StringToUTF8W(outputDesc.DeviceName);
|
||||||
if (SDL_strcmp(outputName, displayName) == 0) {
|
if (SDL_strcmp(outputName, displayName) == 0) {
|
||||||
*adapterIndex = nAdapter;
|
*adapterIndex = nAdapter;
|
||||||
*outputIndex = nOutput;
|
*outputIndex = nOutput;
|
||||||
|
@ -708,7 +708,7 @@ WIN_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp)
|
|||||||
HDC hdc;
|
HDC hdc;
|
||||||
BOOL succeeded = FALSE;
|
BOOL succeeded = FALSE;
|
||||||
|
|
||||||
hdc = CreateDC(data->DeviceName, NULL, NULL, NULL);
|
hdc = CreateDCW(data->DeviceName, NULL, NULL, NULL);
|
||||||
if (hdc) {
|
if (hdc) {
|
||||||
succeeded = SetDeviceGammaRamp(hdc, (LPVOID)ramp);
|
succeeded = SetDeviceGammaRamp(hdc, (LPVOID)ramp);
|
||||||
if (!succeeded) {
|
if (!succeeded) {
|
||||||
@ -727,7 +727,7 @@ WIN_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp)
|
|||||||
HDC hdc;
|
HDC hdc;
|
||||||
BOOL succeeded = FALSE;
|
BOOL succeeded = FALSE;
|
||||||
|
|
||||||
hdc = CreateDC(data->DeviceName, NULL, NULL, NULL);
|
hdc = CreateDCW(data->DeviceName, NULL, NULL, NULL);
|
||||||
if (hdc) {
|
if (hdc) {
|
||||||
succeeded = GetDeviceGammaRamp(hdc, (LPVOID)ramp);
|
succeeded = GetDeviceGammaRamp(hdc, (LPVOID)ramp);
|
||||||
if (!succeeded) {
|
if (!succeeded) {
|
||||||
|
Loading…
Reference in New Issue
Block a user