Windows default to fullscreen desktop mode if they don't pick an explicit video mode

Rather than iterating over display modes using an index, there is a new function SDL_GetFullscreenDisplayModes() to get the list of available fullscreen modes on a display.
{
    SDL_DisplayID display = SDL_GetPrimaryDisplay();
    int num_modes = 0;
    SDL_DisplayMode **modes = SDL_GetFullscreenDisplayModes(display, &num_modes);
    if (modes) {
        for (i = 0; i < num_modes; ++i) {
            SDL_DisplayMode *mode = modes[i];
            SDL_Log("Display %" SDL_PRIu32 " mode %d:  %dx%d@%gHz, %d%% scale\n",
                    display, i, mode->pixel_w, mode->pixel_h, mode->refresh_rate, (int)(mode->display_scale * 100.0f));
        }
        SDL_free(modes);
    }
}

SDL_GetDesktopDisplayMode() and SDL_GetCurrentDisplayMode() return pointers to display modes rather than filling in application memory.

Windows now have an explicit fullscreen mode that is set, using SDL_SetWindowFullscreenMode(). The fullscreen mode for a window can be queried with SDL_GetWindowFullscreenMode(), which returns a pointer to the mode, or NULL if the window will be fullscreen desktop. SDL_SetWindowFullscreen() just takes a boolean value, setting the correct fullscreen state based on the selected mode.
This commit is contained in:
Sam Lantinga
2023-01-31 21:23:14 -08:00
parent 048df6260c
commit 6b137579ea
50 changed files with 976 additions and 1190 deletions

View File

@@ -153,7 +153,6 @@ SDL3_0.0.0 {
SDL_GetCPUCacheLineSize;
SDL_GetCPUCount;
SDL_GetClipboardText;
SDL_GetClosestDisplayMode;
SDL_GetCurrentAudioDriver;
SDL_GetCurrentDisplayMode;
SDL_GetCurrentVideoDriver;
@@ -166,7 +165,6 @@ SDL3_0.0.0 {
SDL_GetDisplayPhysicalDPI;
SDL_GetDisplayForPoint;
SDL_GetDisplayForRect;
SDL_GetDisplayMode;
SDL_GetDisplayName;
SDL_GetDisplayOrientation;
SDL_GetDisplayUsableBounds;
@@ -260,7 +258,6 @@ SDL3_0.0.0 {
SDL_GetNumAllocations;
SDL_GetNumAudioDevices;
SDL_GetNumAudioDrivers;
SDL_GetNumDisplayModes;
SDL_GetNumGamepadMappings;
SDL_GetNumJoystickAxes;
SDL_GetNumJoystickButtons;
@@ -348,7 +345,7 @@ SDL3_0.0.0 {
SDL_GetWindowBordersSize;
SDL_GetWindowData;
SDL_GetDisplayForWindow;
SDL_GetWindowDisplayMode;
SDL_GetWindowFullscreenMode;
SDL_GetWindowFlags;
SDL_GetWindowFromID;
SDL_GetWindowGrab;
@@ -613,7 +610,7 @@ SDL3_0.0.0 {
SDL_SetWindowAlwaysOnTop;
SDL_SetWindowBordered;
SDL_SetWindowData;
SDL_SetWindowDisplayMode;
SDL_SetWindowFullscreenMode;
SDL_SetWindowFullscreen;
SDL_SetWindowGrab;
SDL_SetWindowHitTest;
@@ -840,6 +837,8 @@ SDL3_0.0.0 {
SDL_ConvertAudioSamples;
SDL_GetDisplays;
SDL_GetPrimaryDisplay;
SDL_GetFullscreenDisplayModes;
SDL_GetClosestFullscreenDisplayMode;
# extra symbols go here (don't modify this line)
local: *;
};

View File

@@ -178,7 +178,6 @@
#define SDL_GetCPUCacheLineSize SDL_GetCPUCacheLineSize_REAL
#define SDL_GetCPUCount SDL_GetCPUCount_REAL
#define SDL_GetClipboardText SDL_GetClipboardText_REAL
#define SDL_GetClosestDisplayMode SDL_GetClosestDisplayMode_REAL
#define SDL_GetCurrentAudioDriver SDL_GetCurrentAudioDriver_REAL
#define SDL_GetCurrentDisplayMode SDL_GetCurrentDisplayMode_REAL
#define SDL_GetCurrentVideoDriver SDL_GetCurrentVideoDriver_REAL
@@ -191,7 +190,6 @@
#define SDL_GetDisplayPhysicalDPI SDL_GetDisplayPhysicalDPI_REAL
#define SDL_GetDisplayForPoint SDL_GetDisplayForPoint_REAL
#define SDL_GetDisplayForRect SDL_GetDisplayForRect_REAL
#define SDL_GetDisplayMode SDL_GetDisplayMode_REAL
#define SDL_GetDisplayName SDL_GetDisplayName_REAL
#define SDL_GetDisplayOrientation SDL_GetDisplayOrientation_REAL
#define SDL_GetDisplayUsableBounds SDL_GetDisplayUsableBounds_REAL
@@ -285,7 +283,6 @@
#define SDL_GetNumAllocations SDL_GetNumAllocations_REAL
#define SDL_GetNumAudioDevices SDL_GetNumAudioDevices_REAL
#define SDL_GetNumAudioDrivers SDL_GetNumAudioDrivers_REAL
#define SDL_GetNumDisplayModes SDL_GetNumDisplayModes_REAL
#define SDL_GetNumGamepadMappings SDL_GetNumGamepadMappings_REAL
#define SDL_GetNumJoystickAxes SDL_GetNumJoystickAxes_REAL
#define SDL_GetNumJoystickButtons SDL_GetNumJoystickButtons_REAL
@@ -373,7 +370,7 @@
#define SDL_GetWindowBordersSize SDL_GetWindowBordersSize_REAL
#define SDL_GetWindowData SDL_GetWindowData_REAL
#define SDL_GetDisplayForWindow SDL_GetDisplayForWindow_REAL
#define SDL_GetWindowDisplayMode SDL_GetWindowDisplayMode_REAL
#define SDL_GetWindowFullscreenMode SDL_GetWindowFullscreenMode_REAL
#define SDL_GetWindowFlags SDL_GetWindowFlags_REAL
#define SDL_GetWindowFromID SDL_GetWindowFromID_REAL
#define SDL_GetWindowGrab SDL_GetWindowGrab_REAL
@@ -638,7 +635,7 @@
#define SDL_SetWindowAlwaysOnTop SDL_SetWindowAlwaysOnTop_REAL
#define SDL_SetWindowBordered SDL_SetWindowBordered_REAL
#define SDL_SetWindowData SDL_SetWindowData_REAL
#define SDL_SetWindowDisplayMode SDL_SetWindowDisplayMode_REAL
#define SDL_SetWindowFullscreenMode SDL_SetWindowFullscreenMode_REAL
#define SDL_SetWindowFullscreen SDL_SetWindowFullscreen_REAL
#define SDL_SetWindowGrab SDL_SetWindowGrab_REAL
#define SDL_SetWindowHitTest SDL_SetWindowHitTest_REAL
@@ -867,3 +864,5 @@
#define SDL_ConvertAudioSamples SDL_ConvertAudioSamples_REAL
#define SDL_GetDisplays SDL_GetDisplays_REAL
#define SDL_GetPrimaryDisplay SDL_GetPrimaryDisplay_REAL
#define SDL_GetFullscreenDisplayModes SDL_GetFullscreenDisplayModes_REAL
#define SDL_GetClosestFullscreenDisplayMode SDL_GetClosestFullscreenDisplayMode_REAL

View File

@@ -252,20 +252,18 @@ SDL_DYNAPI_PROC(char*,SDL_GetBasePath,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetCPUCacheLineSize,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetCPUCount,(void),(),return)
SDL_DYNAPI_PROC(char*,SDL_GetClipboardText,(void),(),return)
SDL_DYNAPI_PROC(SDL_DisplayMode*,SDL_GetClosestDisplayMode,(SDL_DisplayID a, const SDL_DisplayMode *b, SDL_DisplayMode *c),(a,b,c),return)
SDL_DYNAPI_PROC(const char*,SDL_GetCurrentAudioDriver,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetCurrentDisplayMode,(SDL_DisplayID a, SDL_DisplayMode *b),(a,b),return)
SDL_DYNAPI_PROC(const SDL_DisplayMode*,SDL_GetCurrentDisplayMode,(SDL_DisplayID a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetCurrentVideoDriver,(void),(),return)
SDL_DYNAPI_PROC(SDL_Cursor*,SDL_GetCursor,(void),(),return)
SDL_DYNAPI_PROC(SDL_AssertionHandler,SDL_GetDefaultAssertionHandler,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetDefaultAudioInfo,(char **a, SDL_AudioSpec *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_Cursor*,SDL_GetDefaultCursor,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetDesktopDisplayMode,(SDL_DisplayID a, SDL_DisplayMode *b),(a,b),return)
SDL_DYNAPI_PROC(const SDL_DisplayMode*,SDL_GetDesktopDisplayMode,(SDL_DisplayID a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetDisplayBounds,(SDL_DisplayID a, SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetDisplayPhysicalDPI,(SDL_DisplayID a, float *b, float *c, float *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_DisplayID,SDL_GetDisplayForPoint,(const SDL_Point *a),(a),return)
SDL_DYNAPI_PROC(SDL_DisplayID,SDL_GetDisplayForRect,(const SDL_Rect *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetDisplayMode,(SDL_DisplayID a, int b, SDL_DisplayMode *c),(a,b,c),return)
SDL_DYNAPI_PROC(const char*,SDL_GetDisplayName,(SDL_DisplayID a),(a),return)
SDL_DYNAPI_PROC(SDL_DisplayOrientation,SDL_GetDisplayOrientation,(SDL_DisplayID a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetDisplayUsableBounds,(SDL_DisplayID a, SDL_Rect *b),(a,b),return)
@@ -359,7 +357,6 @@ SDL_DYNAPI_PROC(Uint32,SDL_GetMouseState,(float *a, float *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetNumAllocations,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetNumAudioDevices,(int a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetNumAudioDrivers,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetNumDisplayModes,(SDL_DisplayID a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetNumGamepadMappings,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetNumJoystickAxes,(SDL_Joystick *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetNumJoystickButtons,(SDL_Joystick *a),(a),return)
@@ -445,7 +442,7 @@ SDL_DYNAPI_PROC(const char*,SDL_GetVideoDriver,(int a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetWindowBordersSize,(SDL_Window *a, int *b, int *c, int *d, int *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(void*,SDL_GetWindowData,(SDL_Window *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_DisplayID,SDL_GetDisplayForWindow,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetWindowDisplayMode,(SDL_Window *a, SDL_DisplayMode *b),(a,b),return)
SDL_DYNAPI_PROC(const SDL_DisplayMode*,SDL_GetWindowFullscreenMode,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(Uint32,SDL_GetWindowFlags,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_Window*,SDL_GetWindowFromID,(Uint32 a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowGrab,(SDL_Window *a),(a),return)
@@ -693,8 +690,8 @@ SDL_DYNAPI_PROC(int,SDL_SetThreadPriority,(SDL_ThreadPriority a),(a),return)
SDL_DYNAPI_PROC(void,SDL_SetWindowAlwaysOnTop,(SDL_Window *a, SDL_bool b),(a,b),)
SDL_DYNAPI_PROC(void,SDL_SetWindowBordered,(SDL_Window *a, SDL_bool b),(a,b),)
SDL_DYNAPI_PROC(void*,SDL_SetWindowData,(SDL_Window *a, const char *b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowDisplayMode,(SDL_Window *a, const SDL_DisplayMode *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowFullscreen,(SDL_Window *a, Uint32 b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowFullscreenMode,(SDL_Window *a, const SDL_DisplayMode *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowFullscreen,(SDL_Window *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_SetWindowGrab,(SDL_Window *a, SDL_bool b),(a,b),)
SDL_DYNAPI_PROC(int,SDL_SetWindowHitTest,(SDL_Window *a, SDL_HitTest b, void *c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_SetWindowIcon,(SDL_Window *a, SDL_Surface *b),(a,b),)
@@ -912,3 +909,5 @@ SDL_DYNAPI_PROC(void,SDL_aligned_free,(void *a),(a),)
SDL_DYNAPI_PROC(int,SDL_ConvertAudioSamples,(SDL_AudioFormat a, Uint8 b, int c, int d, Uint8 *e, SDL_AudioFormat f, Uint8 g, int h, int *i, Uint8 **j),(a,b,c,d,e,f,g,h,i,j),return)
SDL_DYNAPI_PROC(SDL_DisplayID*,SDL_GetDisplays,(int *a),(a),return)
SDL_DYNAPI_PROC(SDL_DisplayID,SDL_GetPrimaryDisplay,(void),(),return)
SDL_DYNAPI_PROC(const SDL_DisplayMode**,SDL_GetFullscreenDisplayModes,(SDL_DisplayID a, int *b),(a,b),return)
SDL_DYNAPI_PROC(const SDL_DisplayMode*,SDL_GetClosestFullscreenDisplayMode,(SDL_DisplayID a, int b, int c, float d),(a,b,c,d),return)

View File

@@ -141,10 +141,10 @@ int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent,
window->flags &= ~SDL_WINDOW_INPUT_FOCUS;
break;
case SDL_EVENT_WINDOW_DISPLAY_CHANGED:
if (data1 == 0 || (SDL_DisplayID)data1 == window->displayID) {
if (data1 == 0 || (SDL_DisplayID)data1 == window->last_displayID) {
return 0;
}
window->displayID = (SDL_DisplayID)data1;
window->last_displayID = (SDL_DisplayID)data1;
break;
default:
break;

View File

@@ -916,15 +916,16 @@ static SDL_RenderLineMethod SDL_GetRenderLineMethod()
static void SDL_CalculateSimulatedVSyncInterval(SDL_Renderer *renderer, SDL_Window *window)
{
SDL_DisplayID displayID = SDL_GetDisplayForWindow(window);
SDL_DisplayMode mode;
const SDL_DisplayMode *mode;
float refresh_rate;
int num, den;
if (displayID == 0) {
displayID = SDL_GetPrimaryDisplay();
}
if (SDL_GetDesktopDisplayMode(displayID, &mode) == 0 && mode.refresh_rate > 0.0f) {
refresh_rate = mode.refresh_rate;
mode = SDL_GetDesktopDisplayMode(displayID);
if (mode && mode->refresh_rate > 0.0f) {
refresh_rate = mode->refresh_rate;
} else {
/* Pick a good default refresh rate */
refresh_rate = 60.0f;

View File

@@ -289,17 +289,18 @@ static int D3D_ActivateRenderer(SDL_Renderer *renderer)
if (data->updateSize) {
SDL_Window *window = renderer->window;
int w, h;
Uint32 window_flags = SDL_GetWindowFlags(window);
const SDL_DisplayMode *fullscreen_mode = NULL;
SDL_GetWindowSizeInPixels(window, &w, &h);
data->pparams.BackBufferWidth = w;
data->pparams.BackBufferHeight = h;
if ((window_flags & SDL_WINDOW_FULLSCREEN_EXCLUSIVE) != 0) {
SDL_DisplayMode fullscreen_mode;
SDL_GetWindowDisplayMode(window, &fullscreen_mode);
if ((SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN_EXCLUSIVE) != 0) {
fullscreen_mode = SDL_GetWindowFullscreenMode(window);
}
if (fullscreen_mode) {
data->pparams.Windowed = FALSE;
data->pparams.BackBufferFormat = PixelFormatToD3DFMT(fullscreen_mode.format);
data->pparams.FullScreen_RefreshRateInHz = (UINT)SDL_ceilf(fullscreen_mode.refresh_rate);
data->pparams.BackBufferFormat = PixelFormatToD3DFMT(fullscreen_mode->format);
data->pparams.FullScreen_RefreshRateInHz = (UINT)SDL_ceilf(fullscreen_mode->refresh_rate);
} else {
data->pparams.Windowed = TRUE;
data->pparams.BackBufferFormat = D3DFMT_UNKNOWN;
@@ -1554,10 +1555,9 @@ D3D_CreateRenderer(SDL_Window *window, Uint32 flags)
IDirect3DSwapChain9 *chain;
D3DCAPS9 caps;
DWORD device_flags;
Uint32 window_flags;
int w, h;
SDL_DisplayMode fullscreen_mode;
SDL_DisplayID displayID;
const SDL_DisplayMode *fullscreen_mode = NULL;
if (SDL_GetWindowWMInfo(window, &windowinfo, SDL_SYSWM_CURRENT_VERSION) < 0 ||
windowinfo.subsystem != SDL_SYSWM_WINDOWS) {
@@ -1612,9 +1612,10 @@ D3D_CreateRenderer(SDL_Window *window, Uint32 flags)
renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
renderer->driverdata = data;
window_flags = SDL_GetWindowFlags(window);
SDL_GetWindowSizeInPixels(window, &w, &h);
SDL_GetWindowDisplayMode(window, &fullscreen_mode);
if ((SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN_EXCLUSIVE) != 0) {
fullscreen_mode = SDL_GetWindowFullscreenMode(window);
}
SDL_zero(pparams);
pparams.hDeviceWindow = windowinfo.info.win.window;
@@ -1623,10 +1624,10 @@ D3D_CreateRenderer(SDL_Window *window, Uint32 flags)
pparams.BackBufferCount = 1;
pparams.SwapEffect = D3DSWAPEFFECT_DISCARD;
if ((window_flags & SDL_WINDOW_FULLSCREEN_EXCLUSIVE) != 0) {
if (fullscreen_mode) {
pparams.Windowed = FALSE;
pparams.BackBufferFormat = PixelFormatToD3DFMT(fullscreen_mode.format);
pparams.FullScreen_RefreshRateInHz = (UINT)SDL_ceilf(fullscreen_mode.refresh_rate);
pparams.BackBufferFormat = PixelFormatToD3DFMT(fullscreen_mode->format);
pparams.FullScreen_RefreshRateInHz = (UINT)SDL_ceilf(fullscreen_mode->refresh_rate);
} else {
pparams.Windowed = TRUE;
pparams.BackBufferFormat = D3DFMT_UNKNOWN;

View File

@@ -218,15 +218,7 @@ int SDLTest_CommonArg(SDLTest_CommonState *state, int index)
if (!argv[index]) {
return -1;
}
state->display = SDL_atoi(argv[index]);
if (SDL_WINDOWPOS_ISUNDEFINED(state->window_x)) {
state->window_x = SDL_WINDOWPOS_UNDEFINED_DISPLAY(state->display);
state->window_y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(state->display);
}
if (SDL_WINDOWPOS_ISCENTERED(state->window_x)) {
state->window_x = SDL_WINDOWPOS_CENTERED_DISPLAY(state->display);
state->window_y = SDL_WINDOWPOS_CENTERED_DISPLAY(state->display);
}
state->display_index = SDL_atoi(argv[index]);
return 2;
}
if (SDL_strcasecmp(argv[index], "--metal-window") == 0) {
@@ -1036,7 +1028,7 @@ SDL_bool
SDLTest_CommonInit(SDLTest_CommonState *state)
{
int i, j, m, n, w, h;
SDL_DisplayMode fullscreen_mode;
const SDL_DisplayMode *fullscreen_mode;
char text[1024];
if (state->flags & SDL_INIT_VIDEO) {
@@ -1103,7 +1095,8 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
SDL_Rect bounds, usablebounds;
float hdpi = 0;
float vdpi = 0;
SDL_DisplayMode mode;
const SDL_DisplayMode **modes;
const SDL_DisplayMode *mode;
int bpp;
Uint32 Rmask, Gmask, Bmask, Amask;
#if SDL_VIDEO_DRIVER_WINDOWS
@@ -1128,12 +1121,12 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
SDL_Log("Usable bounds: %dx%d at %d,%d\n", usablebounds.w, usablebounds.h, usablebounds.x, usablebounds.y);
SDL_Log("DPI: %gx%g\n", hdpi, vdpi);
SDL_GetDesktopDisplayMode(displayID, &mode);
SDL_GetMasksForPixelFormatEnum(mode.format, &bpp, &Rmask, &Gmask,
mode = SDL_GetDesktopDisplayMode(displayID);
SDL_GetMasksForPixelFormatEnum(mode->format, &bpp, &Rmask, &Gmask,
&Bmask, &Amask);
SDL_Log(" Current mode: %dx%d@%gHz, %d%% scale, %d bits-per-pixel (%s)\n",
mode.pixel_w, mode.pixel_h, mode.refresh_rate, (int)(mode.display_scale * 100.0f), bpp,
SDL_GetPixelFormatName(mode.format));
SDL_Log(" Desktop mode: %dx%d@%gHz, %d%% scale, %d bits-per-pixel (%s)\n",
mode->pixel_w, mode->pixel_h, mode->refresh_rate, (int)(mode->display_scale * 100.0f), bpp,
SDL_GetPixelFormatName(mode->format));
if (Rmask || Gmask || Bmask) {
SDL_Log(" Red Mask = 0x%.8" SDL_PRIx32 "\n", Rmask);
SDL_Log(" Green Mask = 0x%.8" SDL_PRIx32 "\n", Gmask);
@@ -1144,18 +1137,18 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
}
/* Print available fullscreen video modes */
m = SDL_GetNumDisplayModes(displayID);
modes = SDL_GetFullscreenDisplayModes(displayID, &m);
if (m == 0) {
SDL_Log("No available fullscreen video modes\n");
} else {
SDL_Log(" Fullscreen video modes:\n");
for (j = 0; j < m; ++j) {
SDL_GetDisplayMode(displayID, j, &mode);
SDL_GetMasksForPixelFormatEnum(mode.format, &bpp, &Rmask,
mode = modes[j];
SDL_GetMasksForPixelFormatEnum(mode->format, &bpp, &Rmask,
&Gmask, &Bmask, &Amask);
SDL_Log(" Mode %d: %dx%d@%gHz, %d%% scale, %d bits-per-pixel (%s)\n",
j, mode.pixel_w, mode.pixel_h, mode.refresh_rate, (int)(mode.display_scale * 100.0f), bpp,
SDL_GetPixelFormatName(mode.format));
j, mode->pixel_w, mode->pixel_h, mode->refresh_rate, (int)(mode->display_scale * 100.0f), bpp,
SDL_GetPixelFormatName(mode->format));
if (Rmask || Gmask || Bmask) {
SDL_Log(" Red Mask = 0x%.8" SDL_PRIx32 "\n",
Rmask);
@@ -1169,6 +1162,7 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
}
}
}
SDL_free(modes);
#if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
/* Print the D3D9 adapter index */
@@ -1195,25 +1189,28 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
}
}
SDL_zero(fullscreen_mode);
switch (state->depth) {
case 8:
fullscreen_mode.format = SDL_PIXELFORMAT_INDEX8;
break;
case 15:
fullscreen_mode.format = SDL_PIXELFORMAT_RGB555;
break;
case 16:
fullscreen_mode.format = SDL_PIXELFORMAT_RGB565;
break;
case 24:
fullscreen_mode.format = SDL_PIXELFORMAT_RGB24;
break;
default:
fullscreen_mode.format = SDL_PIXELFORMAT_RGB888;
break;
state->displayID = SDL_GetPrimaryDisplay();
if (state->display_index > 0) {
SDL_DisplayID *displays = SDL_GetDisplays(&n);
if (state->display_index < n) {
state->displayID = displays[state->display_index];
}
SDL_free(displays);
if (SDL_WINDOWPOS_ISUNDEFINED(state->window_x)) {
state->window_x = SDL_WINDOWPOS_UNDEFINED_DISPLAY(state->displayID);
state->window_y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(state->displayID);
}
if (SDL_WINDOWPOS_ISCENTERED(state->window_x)) {
state->window_x = SDL_WINDOWPOS_CENTERED_DISPLAY(state->displayID);
state->window_y = SDL_WINDOWPOS_CENTERED_DISPLAY(state->displayID);
}
}
fullscreen_mode = SDL_GetClosestFullscreenDisplayMode(state->displayID, state->window_w, state->window_h, state->refresh_rate);
if (fullscreen_mode) {
SDL_memcpy(&state->fullscreen_mode, fullscreen_mode, sizeof(state->fullscreen_mode));
}
fullscreen_mode.refresh_rate = state->refresh_rate;
state->windows =
(SDL_Window **)SDL_calloc(state->num_windows,
@@ -1239,14 +1236,7 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
/* !!! FIXME: hack to make --usable-bounds work for now. */
if ((r.x == -1) && (r.y == -1) && (r.w == -1) && (r.h == -1)) {
int num_displays;
SDL_DisplayID *displays = SDL_GetDisplays(&num_displays);
if (displays && state->display < num_displays) {
SDL_GetDisplayUsableBounds(displays[state->display], &r);
} else {
SDL_GetDisplayUsableBounds(SDL_GetPrimaryDisplay(), &r);
}
SDL_free(displays);
SDL_GetDisplayUsableBounds(state->displayID, &r);
}
if (state->num_windows > 1) {
@@ -1275,10 +1265,13 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
state->window_w = w;
state->window_h = h;
}
if (SDL_SetWindowDisplayMode(state->windows[i], &fullscreen_mode) < 0) {
SDL_Log("Can't set up fullscreen display mode: %s\n",
SDL_GetError());
return SDL_FALSE;
if ((state->window_flags & SDL_WINDOW_FULLSCREEN_MASK) != 0) {
if ((state->window_flags & SDL_WINDOW_FULLSCREEN_EXCLUSIVE) != 0) {
SDL_SetWindowFullscreenMode(state->windows[i], &state->fullscreen_mode);
} else {
SDL_SetWindowFullscreenMode(state->windows[i], NULL);
}
SDL_SetWindowFullscreen(state->windows[i], SDL_TRUE);
}
/* Add resize/drag areas for windows that are borderless and resizable */
@@ -1728,12 +1721,13 @@ static void SDLTest_ScreenShot(SDL_Renderer *renderer)
}
}
static void FullscreenTo(int index, int windowId)
static void FullscreenTo(SDLTest_CommonState *state, int index, int windowId)
{
int num_displays;
SDL_DisplayID *displays;
SDL_Window *window;
Uint32 flags;
const SDL_DisplayMode *mode;
struct SDL_Rect rect = { 0, 0, 0, 0 };
displays = SDL_GetDisplays(&num_displays);
@@ -1744,12 +1738,27 @@ static void FullscreenTo(int index, int windowId)
flags = SDL_GetWindowFlags(window);
if ((flags & SDL_WINDOW_FULLSCREEN_MASK) != 0) {
SDL_SetWindowFullscreen(window, 0);
SDL_SetWindowFullscreen(window, SDL_FALSE);
SDL_Delay(15);
}
SDL_SetWindowPosition(window, rect.x, rect.y);
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_EXCLUSIVE);
mode = SDL_GetWindowFullscreenMode(window);
if (mode) {
/* Try to set the existing mode on the new display */
SDL_DisplayMode new_mode;
SDL_memcpy(&new_mode, mode, sizeof(new_mode));
new_mode.displayID = displays[index];
if (SDL_SetWindowFullscreenMode(window, &new_mode) < 0) {
/* Try again with a default mode */
mode = SDL_GetClosestFullscreenDisplayMode(displays[index], state->window_w, state->window_h, state->refresh_rate);
SDL_SetWindowFullscreenMode(window, mode);
}
}
if (!mode) {
SDL_SetWindowPosition(window, rect.x, rect.y);
}
SDL_SetWindowFullscreen(window, SDL_TRUE);
}
}
SDL_free(displays);
@@ -2043,9 +2052,9 @@ void SDLTest_CommonEvent(SDLTest_CommonState *state, SDL_Event *event, int *done
if (window) {
Uint32 flags = SDL_GetWindowFlags(window);
if ((flags & SDL_WINDOW_FULLSCREEN_MASK) != 0) {
SDL_SetWindowFullscreen(window, 0);
SDL_SetWindowFullscreen(window, SDL_FALSE);
} else {
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_EXCLUSIVE);
SDL_SetWindowFullscreen(window, SDL_TRUE);
}
}
} else if (withAlt) {
@@ -2054,9 +2063,10 @@ void SDLTest_CommonEvent(SDLTest_CommonState *state, SDL_Event *event, int *done
if (window) {
Uint32 flags = SDL_GetWindowFlags(window);
if ((flags & SDL_WINDOW_FULLSCREEN_MASK) != 0) {
SDL_SetWindowFullscreen(window, 0);
SDL_SetWindowFullscreen(window, SDL_FALSE);
} else {
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
SDL_SetWindowFullscreenMode(window, NULL);
SDL_SetWindowFullscreen(window, SDL_TRUE);
}
}
} else if (withShift) {
@@ -2065,10 +2075,11 @@ void SDLTest_CommonEvent(SDLTest_CommonState *state, SDL_Event *event, int *done
if (window) {
Uint32 flags = SDL_GetWindowFlags(window);
if ((flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != 0) {
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_EXCLUSIVE);
SDL_SetWindowFullscreenMode(window, &state->fullscreen_mode);
} else {
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
SDL_SetWindowFullscreenMode(window, NULL);
}
SDL_SetWindowFullscreen(window, SDL_TRUE);
}
}
@@ -2105,12 +2116,12 @@ void SDLTest_CommonEvent(SDLTest_CommonState *state, SDL_Event *event, int *done
break;
case SDLK_1:
if (withControl) {
FullscreenTo(0, event->key.windowID);
FullscreenTo(state, 0, event->key.windowID);
}
break;
case SDLK_2:
if (withControl) {
FullscreenTo(1, event->key.windowID);
FullscreenTo(state, 1, event->key.windowID);
}
break;
case SDLK_ESCAPE:
@@ -2192,7 +2203,7 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, fl
int x, y, w, h;
float fx, fy;
SDL_Rect rect;
SDL_DisplayMode mode;
const SDL_DisplayMode *mode;
float ddpi, hdpi, vdpi;
float scaleX, scaleY;
Uint32 flags;
@@ -2271,9 +2282,10 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, fl
SDLTest_DrawString(renderer, 0.0f, textY, text);
textY += lineHeight;
if (0 == SDL_GetWindowDisplayMode(window, &mode)) {
(void)SDL_snprintf(text, sizeof text, "SDL_GetWindowDisplayMode: %dx%d@%gHz %d%% scale, (%s)",
mode.pixel_w, mode.pixel_h, mode.refresh_rate, (int)(mode.display_scale * 100.0f), SDL_GetPixelFormatName(mode.format));
mode = SDL_GetWindowFullscreenMode(window);
if (mode) {
(void)SDL_snprintf(text, sizeof text, "SDL_GetWindowFullscreenMode: %dx%d@%gHz %d%% scale, (%s)",
mode->pixel_w, mode->pixel_h, mode->refresh_rate, (int)(mode->display_scale * 100.0f), SDL_GetPixelFormatName(mode->format));
SDLTest_DrawString(renderer, 0.0f, textY, text);
textY += lineHeight;
}
@@ -2301,16 +2313,18 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, fl
textY += lineHeight;
}
if (0 == SDL_GetCurrentDisplayMode(windowDisplayID, &mode)) {
mode = SDL_GetCurrentDisplayMode(windowDisplayID);
if (mode) {
(void)SDL_snprintf(text, sizeof text, "SDL_GetCurrentDisplayMode: %dx%d@%gHz %d%% scale, (%s)",
mode.pixel_w, mode.pixel_h, mode.refresh_rate, (int)(mode.display_scale * 100.0f), SDL_GetPixelFormatName(mode.format));
mode->pixel_w, mode->pixel_h, mode->refresh_rate, (int)(mode->display_scale * 100.0f), SDL_GetPixelFormatName(mode->format));
SDLTest_DrawString(renderer, 0.0f, textY, text);
textY += lineHeight;
}
if (0 == SDL_GetDesktopDisplayMode(windowDisplayID, &mode)) {
mode = SDL_GetDesktopDisplayMode(windowDisplayID);
if (mode) {
(void)SDL_snprintf(text, sizeof text, "SDL_GetDesktopDisplayMode: %dx%d@%gHz %d%% scale, (%s)",
mode.pixel_w, mode.pixel_h, mode.refresh_rate, (int)(mode.display_scale * 100.0f), SDL_GetPixelFormatName(mode.format));
mode->pixel_w, mode->pixel_h, mode->refresh_rate, (int)(mode->display_scale * 100.0f), SDL_GetPixelFormatName(mode->format));
SDLTest_DrawString(renderer, 0.0f, textY, text);
textY += lineHeight;
}

View File

@@ -107,7 +107,7 @@ struct SDL_Window
int last_pixel_w, last_pixel_h;
Uint32 flags;
Uint32 last_fullscreen_flags;
SDL_DisplayID displayID;
SDL_DisplayID last_displayID;
/* Stored position and size for windowed mode */
SDL_Rect windowed;
@@ -150,11 +150,10 @@ struct SDL_VideoDisplay
{
SDL_DisplayID id;
char *name;
int max_display_modes;
int num_display_modes;
SDL_DisplayMode *display_modes;
int max_fullscreen_modes;
int num_fullscreen_modes;
SDL_DisplayMode *fullscreen_modes;
SDL_DisplayMode desktop_mode;
SDL_DisplayMode current_mode;
SDL_DisplayOrientation orientation;
SDL_Window *fullscreen_window;
@@ -505,11 +504,11 @@ extern SDL_VideoDevice *SDL_GetVideoDevice(void);
extern SDL_bool SDL_IsVideoContextExternal(void);
extern SDL_DisplayID SDL_AddBasicVideoDisplay(const SDL_DisplayMode *desktop_mode);
extern SDL_DisplayID SDL_AddVideoDisplay(const SDL_VideoDisplay *display, SDL_bool send_event);
extern void SDL_DelVideoDisplay(SDL_DisplayID display);
extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode);
extern void SDL_SetCurrentDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode);
extern void SDL_DelVideoDisplay(SDL_DisplayID display, SDL_bool send_event);
extern SDL_bool SDL_AddFullscreenDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode);
extern void SDL_ResetFullscreenDisplayModes(SDL_VideoDisplay *display);
extern void SDL_SetDesktopDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode);
extern void SDL_ResetDisplayModes(SDL_VideoDisplay *display);
extern void SDL_SetCurrentDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode);
extern SDL_VideoDisplay *SDL_GetVideoDisplay(SDL_DisplayID display);
extern SDL_VideoDisplay *SDL_GetVideoDisplayForWindow(SDL_Window *window);
extern int SDL_GetDisplayIndex(SDL_DisplayID displayID);

File diff suppressed because it is too large Load Diff

View File

@@ -193,8 +193,6 @@ int Android_VideoInit(_THIS)
display = SDL_GetVideoDisplay(displayID);
display->orientation = Android_JNI_GetDisplayOrientation();
SDL_AddDisplayMode(&_this->displays[0], &mode);
Android_InitTouch();
Android_InitMouse();
@@ -288,22 +286,8 @@ void Android_SendResize(SDL_Window *window)
}
if (window) {
/* Force the current mode to match the resize otherwise the SDL_EVENT_WINDOW_RESTORED event
* will fall back to the old mode */
int w, h;
SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window);
SDL_DisplayMode current_mode;
SDL_zero(current_mode);
current_mode.format = Android_ScreenFormat;
current_mode.pixel_w = Android_DeviceWidth;
current_mode.pixel_h = Android_DeviceHeight;
current_mode.display_scale = Android_ScreenDensity;
current_mode.refresh_rate = Android_ScreenRate;
SDL_SetCurrentDisplayMode(display, &current_mode);
w = (int)SDL_floorf(Android_SurfaceWidth / Android_ScreenDensity);
h = (int)SDL_floorf(Android_SurfaceHeight / Android_ScreenDensity);
int w = (int)SDL_floorf(Android_SurfaceWidth / Android_ScreenDensity);
int h = (int)SDL_floorf(Android_SurfaceHeight / Android_ScreenDensity);
SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, w, h);
}
}

View File

@@ -236,8 +236,8 @@ static SDL_bool GetDisplayMode(_THIS, CGDisplayModeRef vidmode, SDL_bool vidmode
* in case there are duplicate modes with different IO flags or IO
* display mode IDs in the future. In that case I think it's better
* to try them all in SetDisplayMode than to risk one of them being
* correct but it being filtered out by SDL_AddDisplayMode as being
* a duplicate.
* correct but it being filtered out by SDL_AddFullscreenDisplayMode
* as being a duplicate.
*/
if (width == otherW && height == otherH && pixelW == otherpixelW && pixelH == otherpixelH && usableForGUI == otherGUI && refreshrate == otherrefresh && format == otherformat) {
CFArrayAppendValue(modes, othermode);
@@ -352,7 +352,6 @@ void Cocoa_InitModes(_THIS)
CGDisplayModeRelease(moderef);
display.desktop_mode = mode;
display.current_mode = mode;
display.driverdata = displaydata;
SDL_AddVideoDisplay(&display, SDL_FALSE);
SDL_free(display.name);
@@ -478,8 +477,6 @@ void Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
{
SDL_DisplayData *data = display->driverdata;
CVDisplayLinkRef link = NULL;
CGDisplayModeRef desktopmoderef;
SDL_DisplayMode desktopmode;
CFArrayRef modes;
CFDictionaryRef dict = NULL;
const CFStringRef dictkeys[] = { kCGDisplayShowDuplicateLowResolutionModes };
@@ -487,23 +484,6 @@ void Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
CVDisplayLinkCreateWithCGDisplay(data->display, &link);
desktopmoderef = CGDisplayCopyDisplayMode(data->display);
/* CopyAllDisplayModes won't always contain the desktop display mode (if
* NULL is passed in) - for example on a retina 15" MBP, System Preferences
* allows choosing 1920x1200 but it's not in the list. AddDisplayMode makes
* sure there are no duplicates so it's safe to always add the desktop mode
* even in cases where it is in the CopyAllDisplayModes list.
*/
if (desktopmoderef && GetDisplayMode(_this, desktopmoderef, SDL_TRUE, NULL, link, &desktopmode)) {
if (!SDL_AddDisplayMode(display, &desktopmode)) {
CFRelease(((SDL_DisplayModeData *)desktopmode.driverdata)->modes);
SDL_free(desktopmode.driverdata);
}
}
CGDisplayModeRelease(desktopmoderef);
/* By default, CGDisplayCopyAllDisplayModes will only get a subset of the
* system's available modes. For example on a 15" 2016 MBP, users can
* choose 1920x1080@2x in System Preferences but it won't show up here,
@@ -538,7 +518,7 @@ void Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
SDL_DisplayMode mode;
if (GetDisplayMode(_this, moderef, SDL_FALSE, modes, link, &mode)) {
if (!SDL_AddDisplayMode(display, &mode)) {
if (!SDL_AddFullscreenDisplayMode(display, &mode)) {
CFRelease(((SDL_DisplayModeData *)mode.driverdata)->modes);
SDL_free(mode.driverdata);
}
@@ -642,15 +622,15 @@ void Cocoa_QuitModes(_THIS)
SDL_VideoDisplay *display = &_this->displays[i];
SDL_DisplayModeData *mode;
if (display->current_mode.driverdata != display->desktop_mode.driverdata) {
if (SDL_GetCurrentDisplayMode(display->id) != SDL_GetDesktopDisplayMode(display->id)) {
Cocoa_SetDisplayMode(_this, display, &display->desktop_mode);
}
mode = (SDL_DisplayModeData *)display->desktop_mode.driverdata;
CFRelease(mode->modes);
for (j = 0; j < display->num_display_modes; j++) {
mode = (SDL_DisplayModeData *)display->display_modes[j].driverdata;
for (j = 0; j < display->num_fullscreen_modes; j++) {
mode = (SDL_DisplayModeData *)display->fullscreen_modes[j].driverdata;
CFRelease(mode->modes);
}
}

View File

@@ -301,7 +301,7 @@ SDL_GLContext Cocoa_GL_CreateContext(_THIS, SDL_Window *window)
attr[i++] = profile;
attr[i++] = NSOpenGLPFAColorSize;
attr[i++] = SDL_BYTESPERPIXEL(display->current_mode.format) * 8;
attr[i++] = 32;
attr[i++] = NSOpenGLPFADepthSize;
attr[i++] = _this->gl_config.depth_size;

View File

@@ -150,8 +150,6 @@ int DUMMY_VideoInit(_THIS)
return -1;
}
SDL_AddDisplayMode(&_this->displays[0], &mode);
#if SDL_INPUT_LINUXEV
SDL_EVDEV_Init();
#endif

View File

@@ -136,8 +136,6 @@ int Emscripten_VideoInit(_THIS)
return -1;
}
SDL_AddDisplayMode(&_this->displays[0], &mode);
Emscripten_InitMouse();
/* We're done! */

View File

@@ -244,7 +244,7 @@ void HAIKU_GetDisplayModes(_THIS, SDL_VideoDisplay *display) {
// FIXME: Apparently there are errors with colorspace changes
if (bmodes[i].space == this_bmode.space) {
_BDisplayModeToSdlDisplayMode(&bmodes[i], &mode);
SDL_AddDisplayMode(display, &mode);
SDL_AddFullscreenDisplayMode(display, &mode);
}
}
free(bmodes); /* This should not be SDL_free() */

View File

@@ -490,27 +490,22 @@ KMSDRM_WaitPageflip(_THIS, SDL_WindowData *windata)
available on the DRM connector of the display.
We use the SDL mode list (which we filled in KMSDRM_GetDisplayModes)
because it's ordered, while the list on the connector is mostly random.*/
static drmModeModeInfo *KMSDRM_GetClosestDisplayMode(SDL_VideoDisplay *display,
uint32_t width, uint32_t height, uint32_t refresh_rate)
static drmModeModeInfo *KMSDRM_GetClosestDisplayMode(SDL_VideoDisplay *display, int width, int height)
{
SDL_DisplayData *dispdata = display->driverdata;
drmModeConnector *connector = dispdata->connector;
SDL_DisplayMode target, closest;
const SDL_DisplayMode *closest;
drmModeModeInfo *drm_mode;
SDL_zero(target);
target.screen_w = (int)width;
target.screen_h = (int)height;
target.refresh_rate = (int)refresh_rate;
if (!SDL_GetClosestDisplayMode(SDL_atoi(display->name), &target, &closest)) {
return NULL;
} else {
SDL_DisplayModeData *modedata = (SDL_DisplayModeData *)closest.driverdata;
closest = SDL_GetClosestFullscreenDisplayMode(display->id, width, height, 0.0f);
if (closest) {
const SDL_DisplayModeData *modedata = (const SDL_DisplayModeData *)closest->driverdata;
drm_mode = &connector->modes[modedata->mode_index];
return drm_mode;
} else {
return NULL;
}
}
@@ -876,7 +871,6 @@ static void KMSDRM_AddDisplay(_THIS, drmModeConnector *connector, drmModeRes *re
display.desktop_mode.refresh_rate = CalculateRefreshRate(&dispdata->mode);
display.desktop_mode.format = SDL_PIXELFORMAT_ARGB8888;
display.desktop_mode.driverdata = modedata;
display.current_mode = display.desktop_mode;
/* Add the display to the list of SDL displays. */
if (SDL_AddVideoDisplay(&display, SDL_FALSE) == 0) {
@@ -1124,11 +1118,7 @@ static void KMSDRM_GetModeToSet(SDL_Window *window, drmModeModeInfo *out_mode)
if ((window->flags & SDL_WINDOW_FULLSCREEN_EXCLUSIVE) != 0) {
*out_mode = dispdata->fullscreen_mode;
} else {
drmModeModeInfo *mode;
mode = KMSDRM_GetClosestDisplayMode(display,
window->windowed.w, window->windowed.h, 0);
drmModeModeInfo *mode = KMSDRM_GetClosestDisplayMode(display, window->windowed.w, window->windowed.h);
if (mode) {
*out_mode = *mode;
} else {
@@ -1161,7 +1151,6 @@ int KMSDRM_CreateSurfaces(_THIS, SDL_Window *window)
SDL_WindowData *windata = window->driverdata;
SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window);
SDL_DisplayData *dispdata = display->driverdata;
SDL_DisplayMode current_mode;
uint32_t surface_fmt = GBM_FORMAT_ARGB8888;
uint32_t surface_flags = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING;
@@ -1183,15 +1172,20 @@ int KMSDRM_CreateSurfaces(_THIS, SDL_Window *window)
/* The KMSDRM backend doesn't always set the mode the higher-level code in
SDL_video.c expects. Hulk-smash the display's current_mode to keep the
mode that's set in sync with what SDL_video.c thinks is set */
mode that's set in sync with what SDL_video.c thinks is set
FIXME: How do we do that now? Can we get a better idea at the higher level?
*/
KMSDRM_GetModeToSet(window, &dispdata->mode);
/*
SDL_zero(current_mode);
current_mode.pixel_w = dispdata->mode.hdisplay;
current_mode.pixel_h = dispdata->mode.vdisplay;
current_mode.refresh_rate = CalculateRefreshRate(&dispdata->mode);
current_mode.format = SDL_PIXELFORMAT_ARGB8888;
SDL_SetCurrentDisplayMode(display, &current_mode);
*/
windata->gs = KMSDRM_gbm_surface_create(viddata->gbm_dev,
dispdata->mode.hdisplay, dispdata->mode.vdisplay,
@@ -1308,7 +1302,7 @@ void KMSDRM_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
mode.format = SDL_PIXELFORMAT_ARGB8888;
mode.driverdata = modedata;
if (!SDL_AddDisplayMode(display, &mode)) {
if (!SDL_AddFullscreenDisplayMode(display, &mode)) {
SDL_free(modedata);
}
}
@@ -1508,8 +1502,7 @@ int KMSDRM_CreateWindow(_THIS, SDL_Window *window)
are considered "windowed" at this point of their life.
If a window is fullscreen, SDL internals will call
KMSDRM_SetWindowFullscreen() to reconfigure it if necessary. */
mode = KMSDRM_GetClosestDisplayMode(display,
window->windowed.w, window->windowed.h, 0);
mode = KMSDRM_GetClosestDisplayMode(display, window->windowed.w, window->windowed.h);
if (mode) {
dispdata->fullscreen_mode = *mode;

View File

@@ -35,7 +35,6 @@ SDL_FORCE_INLINE void AddN3DSDisplay(gfxScreen_t screen);
static int N3DS_VideoInit(_THIS);
static void N3DS_VideoQuit(_THIS);
static void N3DS_GetDisplayModes(_THIS, SDL_VideoDisplay *display);
static int N3DS_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect);
static int N3DS_CreateWindow(_THIS, SDL_Window *window);
static void N3DS_DestroyWindow(_THIS, SDL_Window *window);
@@ -65,7 +64,6 @@ static SDL_VideoDevice *N3DS_CreateDevice(void)
device->VideoInit = N3DS_VideoInit;
device->VideoQuit = N3DS_VideoQuit;
device->GetDisplayModes = N3DS_GetDisplayModes;
device->GetDisplayBounds = N3DS_GetDisplayBounds;
device->CreateSDLWindow = N3DS_CreateWindow;
@@ -124,7 +122,6 @@ static void AddN3DSDisplay(gfxScreen_t screen)
display.name = (screen == GFX_TOP) ? "N3DS top screen" : "N3DS bottom screen";
display.desktop_mode = mode;
display.current_mode = mode;
display.driverdata = display_driver_data;
SDL_AddVideoDisplay(&display, SDL_FALSE);
@@ -139,23 +136,19 @@ static void N3DS_VideoQuit(_THIS)
gfxExit();
}
static void N3DS_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
{
/* Each display only has a single mode */
SDL_AddDisplayMode(display, &display->current_mode);
}
static int N3DS_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
{
SDL_DisplayData *driver_data = display->driverdata;
const SDL_DisplayMode *mode = SDL_GetCurrentDisplayMode(display->id);
if (driver_data == NULL) {
return -1;
}
rect->x = 0;
rect->y = (driver_data->screen == GFX_TOP) ? 0 : GSP_SCREEN_WIDTH;
rect->w = display->current_mode.screen_w;
rect->h = display->current_mode.screen_h;
rect->w = mode->screen_w;
rect->h = mode->screen_h;
return 0;
}

View File

@@ -48,7 +48,6 @@ extern "C" {
/* Initialization/Query functions */
static int NGAGE_VideoInit(_THIS);
static int NGAGE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode);
static void NGAGE_VideoQuit(_THIS);
/* NGAGE driver bootstrap functions */
@@ -121,7 +120,6 @@ static SDL_VideoDevice *NGAGE_CreateDevice(void)
/* General video */
device->VideoInit = NGAGE_VideoInit;
device->VideoQuit = NGAGE_VideoQuit;
device->SetDisplayMode = NGAGE_SetDisplayMode;
device->PumpEvents = NGAGE_PumpEvents;
device->CreateWindowFramebuffer = SDL_NGAGE_CreateWindowFramebuffer;
device->UpdateWindowFramebuffer = SDL_NGAGE_UpdateWindowFramebuffer;
@@ -156,18 +154,10 @@ int NGAGE_VideoInit(_THIS)
return -1;
}
SDL_zero(mode);
SDL_AddDisplayMode(&_this->displays[0], &mode);
/* We're done! */
return 0;
}
static int NGAGE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
{
return 0;
}
void NGAGE_VideoQuit(_THIS)
{
}

View File

@@ -109,8 +109,6 @@ int OFFSCREEN_VideoInit(_THIS)
return -1;
}
SDL_AddDisplayMode(&_this->displays[0], &mode);
/* We're done! */
return 0;
}

View File

@@ -133,7 +133,6 @@ VideoBootStrap PSP_bootstrap = {
/*****************************************************************************/
int PSP_VideoInit(_THIS)
{
SDL_VideoDisplay display;
SDL_DisplayMode mode;
SDL_zero(mode);
@@ -144,17 +143,7 @@ int PSP_VideoInit(_THIS)
/* 32 bpp for default */
mode.format = SDL_PIXELFORMAT_ABGR8888;
SDL_zero(display);
display.desktop_mode = mode;
display.current_mode = mode;
SDL_AddDisplayMode(&display, &mode);
/* 16 bpp secondary mode */
mode.format = SDL_PIXELFORMAT_BGR565;
SDL_AddDisplayMode(&display, &mode);
if (SDL_AddVideoDisplay(&display, SDL_FALSE) == 0) {
if (SDL_AddBasicVideoDisplay(&mode) == 0) {
return -1;
}
return 0;
@@ -166,12 +155,27 @@ void PSP_VideoQuit(_THIS)
void PSP_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
{
SDL_DisplayMode mode;
SDL_zero(mode);
mode.pixel_w = 480;
mode.pixel_h = 272;
mode.refresh_rate = 60.0f;
/* 32 bpp for default */
mode.format = SDL_PIXELFORMAT_ABGR8888;
SDL_AddFullscreenDisplayMode(display, &mode);
/* 16 bpp secondary mode */
mode.format = SDL_PIXELFORMAT_BGR565;
SDL_AddFullscreenDisplayMode(display, &mode);
}
int PSP_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
{
return 0;
}
#define EGLCHK(stmt) \
do { \
EGLint err; \

View File

@@ -102,8 +102,6 @@ static SDL_VideoDevice *RPI_Create()
/* Setup all functions which we can handle */
device->VideoInit = RPI_VideoInit;
device->VideoQuit = RPI_VideoQuit;
device->GetDisplayModes = RPI_GetDisplayModes;
device->SetDisplayMode = RPI_SetDisplayMode;
device->CreateSDLWindow = RPI_CreateWindow;
device->CreateSDLWindowFrom = RPI_CreateWindowFrom;
device->SetWindowTitle = RPI_SetWindowTitle;
@@ -172,7 +170,6 @@ static void AddDispManXDisplay(const int display_id)
SDL_zero(display);
display.desktop_mode = mode;
display.current_mode = mode;
/* Allocate display internal data */
data = (SDL_DisplayData *)SDL_calloc(1, sizeof(SDL_DisplayData));
@@ -214,17 +211,6 @@ void RPI_VideoQuit(_THIS)
#endif
}
void RPI_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
{
/* Only one display mode available, the current one */
SDL_AddDisplayMode(display, &display->current_mode);
}
int RPI_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
{
return 0;
}
static void RPI_vsync_callback(DISPMANX_UPDATE_HANDLE_T u, void *data)
{
SDL_WindowData *wdata = (SDL_WindowData *)data;

View File

@@ -37,7 +37,7 @@ int RISCOS_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, vo
unsigned int sprite_mode;
_kernel_oserror *error;
_kernel_swi_regs regs;
SDL_DisplayMode mode;
const SDL_DisplayMode *mode;
int size;
int w, h;
@@ -47,10 +47,10 @@ int RISCOS_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, vo
RISCOS_DestroyWindowFramebuffer(_this, window);
/* Create a new one */
SDL_GetCurrentDisplayMode(SDL_GetDisplayForWindow(window), &mode);
if ((SDL_ISPIXELFORMAT_PACKED(mode.format) || SDL_ISPIXELFORMAT_ARRAY(mode.format))) {
*format = mode.format;
sprite_mode = (unsigned int)mode.driverdata;
mode = SDL_GetCurrentDisplayMode(SDL_GetDisplayForWindow(window));
if ((SDL_ISPIXELFORMAT_PACKED(mode->format) || SDL_ISPIXELFORMAT_ARRAY(mode->format))) {
*format = mode->format;
sprite_mode = (unsigned int)mode->driverdata;
} else {
*format = SDL_PIXELFORMAT_BGR888;
sprite_mode = (1 | (90 << 1) | (90 << 14) | (6 << 27));

View File

@@ -277,7 +277,7 @@ void RISCOS_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
break;
}
if (!SDL_AddDisplayMode(display, &mode)) {
if (!SDL_AddFullscreenDisplayMode(display, &mode)) {
SDL_free(mode.driverdata);
}
}

View File

@@ -275,7 +275,7 @@ static int UIKit_AddSingleDisplayMode(SDL_VideoDisplay *display, int w, int h,
mode.refresh_rate = UIKit_GetDisplayModeRefreshRate(uiscreen);
mode.format = SDL_PIXELFORMAT_ABGR8888;
if (SDL_AddDisplayMode(display, &mode)) {
if (SDL_AddFullscreenDisplayMode(display, &mode)) {
return 0;
} else {
UIKit_FreeDisplayModeData(&mode);
@@ -349,7 +349,6 @@ int UIKit_AddDisplay(UIScreen *uiscreen, SDL_bool send_event)
SDL_zero(display);
display.desktop_mode = mode;
display.current_mode = mode;
/* Allocate the display data */
SDL_DisplayData *data = [[SDL_DisplayData alloc] initWithScreen:uiscreen];
@@ -378,8 +377,8 @@ void UIKit_DelDisplay(UIScreen *uiscreen)
if (data && data.uiscreen == uiscreen) {
display->driverdata = nil;
SDL_DelVideoDisplay(displays[i]);
return;
SDL_DelVideoDisplay(displays[i], SDL_FALSE);
break;
}
}
SDL_free(displays);
@@ -532,8 +531,8 @@ void UIKit_QuitModes(_THIS)
SDL_VideoDisplay *display = &_this->displays[i];
UIKit_FreeDisplayModeData(&display->desktop_mode);
for (j = 0; j < display->num_display_modes; j++) {
SDL_DisplayMode *mode = &display->display_modes[j];
for (j = 0; j < display->num_fullscreen_modes; j++) {
SDL_DisplayMode *mode = &display->fullscreen_modes[j];
UIKit_FreeDisplayModeData(mode);
}
@@ -551,31 +550,34 @@ void SDL_OnApplicationDidChangeStatusBarOrientation()
SDL_VideoDisplay *display = SDL_GetVideoDisplay(SDL_GetPrimaryDisplay());
if (display) {
SDL_DisplayMode *desktopmode = &display->desktop_mode;
SDL_DisplayMode *currentmode = &display->current_mode;
SDL_DisplayMode *mode = &display->desktop_mode;
SDL_DisplayOrientation orientation = SDL_ORIENTATION_UNKNOWN;
int i;
/* The desktop display mode should be kept in sync with the screen
* orientation so that updating a window's fullscreen state to
* SDL_WINDOW_FULLSCREEN_DESKTOP keeps the window dimensions in the
* correct orientation. */
if (isLandscape != (desktopmode->pixel_w > desktopmode->pixel_h)) {
int height = desktopmode->pixel_w;
desktopmode->pixel_w = desktopmode->pixel_h;
desktopmode->pixel_h = height;
height = desktopmode->screen_w;
desktopmode->screen_w = desktopmode->screen_h;
desktopmode->screen_h = height;
if (isLandscape != (mode->pixel_w > mode->pixel_h)) {
int height = mode->pixel_w;
mode->pixel_w = mode->pixel_h;
mode->pixel_h = height;
height = mode->screen_w;
mode->screen_w = mode->screen_h;
mode->screen_h = height;
}
/* Same deal with the current mode + SDL_GetCurrentDisplayMode. */
if (isLandscape != (currentmode->pixel_w > currentmode->pixel_h)) {
int height = currentmode->pixel_w;
currentmode->pixel_w = currentmode->pixel_h;
currentmode->pixel_h = height;
height = currentmode->screen_w;
currentmode->screen_w = currentmode->screen_h;
currentmode->screen_h = height;
/* Same deal with the fullscreen modes */
for (i = 0; i < display->num_fullscreen_modes; ++i) {
mode = &display->fullscreen_modes[i];
if (isLandscape != (mode->pixel_w > mode->pixel_h)) {
int height = mode->pixel_w;
mode->pixel_w = mode->pixel_h;
mode->pixel_h = height;
height = mode->screen_w;
mode->screen_w = mode->screen_h;
mode->screen_h = height;
}
}
switch ([UIApplication sharedApplication].statusBarOrientation) {

View File

@@ -169,19 +169,7 @@ int UIKit_CreateWindow(_THIS, SDL_Window *window)
#if !TARGET_OS_TV
const CGSize origsize = data.uiscreen.currentMode.size;
if ((origsize.width == 0.0f) && (origsize.height == 0.0f)) {
if (display->num_display_modes == 0) {
_this->GetDisplayModes(_this, display);
}
int i;
const SDL_DisplayMode *bestmode = NULL;
for (i = display->num_display_modes; i >= 0; i--) {
const SDL_DisplayMode *mode = &display->display_modes[i];
if ((mode->screen_w >= window->w) && (mode->screen_h >= window->h)) {
bestmode = mode;
}
}
const SDL_DisplayMode *bestmode = SDL_GetClosestFullscreenDisplayMode(display->id, window->w, window->h, 0.0f);
if (bestmode) {
SDL_DisplayModeData *modedata = (__bridge SDL_DisplayModeData *)bestmode->driverdata;
[data.uiscreen setCurrentMode:modedata.uiscreenmode];
@@ -189,7 +177,7 @@ int UIKit_CreateWindow(_THIS, SDL_Window *window)
/* desktop_mode doesn't change here (the higher level will
* use it to set all the screens back to their defaults
* upon window destruction, SDL_Quit(), etc. */
display->current_mode = *bestmode;
SDL_SetCurrentDisplayMode(display, bestmode);
}
}

View File

@@ -106,8 +106,6 @@ static SDL_VideoDevice *VITA_Create()
/* Setup all functions which we can handle */
device->VideoInit = VITA_VideoInit;
device->VideoQuit = VITA_VideoQuit;
device->GetDisplayModes = VITA_GetDisplayModes;
device->SetDisplayMode = VITA_SetDisplayMode;
device->CreateSDLWindow = VITA_CreateWindow;
device->CreateSDLWindowFrom = VITA_CreateWindowFrom;
device->SetWindowTitle = VITA_SetWindowTitle;
@@ -208,7 +206,9 @@ int VITA_VideoInit(_THIS)
/* 32 bpp for default */
mode.format = SDL_PIXELFORMAT_ABGR8888;
SDL_AddBasicVideoDisplay(&mode);
if (SDL_AddBasicVideoDisplay(&mode) == 0) {
return -1;
}
VITA_InitTouch();
VITA_InitKeyboard();
@@ -222,16 +222,6 @@ void VITA_VideoQuit(_THIS)
VITA_QuitTouch();
}
void VITA_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
{
SDL_AddDisplayMode(display, &display->current_mode);
}
int VITA_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
{
return 0;
}
int VITA_CreateWindow(_THIS, SDL_Window *window)
{
SDL_WindowData *wdata;

View File

@@ -74,8 +74,6 @@ static SDL_VideoDevice *VIVANTE_Create()
/* Setup all functions which we can handle */
device->VideoInit = VIVANTE_VideoInit;
device->VideoQuit = VIVANTE_VideoQuit;
device->GetDisplayModes = VIVANTE_GetDisplayModes;
device->SetDisplayMode = VIVANTE_SetDisplayMode;
device->CreateSDLWindow = VIVANTE_CreateWindow;
device->SetWindowTitle = VIVANTE_SetWindowTitle;
device->SetWindowPosition = VIVANTE_SetWindowPosition;
@@ -159,7 +157,6 @@ static int VIVANTE_AddVideoDisplays(_THIS)
SDL_zero(display);
display.name = VIVANTE_GetDisplayName(_this);
display.desktop_mode = mode;
display.current_mode = mode;
display.driverdata = data;
if (SDL_AddVideoDisplay(&display, SDL_FALSE) == 0) {
return -1;
@@ -242,17 +239,6 @@ void VIVANTE_VideoQuit(_THIS)
#endif
}
void VIVANTE_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
{
/* Only one display mode available, the current one */
SDL_AddDisplayMode(display, &display->current_mode);
}
int VIVANTE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
{
return 0;
}
int VIVANTE_CreateWindow(_THIS, SDL_Window *window)
{
SDL_VideoData *videodata = _this->driverdata;

View File

@@ -123,9 +123,8 @@ int Wayland_GLES_SwapWindow(_THIS, SDL_Window *window)
if (swap_interval != 0) {
SDL_VideoData *videodata = _this->driverdata;
struct wl_display *display = videodata->display;
SDL_VideoDisplay *sdldisplay = SDL_GetVideoDisplayForWindow(window);
/* ~10 frames (or 1 sec), so we'll progress even if throttled to zero. */
const Uint64 max_wait = SDL_GetTicksNS() + (sdldisplay->current_mode.refresh_rate ? ((SDL_NS_PER_SECOND * 10 * 100) / (int)(sdldisplay->current_mode.refresh_rate * 100)) : SDL_NS_PER_SECOND);
/* 1 sec, so we'll progress even if throttled to zero. */
const Uint64 max_wait = SDL_NS_PER_SECOND;
while (SDL_AtomicGet(&data->swap_interval_ready) == 0) {
Uint64 now;

View File

@@ -413,15 +413,15 @@ static void AddEmulatedModes(SDL_VideoDisplay *dpy, SDL_bool rot_90)
int i;
SDL_DisplayMode mode;
const int native_width = dpy->display_modes->pixel_w;
const int native_height = dpy->display_modes->pixel_h;
const int native_width = dpy->desktop_mode.pixel_w;
const int native_height = dpy->desktop_mode.pixel_h;
for (i = 0; i < SDL_arraysize(mode_list); ++i) {
SDL_zero(mode);
mode.format = dpy->display_modes->format;
mode.format = dpy->desktop_mode.format;
mode.display_scale = 1.0f;
mode.refresh_rate = dpy->display_modes->refresh_rate;
mode.driverdata = dpy->display_modes->driverdata;
mode.refresh_rate = dpy->desktop_mode.refresh_rate;
mode.driverdata = dpy->desktop_mode.driverdata;
if (rot_90) {
mode.pixel_w = mode_list[i].h;
@@ -435,7 +435,7 @@ static void AddEmulatedModes(SDL_VideoDisplay *dpy, SDL_bool rot_90)
if ((mode.pixel_w < native_width && mode.pixel_h < native_height) ||
(mode.pixel_w < native_width && mode.pixel_h == native_height) ||
(mode.pixel_w == native_width && mode.pixel_h < native_height)) {
SDL_AddDisplayMode(dpy, &mode);
SDL_AddFullscreenDisplayMode(dpy, &mode);
}
}
}
@@ -458,12 +458,12 @@ static void display_handle_geometry(void *data,
if (driverdata->wl_output_done_count) {
/* Clear the wl_output ref so Reset doesn't free it */
display = SDL_GetVideoDisplay(driverdata->display);
for (i = 0; i < display->num_display_modes; ++i) {
display->display_modes[i].driverdata = NULL;
for (i = 0; i < display->num_fullscreen_modes; ++i) {
display->fullscreen_modes[i].driverdata = NULL;
}
/* Okay, now it's safe to reset */
SDL_ResetDisplayModes(display);
SDL_ResetFullscreenDisplayModes(display);
/* The display has officially started over. */
driverdata->wl_output_done_count = 0;
@@ -609,15 +609,13 @@ static void display_handle_done(void *data,
}
/* Set the desktop display mode. */
SDL_AddDisplayMode(dpy, &desktop_mode);
SDL_SetCurrentDisplayMode(dpy, &desktop_mode);
SDL_SetDesktopDisplayMode(dpy, &desktop_mode);
SDL_memcpy(&dpy->desktop_mode, &desktop_mode, sizeof(&dpy->desktop_mode));
/* If the desktop is scaled... */
if (driverdata->scale_factor > 1.0f) {
/* ...expose the native resolution if viewports are available... */
if (video->viewporter != NULL) {
SDL_AddDisplayMode(dpy, &native_mode);
SDL_AddFullscreenDisplayMode(dpy, &native_mode);
} else {
/* ...if not, expose some smaller, integer scaled resolutions. */
int i;
@@ -628,7 +626,7 @@ static void display_handle_done(void *data,
desktop_mode.pixel_h = base_pixel_h * i;
desktop_mode.display_scale = (float)i;
SDL_AddDisplayMode(dpy, &desktop_mode);
SDL_AddFullscreenDisplayMode(dpy, &desktop_mode);
}
}
}
@@ -749,7 +747,7 @@ static void Wayland_free_display(SDL_VideoData *d, uint32_t id)
}
}
}
SDL_DelVideoDisplay(displays[i]);
SDL_DelVideoDisplay(displays[i], SDL_FALSE);
if (data->xdg_output) {
zxdg_output_v1_destroy(data->xdg_output);
}
@@ -974,10 +972,11 @@ int Wayland_VideoInit(_THIS)
static int Wayland_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
{
SDL_DisplayData *driverdata = display->driverdata;
const SDL_DisplayMode *mode = SDL_GetCurrentDisplayMode(display->id);
rect->x = driverdata->x;
rect->y = driverdata->y;
rect->w = display->current_mode.screen_w;
rect->h = display->current_mode.screen_h;
rect->w = mode->screen_w;
rect->h = mode->screen_h;
return 0;
}
@@ -1017,11 +1016,11 @@ static void Wayland_VideoCleanup(_THIS)
SDL_free(display->driverdata);
display->driverdata = NULL;
for (j = display->num_display_modes; j--;) {
display->display_modes[j].driverdata = NULL;
for (j = display->num_fullscreen_modes; j--;) {
display->fullscreen_modes[j].driverdata = NULL;
}
display->desktop_mode.driverdata = NULL;
SDL_DelVideoDisplay(display->id);
SDL_DelVideoDisplay(display->id, SDL_FALSE);
}
data->output_list = NULL;

View File

@@ -83,17 +83,14 @@ static void GetFullScreenDimensions(SDL_Window *window, int *width, int *height,
}
} else {
/* If a mode was set, use it, otherwise use the native resolution. */
if (window->fullscreen_mode.pixel_w != 0 && window->fullscreen_mode.pixel_h != 0) {
fs_width = window->fullscreen_mode.screen_w;
fs_height = window->fullscreen_mode.screen_h;
buf_width = window->fullscreen_mode.pixel_w;
buf_height = window->fullscreen_mode.pixel_h;
} else {
fs_width = disp->display_modes[0].screen_w;
fs_height = disp->display_modes[0].screen_h;
buf_width = disp->display_modes[0].pixel_w;
buf_height = disp->display_modes[0].pixel_h;
const SDL_DisplayMode *mode = SDL_GetWindowFullscreenMode(window);
if (!mode) {
mode = &disp->desktop_mode;
}
fs_width = mode->screen_w;
fs_height = mode->screen_h;
buf_width = mode->pixel_w;
buf_height = mode->pixel_h;
}
if (width) {

View File

@@ -1241,7 +1241,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
RECT rect;
int x, y;
int w, h;
SDL_DisplayID displayID = data->window->displayID;
SDL_DisplayID displayID = SDL_GetDisplayForWindow(data->window);
if (data->initializing || data->in_border_change) {
break;
@@ -1294,7 +1294,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
/* Forces a WM_PAINT event */
InvalidateRect(hwnd, NULL, FALSE);
if (data->window->displayID != displayID) {
if (data->window->last_displayID != displayID) {
/* Display changed, check ICC profile */
WIN_UpdateWindowICCProfile(data->window, SDL_TRUE);
}

View File

@@ -342,9 +342,7 @@ static void WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEXW *info,
SDL_VideoDisplay *existing_display = &_this->displays[i];
SDL_Rect bounds;
SDL_ResetDisplayModes(existing_display);
SDL_SetCurrentDisplayMode(existing_display, &mode);
SDL_SetDesktopDisplayMode(existing_display, &mode);
SDL_ResetFullscreenDisplayModes(existing_display);
if (WIN_GetDisplayBounds(_this, existing_display, &bounds) == 0) {
if (SDL_memcmp(&driverdata->bounds, &bounds, sizeof(bounds)) != 0 || moved) {
SDL_SendDisplayEvent(existing_display, SDL_EVENT_DISPLAY_MOVED, 0);
@@ -376,7 +374,6 @@ static void WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEXW *info,
}
display.desktop_mode = mode;
display.current_mode = mode;
display.orientation = orientation;
display.device = _this;
display.driverdata = displaydata;
@@ -737,7 +734,7 @@ void WIN_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
continue;
}
if (mode.format != SDL_PIXELFORMAT_UNKNOWN) {
if (!SDL_AddDisplayMode(display, &mode)) {
if (!SDL_AddFullscreenDisplayMode(display, &mode)) {
SDL_free(mode.driverdata);
}
} else {
@@ -858,7 +855,7 @@ void WIN_RefreshDisplays(_THIS)
SDL_VideoDisplay *display = &_this->displays[i];
SDL_DisplayData *driverdata = display->driverdata;
if (driverdata->IsValid == SDL_FALSE) {
SDL_DelVideoDisplay(display->id);
SDL_DelVideoDisplay(display->id, SDL_TRUE);
}
}
}

View File

@@ -307,17 +307,12 @@ static int WINRT_AddDisplaysForOutput(_THIS, IDXGIAdapter1 *dxgiAdapter1, int ou
mode.pixel_h = (dxgiOutputDesc.DesktopCoordinates.bottom - dxgiOutputDesc.DesktopCoordinates.top);
mode.format = DXGI_FORMAT_B8G8R8A8_UNORM;
display.desktop_mode = mode;
display.current_mode = mode;
if (!SDL_AddDisplayMode(&display, &mode)) {
goto done;
}
} else if (FAILED(hr)) {
WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIOutput::FindClosestMatchingMode failed", hr);
goto done;
} else {
display.name = WIN_StringToUTF8(dxgiOutputDesc.DeviceName);
WINRT_DXGIModeToSDLDisplayMode(&closestMatch, &display.desktop_mode);
display.current_mode = display.desktop_mode;
hr = dxgiOutput->GetDisplayModeList(DXGI_FORMAT_B8G8R8A8_UNORM, 0, &numModes, NULL);
if (FAILED(hr)) {
@@ -343,7 +338,7 @@ static int WINRT_AddDisplaysForOutput(_THIS, IDXGIAdapter1 *dxgiAdapter1, int ou
for (UINT i = 0; i < numModes; ++i) {
SDL_DisplayMode sdlMode;
WINRT_DXGIModeToSDLDisplayMode(&dxgiModes[i], &sdlMode);
SDL_AddDisplayMode(&display, &sdlMode);
SDL_AddFullscreenDisplayMode(&display, &sdlMode);
}
}
@@ -432,9 +427,7 @@ static int WINRT_AddDisplaysForAdapter(_THIS, IDXGIFactory2 *dxgiFactory2, int a
mode.format = DXGI_FORMAT_B8G8R8A8_UNORM;
display.desktop_mode = mode;
display.current_mode = mode;
bool error = SDL_AddDisplayMode(&display, &mode) < 0 ||
SDL_AddVideoDisplay(&display, SDL_FALSE) == 0;
bool error = (SDL_AddVideoDisplay(&display, SDL_FALSE) == 0);
if (display.name) {
SDL_free(display.name);
}

View File

@@ -470,8 +470,9 @@ static int X11_MessageBoxCreateWindow(SDL_MessageBoxDataX11 *data)
if ((dev) && (dev->displays) && (dev->num_displays > 0)) {
const SDL_VideoDisplay *dpy = &dev->displays[0];
const SDL_DisplayData *dpydata = dpy->driverdata;
x = dpydata->x + ((dpy->current_mode.pixel_w - data->dialog_width) / 2);
y = dpydata->y + ((dpy->current_mode.pixel_h - data->dialog_height) / 3);
const SDL_DisplayMode *mode = SDL_GetCurrentDisplayMode(dpy->id);
x = dpydata->x + ((mode->pixel_w - data->dialog_width) / 2);
y = dpydata->y + ((mode->pixel_h - data->dialog_height) / 3);
} else { /* oh well. This will misposition on a multi-head setup. Init first next time. */
x = (DisplayWidth(display, data->screen) - data->dialog_width) / 2;
y = (DisplayHeight(display, data->screen) - data->dialog_height) / 3;

View File

@@ -386,7 +386,6 @@ static int X11_AddXRandRDisplay(_THIS, Display *dpy, int screen, RROutput output
display.name = display_name;
}
display.desktop_mode = mode;
display.current_mode = mode;
display.driverdata = displaydata;
if (SDL_AddVideoDisplay(&display, send_event) == 0) {
return -1;
@@ -419,7 +418,7 @@ static void X11_HandleXRandROutputChange(_THIS, const XRROutputChangeNotifyEvent
if (ev->connection == RR_Disconnected) { /* output is going away */
if (display != NULL) {
SDL_DelVideoDisplay(display->id);
SDL_DelVideoDisplay(display->id, SDL_TRUE);
}
} else if (ev->connection == RR_Connected) { /* output is coming online */
if (display != NULL) {
@@ -629,7 +628,6 @@ static int X11_InitModes_StdXlib(_THIS)
SDL_zero(display);
display.name = (char *)"Generic X11 Display"; /* this is just copied and thrown away, it's safe to cast to char* here. */
display.desktop_mode = mode;
display.current_mode = mode;
display.driverdata = displaydata;
if (SDL_AddVideoDisplay(&display, SDL_TRUE) == 0) {
return -1;
@@ -670,7 +668,7 @@ void X11_GetDisplayModes(_THIS, SDL_VideoDisplay *sdl_display)
* (or support recreating the window with a new visual behind the scenes)
*/
SDL_zero(mode);
mode.format = sdl_display->current_mode.format;
mode.format = sdl_display->desktop_mode.format;
#if SDL_VIDEO_DRIVER_X11_XRANDR
if (data->use_xrandr) {
@@ -693,7 +691,7 @@ void X11_GetDisplayModes(_THIS, SDL_VideoDisplay *sdl_display)
mode.driverdata = modedata;
if (!SetXRandRModeInfo(display, res, output_info->crtc, output_info->modes[i], &mode) ||
!SDL_AddDisplayMode(sdl_display, &mode)) {
!SDL_AddFullscreenDisplayMode(sdl_display, &mode)) {
SDL_free(modedata);
}
}
@@ -704,20 +702,6 @@ void X11_GetDisplayModes(_THIS, SDL_VideoDisplay *sdl_display)
return;
}
#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
if (!data->use_xrandr) {
SDL_DisplayModeData *modedata;
/* Add the desktop mode */
mode = sdl_display->desktop_mode;
modedata = (SDL_DisplayModeData *)SDL_calloc(1, sizeof(SDL_DisplayModeData));
if (modedata) {
*modedata = *(SDL_DisplayModeData *)sdl_display->desktop_mode.driverdata;
}
mode.driverdata = modedata;
if (!SDL_AddDisplayMode(sdl_display, &mode)) {
SDL_free(modedata);
}
}
}
#if SDL_VIDEO_DRIVER_X11_XRANDR
@@ -832,12 +816,12 @@ void X11_QuitModes(_THIS)
int X11_GetDisplayBounds(_THIS, SDL_VideoDisplay *sdl_display, SDL_Rect *rect)
{
SDL_DisplayData *data = sdl_display->driverdata;
const SDL_DisplayMode *mode = SDL_GetCurrentDisplayMode(sdl_display->id);
rect->x = data->x;
rect->y = data->y;
rect->w = sdl_display->current_mode.screen_w;
rect->h = sdl_display->current_mode.screen_h;
rect->w = mode->screen_w;
rect->h = mode->screen_h;
return 0;
}

View File

@@ -125,8 +125,7 @@ static int X11_SafetyNetErrHandler(Display *d, XErrorEvent *e)
int i;
for (i = 0; i < device->num_displays; i++) {
SDL_VideoDisplay *display = &device->displays[i];
if (SDL_memcmp(&display->current_mode, &display->desktop_mode,
sizeof(SDL_DisplayMode)) != 0) {
if (SDL_GetCurrentDisplayMode(display->id) != SDL_GetDesktopDisplayMode(display->id)) {
X11_SetDisplayMode(device, display, &display->desktop_mode);
}
}