From 94984dce17ab17d892931ea29d9d32bec5dccb01 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Sun, 28 Feb 2021 17:33:04 +0300
Subject: [PATCH] OS/2: Removed video driver name dance from toplevel
SDL_video.c,
adjusted OS/2 GrOp to have three bootstaps corresponding to the
proper output video system, so that the SDL_VIDEODRIVER env var
would always work.
---
src/video/SDL_sysvideo.h | 4 ++-
src/video/SDL_video.c | 16 ++---------
src/video/os2fslib/SDL_os2fslib.c | 2 +-
src/video/os2grop/SDL_os2grop.c | 46 +++++++++++++++++++------------
src/video/os2grop/SDL_os2grop.h | 2 ++
5 files changed, 38 insertions(+), 32 deletions(-)
diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h
index ecccd1f3..e1c8bc8d 100644
--- a/src/video/SDL_sysvideo.h
+++ b/src/video/SDL_sysvideo.h
@@ -402,7 +402,9 @@ extern VideoBootStrap NDS_bootstrap;
extern VideoBootStrap RISCOS_bootstrap;
#endif
#if SDL_VIDEO_DRIVER_OS2GROP
-extern VideoBootStrap OS2GROP_bootstrap;
+extern VideoBootStrap OS2DIVE_bootstrap;
+extern VideoBootStrap OS2VMAN_bootstrap;
+extern VideoBootStrap OS2VMANFS_bootstrap;
#endif
#if SDL_VIDEO_DRIVER_OS2FS
extern VideoBootStrap OS2FSLib_bootstrap;
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 52dc8d3f..2359b867 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -118,7 +118,9 @@ static VideoBootStrap *bootstrap[] = {
&RISCOS_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_OS2GROP
- &OS2GROP_bootstrap,
+ &OS2DIVE_bootstrap,
+ &OS2VMAN_bootstrap,
+ &OS2VMANFS_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_OS2FS
&OS2FSLib_bootstrap,
@@ -182,18 +184,6 @@ int SDL_VideoInit (const char *driver_name, Uint32 flags)
if ( SDL_strrchr(driver_name, ':') != NULL ) {
index = atoi(SDL_strrchr(driver_name, ':')+1);
}
-#endif
-#if SDL_VIDEO_DRIVER_OS2GROP
- if ( SDL_strcasecmp(driver_name,"DIVE") == 0 ||
- SDL_strcasecmp(driver_name,"VMAN") == 0 ||
- SDL_strcasecmp(driver_name,"VMANFS") == 0 ) {
- driver_name = "OS2";
- }
-#endif
-#if SDL_VIDEO_DRIVER_OS2FS
- if ( SDL_strcasecmp(driver_name,"FSLIB") == 0 ) {
- driver_name = "os2fslib";
- }
#endif
for ( i=0; bootstrap[i]; ++i ) {
if ( SDL_strcasecmp(bootstrap[i]->name, driver_name) == 0) {
diff --git a/src/video/os2fslib/SDL_os2fslib.c b/src/video/os2fslib/SDL_os2fslib.c
index fc8247f2..ebb62df6 100644
--- a/src/video/os2fslib/SDL_os2fslib.c
+++ b/src/video/os2fslib/SDL_os2fslib.c
@@ -2515,7 +2515,7 @@ static SDL_VideoDevice *os2fslib_CreateDevice(int devindex)
}
VideoBootStrap OS2FSLib_bootstrap = {
- "os2fslib", "OS/2 Video Output using FSLib",
+ "FSLIB", "OS/2 Video Output using FSLib",
os2fslib_Available, os2fslib_CreateDevice
};
#endif /* SDL_VIDEO_DRIVER_OS2FS */
diff --git a/src/video/os2grop/SDL_os2grop.c b/src/video/os2grop/SDL_os2grop.c
index 85cd51d0..480ed14f 100644
--- a/src/video/os2grop/SDL_os2grop.c
+++ b/src/video/os2grop/SDL_os2grop.c
@@ -388,21 +388,9 @@ static int os2_VideoInit(SDL_VideoDevice *pDevice,
ULONG cModes;
PBPPSIZELIST pBPPSizeList;
ULONG ulRC;
- char *driver;
-
- /* Select output video system. */
- ulIdx = GROP_VS_DIVE;
- driver = SDL_getenv("SDL_VIDEODRIVER");
-
- if (driver != NULL) {
- if (SDL_strcasecmp(driver, "VMAN") == 0)
- ulIdx = GROP_VS_VMAN_COMPATIBLE;
- else if (SDL_strcasecmp(driver, "VMANFS") == 0)
- ulIdx = GROP_VS_VMAN;
- }
/* Create a new GrOp object. */
- pGrop = gropNew(ulIdx, &stGropCallback, (PVOID)pPVData);
+ pGrop = gropNew(pPVData->ulVideoSys, &stGropCallback, (PVOID)pPVData);
if (pGrop == NULL) {
dbgprintf("gropNew() failed\n");
@@ -1092,7 +1080,7 @@ static void os2_DeleteDevice(SDL_VideoDevice *pDevice)
SDL_free(pDevice);
}
-static SDL_VideoDevice *os2_CreateDevice(int devindex)
+static SDL_VideoDevice *os2_CreateDevice(int devindex, ULONG ulVideoSys)
{
SDL_VideoDevice *pDevice;
SDL_PrivateVideoData *pPVData;
@@ -1139,6 +1127,7 @@ static SDL_VideoDevice *os2_CreateDevice(int devindex)
SDL_free(pDevice);
return NULL;
}
+ pPVData->ulVideoSys = ulVideoSys;
pDevice->hidden = pPVData;
if (!gropInit()) {
@@ -1151,14 +1140,37 @@ static SDL_VideoDevice *os2_CreateDevice(int devindex)
return pDevice;
}
+static SDL_VideoDevice *DIVE_CreateDevice(int devindex)
+{
+ return os2_CreateDevice(devindex, GROP_VS_DIVE);
+}
+
+static SDL_VideoDevice *VMAN_CreateDevice(int devindex)
+{
+ return os2_CreateDevice(devindex, GROP_VS_VMAN_COMPATIBLE);
+}
+
+static SDL_VideoDevice *VMANFS_CreateDevice(int devindex)
+{
+ return os2_CreateDevice(devindex, GROP_VS_VMAN);
+}
+
static int os2_Available(void)
{
return 1;
}
-VideoBootStrap OS2GROP_bootstrap = {
- "OS2", "OS/2 GrOp",
- os2_Available, os2_CreateDevice
+VideoBootStrap OS2DIVE_bootstrap = {
+ "DIVE", "OS/2 GrOp (DIVE)",
+ os2_Available, DIVE_CreateDevice
+};
+VideoBootStrap OS2VMAN_bootstrap = {
+ "VMAN", "OS/2 GrOp (VMAN)",
+ os2_Available, VMAN_CreateDevice
+};
+VideoBootStrap OS2VMANFS_bootstrap = {
+ "VMANFS", "OS/2 GrOp (VMANFS)",
+ os2_Available, VMANFS_CreateDevice
};
#endif /* SDL_VIDEO_DRIVER_OS2GROP */
diff --git a/src/video/os2grop/SDL_os2grop.h b/src/video/os2grop/SDL_os2grop.h
index 226ea55e..fb682e86 100644
--- a/src/video/os2grop/SDL_os2grop.h
+++ b/src/video/os2grop/SDL_os2grop.h
@@ -59,6 +59,8 @@ struct SDL_PrivateVideoData {
ULONG ulWinHeight;
BOOL fWinResized;
ULONG ulResizedReportTime;
+
+ ULONG ulVideoSys;
};