2015-06-21 17:33:46 +02:00
|
|
|
/*
|
|
|
|
Simple DirectMedia Layer
|
2016-01-02 19:10:34 +01:00
|
|
|
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
|
2015-06-21 17:33:46 +02:00
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any damages
|
|
|
|
arising from the use of this software.
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
including commercial applications, and to alter it and redistribute it
|
|
|
|
freely, subject to the following restrictions:
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you must not
|
|
|
|
claim that you wrote the original software. If you use this software
|
|
|
|
in a product, an acknowledgment in the product documentation would be
|
|
|
|
appreciated but is not required.
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
|
|
misrepresented as being the original software.
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
|
|
*/
|
|
|
|
#include "../../SDL_internal.h"
|
|
|
|
|
|
|
|
#if SDL_VIDEO_DRIVER_WINDOWS
|
|
|
|
|
|
|
|
#include "SDL_windowsvideo.h"
|
2016-01-05 11:22:35 +01:00
|
|
|
#include "../../../include/SDL_assert.h"
|
2015-06-21 17:33:46 +02:00
|
|
|
|
|
|
|
/* Windows CE compatibility */
|
|
|
|
#ifndef CDS_FULLSCREEN
|
|
|
|
#define CDS_FULLSCREEN 0
|
|
|
|
#endif
|
|
|
|
|
2015-07-30 02:18:56 +02:00
|
|
|
typedef struct _WIN_GetMonitorDPIData {
|
2015-10-07 06:40:50 +02:00
|
|
|
SDL_VideoData *vid_data;
|
|
|
|
SDL_DisplayMode *mode;
|
|
|
|
SDL_DisplayModeData *mode_data;
|
2015-07-30 02:18:56 +02:00
|
|
|
} WIN_GetMonitorDPIData;
|
|
|
|
|
|
|
|
static BOOL CALLBACK
|
|
|
|
WIN_GetMonitorDPI(HMONITOR hMonitor,
|
2015-10-07 06:40:50 +02:00
|
|
|
HDC hdcMonitor,
|
|
|
|
LPRECT lprcMonitor,
|
|
|
|
LPARAM dwData)
|
2015-07-30 02:18:56 +02:00
|
|
|
{
|
2015-10-07 06:40:50 +02:00
|
|
|
WIN_GetMonitorDPIData *data = (WIN_GetMonitorDPIData*) dwData;
|
|
|
|
UINT hdpi, vdpi;
|
|
|
|
|
|
|
|
if (data->vid_data->GetDpiForMonitor(hMonitor, MDT_EFFECTIVE_DPI, &hdpi, &vdpi) == S_OK &&
|
|
|
|
hdpi > 0 &&
|
|
|
|
vdpi > 0) {
|
|
|
|
float hsize, vsize;
|
|
|
|
|
|
|
|
data->mode_data->HorzDPI = (float)hdpi;
|
|
|
|
data->mode_data->VertDPI = (float)vdpi;
|
|
|
|
|
|
|
|
// Figure out the monitor size and compute the diagonal DPI.
|
|
|
|
hsize = data->mode->w / data->mode_data->HorzDPI;
|
|
|
|
vsize = data->mode->h / data->mode_data->VertDPI;
|
|
|
|
|
|
|
|
data->mode_data->DiagDPI = SDL_ComputeDiagonalDPI( data->mode->w,
|
|
|
|
data->mode->h,
|
|
|
|
hsize,
|
|
|
|
vsize );
|
|
|
|
|
|
|
|
// We can only handle one DPI per display mode so end the enumeration.
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We didn't get DPI information so keep going.
|
|
|
|
return TRUE;
|
2015-07-30 02:18:56 +02:00
|
|
|
}
|
|
|
|
|
2016-03-11 17:33:47 +01:00
|
|
|
static void
|
|
|
|
WIN_UpdateDisplayMode(_THIS, LPCTSTR deviceName, DWORD index, SDL_DisplayMode * mode)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
2015-07-30 02:18:56 +02:00
|
|
|
SDL_VideoData *vid_data = (SDL_VideoData *) _this->driverdata;
|
2016-03-11 17:33:47 +01:00
|
|
|
SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
|
2015-06-21 17:33:46 +02:00
|
|
|
HDC hdc;
|
|
|
|
|
|
|
|
data->DeviceMode.dmFields =
|
|
|
|
(DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY |
|
|
|
|
DM_DISPLAYFLAGS);
|
|
|
|
|
|
|
|
if (index == ENUM_CURRENT_SETTINGS
|
|
|
|
&& (hdc = CreateDC(deviceName, NULL, NULL, NULL)) != NULL) {
|
|
|
|
char bmi_data[sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)];
|
|
|
|
LPBITMAPINFO bmi;
|
|
|
|
HBITMAP hbm;
|
2015-10-07 06:40:50 +02:00
|
|
|
int logical_width = GetDeviceCaps( hdc, HORZRES );
|
|
|
|
int logical_height = GetDeviceCaps( hdc, VERTRES );
|
|
|
|
|
2016-03-11 17:33:47 +01:00
|
|
|
data->ScaleX = (float)logical_width / data->DeviceMode.dmPelsWidth;
|
|
|
|
data->ScaleY = (float)logical_height / data->DeviceMode.dmPelsHeight;
|
2015-10-07 06:40:50 +02:00
|
|
|
mode->w = logical_width;
|
|
|
|
mode->h = logical_height;
|
|
|
|
|
|
|
|
// WIN_GetMonitorDPI needs mode->w and mode->h
|
|
|
|
// so only call after those are set.
|
|
|
|
if (vid_data->GetDpiForMonitor) {
|
|
|
|
WIN_GetMonitorDPIData dpi_data;
|
2015-07-30 02:19:13 +02:00
|
|
|
RECT monitor_rect;
|
2015-07-30 02:18:56 +02:00
|
|
|
|
2015-10-07 06:40:50 +02:00
|
|
|
dpi_data.vid_data = vid_data;
|
|
|
|
dpi_data.mode = mode;
|
|
|
|
dpi_data.mode_data = data;
|
2016-03-11 17:33:47 +01:00
|
|
|
monitor_rect.left = data->DeviceMode.dmPosition.x;
|
|
|
|
monitor_rect.top = data->DeviceMode.dmPosition.y;
|
2015-07-30 02:19:13 +02:00
|
|
|
monitor_rect.right = monitor_rect.left + 1;
|
|
|
|
monitor_rect.bottom = monitor_rect.top + 1;
|
2015-10-07 06:40:50 +02:00
|
|
|
EnumDisplayMonitors(NULL, &monitor_rect, WIN_GetMonitorDPI, (LPARAM)&dpi_data);
|
|
|
|
} else {
|
|
|
|
// We don't have the Windows 8.1 routine so just
|
|
|
|
// get system DPI.
|
|
|
|
data->HorzDPI = (float)GetDeviceCaps( hdc, LOGPIXELSX );
|
|
|
|
data->VertDPI = (float)GetDeviceCaps( hdc, LOGPIXELSY );
|
|
|
|
if (data->HorzDPI == data->VertDPI) {
|
|
|
|
data->DiagDPI = data->HorzDPI;
|
|
|
|
} else {
|
|
|
|
data->DiagDPI = SDL_ComputeDiagonalDPI( mode->w,
|
|
|
|
mode->h,
|
|
|
|
(float)GetDeviceCaps( hdc, HORZSIZE ) / 25.4f,
|
|
|
|
(float)GetDeviceCaps( hdc, VERTSIZE ) / 25.4f );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-21 17:33:46 +02:00
|
|
|
SDL_zero(bmi_data);
|
|
|
|
bmi = (LPBITMAPINFO) bmi_data;
|
|
|
|
bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
|
|
|
|
|
|
|
hbm = CreateCompatibleBitmap(hdc, 1, 1);
|
|
|
|
GetDIBits(hdc, hbm, 0, 1, NULL, bmi, DIB_RGB_COLORS);
|
|
|
|
GetDIBits(hdc, hbm, 0, 1, NULL, bmi, DIB_RGB_COLORS);
|
|
|
|
DeleteObject(hbm);
|
|
|
|
DeleteDC(hdc);
|
|
|
|
if (bmi->bmiHeader.biCompression == BI_BITFIELDS) {
|
|
|
|
switch (*(Uint32 *) bmi->bmiColors) {
|
|
|
|
case 0x00FF0000:
|
|
|
|
mode->format = SDL_PIXELFORMAT_RGB888;
|
|
|
|
break;
|
|
|
|
case 0x000000FF:
|
|
|
|
mode->format = SDL_PIXELFORMAT_BGR888;
|
|
|
|
break;
|
|
|
|
case 0xF800:
|
|
|
|
mode->format = SDL_PIXELFORMAT_RGB565;
|
|
|
|
break;
|
|
|
|
case 0x7C00:
|
|
|
|
mode->format = SDL_PIXELFORMAT_RGB555;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (bmi->bmiHeader.biBitCount == 8) {
|
|
|
|
mode->format = SDL_PIXELFORMAT_INDEX8;
|
|
|
|
} else if (bmi->bmiHeader.biBitCount == 4) {
|
|
|
|
mode->format = SDL_PIXELFORMAT_INDEX4LSB;
|
|
|
|
}
|
2016-03-11 17:33:47 +01:00
|
|
|
} else if (mode->format == SDL_PIXELFORMAT_UNKNOWN) {
|
2015-06-21 17:33:46 +02:00
|
|
|
/* FIXME: Can we tell what this will be? */
|
2016-03-11 17:33:47 +01:00
|
|
|
if ((data->DeviceMode.dmFields & DM_BITSPERPEL) == DM_BITSPERPEL) {
|
|
|
|
switch (data->DeviceMode.dmBitsPerPel) {
|
2015-06-21 17:33:46 +02:00
|
|
|
case 32:
|
|
|
|
mode->format = SDL_PIXELFORMAT_RGB888;
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
mode->format = SDL_PIXELFORMAT_RGB24;
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
mode->format = SDL_PIXELFORMAT_RGB565;
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
mode->format = SDL_PIXELFORMAT_RGB555;
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
mode->format = SDL_PIXELFORMAT_INDEX8;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
mode->format = SDL_PIXELFORMAT_INDEX4LSB;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-03-11 17:33:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static SDL_bool
|
|
|
|
WIN_GetDisplayMode(_THIS, LPCTSTR deviceName, DWORD index, SDL_DisplayMode * mode)
|
|
|
|
{
|
|
|
|
SDL_DisplayModeData *data;
|
|
|
|
DEVMODE devmode;
|
|
|
|
|
|
|
|
devmode.dmSize = sizeof(devmode);
|
|
|
|
devmode.dmDriverExtra = 0;
|
|
|
|
if (!EnumDisplaySettings(deviceName, index, &devmode)) {
|
|
|
|
return SDL_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
data = (SDL_DisplayModeData *) SDL_malloc(sizeof(*data));
|
|
|
|
if (!data) {
|
|
|
|
return SDL_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
mode->driverdata = data;
|
|
|
|
data->DeviceMode = devmode;
|
|
|
|
|
|
|
|
/* Default basic information */
|
|
|
|
data->ScaleX = 1.0f;
|
|
|
|
data->ScaleY = 1.0f;
|
|
|
|
data->DiagDPI = 0.0f;
|
|
|
|
data->HorzDPI = 0.0f;
|
|
|
|
data->VertDPI = 0.0f;
|
|
|
|
|
|
|
|
mode->format = SDL_PIXELFORMAT_UNKNOWN;
|
|
|
|
mode->w = data->DeviceMode.dmPelsWidth;
|
|
|
|
mode->h = data->DeviceMode.dmPelsHeight;
|
|
|
|
mode->refresh_rate = data->DeviceMode.dmDisplayFrequency;
|
|
|
|
|
|
|
|
/* Fill in the mode information */
|
|
|
|
WIN_UpdateDisplayMode(_this, deviceName, index, mode);
|
2015-06-21 17:33:46 +02:00
|
|
|
return SDL_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static SDL_bool
|
2015-07-30 02:18:56 +02:00
|
|
|
WIN_AddDisplay(_THIS, LPTSTR DeviceName)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
|
|
|
SDL_VideoDisplay display;
|
|
|
|
SDL_DisplayData *displaydata;
|
|
|
|
SDL_DisplayMode mode;
|
|
|
|
DISPLAY_DEVICE device;
|
|
|
|
|
|
|
|
#ifdef DEBUG_MODES
|
|
|
|
printf("Display: %s\n", WIN_StringToUTF8(DeviceName));
|
|
|
|
#endif
|
2015-07-30 02:18:56 +02:00
|
|
|
if (!WIN_GetDisplayMode(_this, DeviceName, ENUM_CURRENT_SETTINGS, &mode)) {
|
2015-06-21 17:33:46 +02:00
|
|
|
return SDL_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
|
|
|
|
if (!displaydata) {
|
|
|
|
return SDL_FALSE;
|
|
|
|
}
|
|
|
|
SDL_memcpy(displaydata->DeviceName, DeviceName,
|
|
|
|
sizeof(displaydata->DeviceName));
|
|
|
|
|
|
|
|
SDL_zero(display);
|
|
|
|
device.cb = sizeof(device);
|
|
|
|
if (EnumDisplayDevices(DeviceName, 0, &device, 0)) {
|
|
|
|
display.name = WIN_StringToUTF8(device.DeviceString);
|
|
|
|
}
|
|
|
|
display.desktop_mode = mode;
|
|
|
|
display.current_mode = mode;
|
|
|
|
display.driverdata = displaydata;
|
|
|
|
SDL_AddVideoDisplay(&display);
|
|
|
|
SDL_free(display.name);
|
|
|
|
return SDL_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
WIN_InitModes(_THIS)
|
|
|
|
{
|
|
|
|
int pass;
|
|
|
|
DWORD i, j, count;
|
|
|
|
DISPLAY_DEVICE device;
|
|
|
|
|
|
|
|
device.cb = sizeof(device);
|
|
|
|
|
|
|
|
/* Get the primary display in the first pass */
|
|
|
|
for (pass = 0; pass < 2; ++pass) {
|
|
|
|
for (i = 0; ; ++i) {
|
|
|
|
TCHAR DeviceName[32];
|
|
|
|
|
|
|
|
if (!EnumDisplayDevices(NULL, i, &device, 0)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!(device.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (pass == 0) {
|
|
|
|
if (!(device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SDL_memcpy(DeviceName, device.DeviceName, sizeof(DeviceName));
|
|
|
|
#ifdef DEBUG_MODES
|
|
|
|
printf("Device: %s\n", WIN_StringToUTF8(DeviceName));
|
|
|
|
#endif
|
|
|
|
count = 0;
|
|
|
|
for (j = 0; ; ++j) {
|
|
|
|
if (!EnumDisplayDevices(DeviceName, j, &device, 0)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!(device.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (pass == 0) {
|
|
|
|
if (!(device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2015-07-30 02:18:56 +02:00
|
|
|
count += WIN_AddDisplay(_this, device.DeviceName);
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
if (count == 0) {
|
2015-07-30 02:18:56 +02:00
|
|
|
WIN_AddDisplay(_this, DeviceName);
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (_this->num_displays == 0) {
|
|
|
|
return SDL_SetError("No displays available");
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
WIN_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect)
|
|
|
|
{
|
|
|
|
SDL_DisplayModeData *data = (SDL_DisplayModeData *) display->current_mode.driverdata;
|
|
|
|
|
|
|
|
rect->x = (int)SDL_ceil(data->DeviceMode.dmPosition.x * data->ScaleX);
|
|
|
|
rect->y = (int)SDL_ceil(data->DeviceMode.dmPosition.y * data->ScaleY);
|
|
|
|
rect->w = (int)SDL_ceil(data->DeviceMode.dmPelsWidth * data->ScaleX);
|
|
|
|
rect->h = (int)SDL_ceil(data->DeviceMode.dmPelsHeight * data->ScaleY);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-07-30 02:18:56 +02:00
|
|
|
int
|
|
|
|
WIN_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi)
|
|
|
|
{
|
|
|
|
SDL_DisplayModeData *data = (SDL_DisplayModeData *) display->current_mode.driverdata;
|
|
|
|
|
2015-10-07 06:40:50 +02:00
|
|
|
if (ddpi) {
|
|
|
|
*ddpi = data->DiagDPI;
|
|
|
|
}
|
|
|
|
if (hdpi) {
|
|
|
|
*hdpi = data->HorzDPI;
|
|
|
|
}
|
|
|
|
if (vdpi) {
|
|
|
|
*vdpi = data->VertDPI;
|
|
|
|
}
|
|
|
|
|
2016-05-20 22:15:58 +02:00
|
|
|
return data->DiagDPI != 0.0f ? 0 : SDL_SetError("Couldn't get DPI");
|
2015-07-30 02:18:56 +02:00
|
|
|
}
|
|
|
|
|
2016-01-05 05:52:40 +01:00
|
|
|
int
|
|
|
|
WIN_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect)
|
|
|
|
{
|
|
|
|
const SDL_DisplayModeData *data = (const SDL_DisplayModeData *) display->current_mode.driverdata;
|
|
|
|
const DEVMODE *pDevMode = &data->DeviceMode;
|
|
|
|
POINT pt = {
|
|
|
|
/* !!! FIXME: no scale, right? */
|
|
|
|
(LONG) (pDevMode->dmPosition.x + (pDevMode->dmPelsWidth / 2)),
|
|
|
|
(LONG) (pDevMode->dmPosition.y + (pDevMode->dmPelsHeight / 2))
|
|
|
|
};
|
2016-01-05 11:22:35 +01:00
|
|
|
HMONITOR hmon = MonitorFromPoint(pt, MONITOR_DEFAULTTONULL);
|
2016-01-05 05:52:40 +01:00
|
|
|
MONITORINFO minfo;
|
|
|
|
const RECT *work;
|
|
|
|
BOOL rc = FALSE;
|
|
|
|
|
|
|
|
SDL_assert(hmon != NULL);
|
|
|
|
|
|
|
|
if (hmon != NULL) {
|
|
|
|
SDL_zero(minfo);
|
|
|
|
minfo.cbSize = sizeof (MONITORINFO);
|
|
|
|
rc = GetMonitorInfo(hmon, &minfo);
|
|
|
|
SDL_assert(rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!rc) {
|
|
|
|
return SDL_SetError("Couldn't find monitor data");
|
|
|
|
}
|
|
|
|
|
2016-01-05 11:22:35 +01:00
|
|
|
work = &minfo.rcWork;
|
2016-01-05 05:52:40 +01:00
|
|
|
rect->x = (int)SDL_ceil(work->left * data->ScaleX);
|
|
|
|
rect->y = (int)SDL_ceil(work->top * data->ScaleY);
|
|
|
|
rect->w = (int)SDL_ceil((work->right - work->left) * data->ScaleX);
|
|
|
|
rect->h = (int)SDL_ceil((work->bottom - work->top) * data->ScaleY);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-06-21 17:33:46 +02:00
|
|
|
void
|
|
|
|
WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
|
|
|
|
{
|
|
|
|
SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
|
|
|
|
DWORD i;
|
|
|
|
SDL_DisplayMode mode;
|
|
|
|
|
|
|
|
for (i = 0;; ++i) {
|
2015-07-30 02:18:56 +02:00
|
|
|
if (!WIN_GetDisplayMode(_this, data->DeviceName, i, &mode)) {
|
2015-06-21 17:33:46 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (SDL_ISPIXELFORMAT_INDEXED(mode.format)) {
|
|
|
|
/* We don't support palettized modes now */
|
|
|
|
SDL_free(mode.driverdata);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (mode.format != SDL_PIXELFORMAT_UNKNOWN) {
|
|
|
|
if (!SDL_AddDisplayMode(display, &mode)) {
|
|
|
|
SDL_free(mode.driverdata);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
SDL_free(mode.driverdata);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
|
|
|
{
|
|
|
|
SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
|
|
|
|
SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
|
|
|
|
LONG status;
|
|
|
|
|
|
|
|
if (mode->driverdata == display->desktop_mode.driverdata) {
|
2016-05-23 20:29:25 +02:00
|
|
|
status = ChangeDisplaySettingsEx(displaydata->DeviceName, NULL, NULL, CDS_FULLSCREEN, NULL);
|
2015-06-21 17:33:46 +02:00
|
|
|
} else {
|
|
|
|
status = ChangeDisplaySettingsEx(displaydata->DeviceName, &data->DeviceMode, NULL, CDS_FULLSCREEN, NULL);
|
|
|
|
}
|
|
|
|
if (status != DISP_CHANGE_SUCCESSFUL) {
|
|
|
|
const char *reason = "Unknown reason";
|
|
|
|
switch (status) {
|
|
|
|
case DISP_CHANGE_BADFLAGS:
|
|
|
|
reason = "DISP_CHANGE_BADFLAGS";
|
|
|
|
break;
|
|
|
|
case DISP_CHANGE_BADMODE:
|
|
|
|
reason = "DISP_CHANGE_BADMODE";
|
|
|
|
break;
|
|
|
|
case DISP_CHANGE_BADPARAM:
|
|
|
|
reason = "DISP_CHANGE_BADPARAM";
|
|
|
|
break;
|
|
|
|
case DISP_CHANGE_FAILED:
|
|
|
|
reason = "DISP_CHANGE_FAILED";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return SDL_SetError("ChangeDisplaySettingsEx() failed: %s", reason);
|
|
|
|
}
|
|
|
|
EnumDisplaySettings(displaydata->DeviceName, ENUM_CURRENT_SETTINGS, &data->DeviceMode);
|
2016-03-11 17:33:47 +01:00
|
|
|
WIN_UpdateDisplayMode(_this, displaydata->DeviceName, ENUM_CURRENT_SETTINGS, mode);
|
2015-06-21 17:33:46 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
WIN_QuitModes(_THIS)
|
|
|
|
{
|
|
|
|
/* All fullscreen windows should have restored modes by now */
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* SDL_VIDEO_DRIVER_WINDOWS */
|
|
|
|
|
|
|
|
/* vi: set ts=4 sw=4 expandtab: */
|