kmsdrm: fix scaling for SDL_WINDOW_FULLSCREEN windows.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c
index d441290..e845f03 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c
@@ -876,7 +876,7 @@ KMSDRM_CreateSurfaces(_THIS, SDL_Window * window)
/* Destroy the surfaces and buffers before creating the new ones. */
KMSDRM_DestroySurfaces(_this, window);
- if (window->flags & SDL_WINDOW_FULLSCREEN) {
+ if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
width = dispdata->mode.hdisplay;
height = dispdata->mode.vdisplay;
}
@@ -962,7 +962,7 @@ KMSDRM_ReconfigureWindow( _THIS, SDL_Window * window) {
SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
float ratio;
- if (window->flags & SDL_WINDOW_FULLSCREEN) {
+ if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
windata->src_w = dispdata->mode.hdisplay;
windata->src_h = dispdata->mode.vdisplay;
windata->output_w = dispdata->mode.hdisplay;
@@ -1329,12 +1329,37 @@ KMSDRM_VideoQuit(_THIS)
#endif
}
+#if 0
void
KMSDRM_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
{
/* Only one display mode available: the current one */
SDL_AddDisplayMode(display, &display->current_mode);
}
+#endif
+
+/* We are NOT really changing the physical display mode, but using
+the PRIMARY PLANE and CRTC to scale as we please. But we need that SDL
+has knowledge of the video modes we are going to use for fullscreen
+window sizes, even if we are faking their use. If not, SDL only considers
+the in-use video mode as available, and sets every window to that size
+before we get to CreateWindow or ReconfigureWindow. */
+void
+KMSDRM_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
+{
+ SDL_DisplayData *dispdata = display->driverdata;
+ drmModeConnector *conn = dispdata->connector->connector;
+ SDL_DisplayMode mode;
+
+ for (int i = 0; i < conn->count_modes; i++) {
+ mode.w = conn->modes[i].hdisplay;
+ mode.h = conn->modes[i].vdisplay;
+ mode.refresh_rate = conn->modes[i].vrefresh;
+ mode.format = SDL_PIXELFORMAT_ARGB8888;
+
+ SDL_AddDisplayMode(display, &mode);
+ }
+}
int
KMSDRM_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
@@ -1372,7 +1397,7 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
display = SDL_GetDisplayForWindow(window);
dispdata = display->driverdata;
- if (window->flags & SDL_WINDOW_FULLSCREEN) {
+ if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
windata->src_w = dispdata->mode.hdisplay;
windata->src_h = dispdata->mode.vdisplay;
windata->output_w = dispdata->mode.hdisplay;