video: Only check major version in SDL_GetWindowWMInfo Since #5602, SDL is intended to have the same ABI across the whole major-version 2 cycle, so we should not check that the minor version matches the one that was used to compile an application. There are two checks that could make sense here. The first check is that the major version matches the expected major version. This is usually unnecessary and is not usually done (if we're calling into the wrong library we'll likely crash anyway), but since we have the information, we might as well continue to use it. The second check is whether the version provided by the caller is equal to or greater than a threshold version at which additional fields were added to the struct. If it is, we should populate those fields; if it is not, then we cannot. This is only useful on platforms where additional fields have genuinely been added during the lifetime of SDL 2, like Windows and DirectFB (but not X11). This commit changes the first check to be consistent about only looking at the minor version, while leaving the second check using SDL_VERSIONNUM (which will be removed or widened in SDL 3, but it's fine for now). Resolves: https://github.com/libsdl-org/SDL/issues/5711 Fixes: cd7c2f1 "Switch versioning scheme to be the same as GLib and Flatpak" Signed-off-by: Simon McVittie <smcv@collabora.com>
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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
diff --git a/src/video/android/SDL_androidwindow.c b/src/video/android/SDL_androidwindow.c
index f9ae3f1..0b62910 100644
--- a/src/video/android/SDL_androidwindow.c
+++ b/src/video/android/SDL_androidwindow.c
@@ -206,8 +206,7 @@ Android_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info)
{
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
- if (info->version.major == SDL_MAJOR_VERSION &&
- info->version.minor == SDL_MINOR_VERSION) {
+ if (info->version.major == SDL_MAJOR_VERSION) {
info->subsystem = SDL_SYSWM_ANDROID;
info->info.android.window = data->native_window;
@@ -217,8 +216,8 @@ Android_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info)
return SDL_TRUE;
} else {
- SDL_SetError("Application not compiled with SDL %d.%d",
- SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
+ SDL_SetError("Application not compiled with SDL %d",
+ SDL_MAJOR_VERSION);
return SDL_FALSE;
}
}
diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index 44e9144..30791b0 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -2323,8 +2323,8 @@ Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
info->info.cocoa.window = nswindow;
return SDL_TRUE;
} else {
- SDL_SetError("Application not compiled with SDL %d.%d",
- SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
+ SDL_SetError("Application not compiled with SDL %d",
+ SDL_MAJOR_VERSION);
return SDL_FALSE;
}
}}
diff --git a/src/video/directfb/SDL_DirectFB_window.c b/src/video/directfb/SDL_DirectFB_window.c
index 7dfda64..999f21d 100644
--- a/src/video/directfb/SDL_DirectFB_window.c
+++ b/src/video/directfb/SDL_DirectFB_window.c
@@ -482,16 +482,15 @@ DirectFB_GetWindowWMInfo(_THIS, SDL_Window * window,
return SDL_FALSE;
}
- if (info->version.major == SDL_MAJOR_VERSION &&
- info->version.minor == SDL_MINOR_VERSION) {
+ if (info->version.major == SDL_MAJOR_VERSION) {
info->subsystem = SDL_SYSWM_DIRECTFB;
info->info.dfb.dfb = devdata->dfb;
info->info.dfb.window = windata->dfbwin;
info->info.dfb.surface = windata->surface;
return SDL_TRUE;
} else {
- SDL_SetError("Application not compiled with SDL %d.%d",
- SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
+ SDL_SetError("Application not compiled with SDL %d",
+ SDL_MAJOR_VERSION);
return SDL_FALSE;
}
}
diff --git a/src/video/haiku/SDL_bwindow.cc b/src/video/haiku/SDL_bwindow.cc
index 587affa..2462533 100644
--- a/src/video/haiku/SDL_bwindow.cc
+++ b/src/video/haiku/SDL_bwindow.cc
@@ -226,13 +226,12 @@ void HAIKU_DestroyWindow(_THIS, SDL_Window * window) {
SDL_bool HAIKU_GetWindowWMInfo(_THIS, SDL_Window * window,
struct SDL_SysWMinfo *info) {
/* FIXME: What is the point of this? What information should be included? */
- if (info->version.major == SDL_MAJOR_VERSION &&
- info->version.minor == SDL_MINOR_VERSION) {
+ if (info->version.major == SDL_MAJOR_VERSION) {
info->subsystem = SDL_SYSWM_HAIKU;
return SDL_TRUE;
} else {
- SDL_SetError("Application not compiled with SDL %d.%d",
- SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
+ SDL_SetError("Application not compiled with SDL %d",
+ SDL_MAJOR_VERSION);
return SDL_FALSE;
}
}
diff --git a/src/video/os2/SDL_os2video.c b/src/video/os2/SDL_os2video.c
index 64731d7..65428da 100644
--- a/src/video/os2/SDL_os2video.c
+++ b/src/video/os2/SDL_os2video.c
@@ -1137,8 +1137,8 @@ static SDL_bool OS2_GetWindowWMInfo(_THIS, SDL_Window * window,
return SDL_TRUE;
}
- SDL_SetError("Application not compiled with SDL %u.%u",
- SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
+ SDL_SetError("Application not compiled with SDL %u",
+ SDL_MAJOR_VERSION);
return SDL_FALSE;
}
diff --git a/src/video/pandora/SDL_pandora.c b/src/video/pandora/SDL_pandora.c
index 16349f8..8340838 100644
--- a/src/video/pandora/SDL_pandora.c
+++ b/src/video/pandora/SDL_pandora.c
@@ -302,8 +302,8 @@ PND_getwindowwminfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
if (info->version.major <= SDL_MAJOR_VERSION) {
return SDL_TRUE;
} else {
- SDL_SetError("application not compiled with SDL %d.%d",
- SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
+ SDL_SetError("application not compiled with SDL %d",
+ SDL_MAJOR_VERSION);
return SDL_FALSE;
}
diff --git a/src/video/psp/SDL_pspvideo.c b/src/video/psp/SDL_pspvideo.c
index a5c86ec..de31a20 100644
--- a/src/video/psp/SDL_pspvideo.c
+++ b/src/video/psp/SDL_pspvideo.c
@@ -287,8 +287,8 @@ PSP_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
if (info->version.major <= SDL_MAJOR_VERSION) {
return SDL_TRUE;
} else {
- SDL_SetError("Application not compiled with SDL %d.%d",
- SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
+ SDL_SetError("Application not compiled with SDL %d",
+ SDL_MAJOR_VERSION);
return SDL_FALSE;
}
diff --git a/src/video/raspberry/SDL_rpivideo.c b/src/video/raspberry/SDL_rpivideo.c
index 1a0a4ce..4503f56 100644
--- a/src/video/raspberry/SDL_rpivideo.c
+++ b/src/video/raspberry/SDL_rpivideo.c
@@ -431,8 +431,8 @@ RPI_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
if (info->version.major <= SDL_MAJOR_VERSION) {
return SDL_TRUE;
} else {
- SDL_SetError("application not compiled with SDL %d.%d",
- SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
+ SDL_SetError("application not compiled with SDL %d",
+ SDL_MAJOR_VERSION);
return SDL_FALSE;
}
diff --git a/src/video/riscos/SDL_riscoswindow.c b/src/video/riscos/SDL_riscoswindow.c
index 84e4de0..0587880 100644
--- a/src/video/riscos/SDL_riscoswindow.c
+++ b/src/video/riscos/SDL_riscoswindow.c
@@ -62,13 +62,12 @@ RISCOS_DestroyWindow(_THIS, SDL_Window * window)
SDL_bool
RISCOS_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
{
- if (info->version.major == SDL_MAJOR_VERSION &&
- info->version.minor == SDL_MINOR_VERSION) {
+ if (info->version.major == SDL_MAJOR_VERSION) {
info->subsystem = SDL_SYSWM_RISCOS;
return SDL_TRUE;
} else {
- SDL_SetError("Application not compiled with SDL %d.%d",
- SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
+ SDL_SetError("Application not compiled with SDL %d",
+ SDL_MAJOR_VERSION);
return SDL_FALSE;
}
}
diff --git a/src/video/uikit/SDL_uikitwindow.m b/src/video/uikit/SDL_uikitwindow.m
index 6808de4..d68e6e7 100644
--- a/src/video/uikit/SDL_uikitwindow.m
+++ b/src/video/uikit/SDL_uikitwindow.m
@@ -403,8 +403,8 @@ UIKit_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
return SDL_TRUE;
} else {
- SDL_SetError("Application not compiled with SDL %d.%d",
- SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
+ SDL_SetError("Application not compiled with SDL %d",
+ SDL_MAJOR_VERSION);
return SDL_FALSE;
}
}
diff --git a/src/video/vita/SDL_vitavideo.c b/src/video/vita/SDL_vitavideo.c
index 60bd18f..33758d6 100644
--- a/src/video/vita/SDL_vitavideo.c
+++ b/src/video/vita/SDL_vitavideo.c
@@ -404,8 +404,8 @@ VITA_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
if (info->version.major <= SDL_MAJOR_VERSION) {
return SDL_TRUE;
} else {
- SDL_SetError("application not compiled with SDL %d.%d\n",
- SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
+ SDL_SetError("application not compiled with SDL %d\n",
+ SDL_MAJOR_VERSION);
return SDL_FALSE;
}
diff --git a/src/video/vivante/SDL_vivantevideo.c b/src/video/vivante/SDL_vivantevideo.c
index de2fdbf..3b18b7d 100644
--- a/src/video/vivante/SDL_vivantevideo.c
+++ b/src/video/vivante/SDL_vivantevideo.c
@@ -382,15 +382,14 @@ VIVANTE_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
SDL_DisplayData *displaydata = SDL_GetDisplayDriverData(0);
- if (info->version.major == SDL_MAJOR_VERSION &&
- info->version.minor == SDL_MINOR_VERSION) {
+ if (info->version.major == SDL_MAJOR_VERSION) {
info->subsystem = SDL_SYSWM_VIVANTE;
info->info.vivante.display = displaydata->native_display;
info->info.vivante.window = data->native_window;
return SDL_TRUE;
} else {
- SDL_SetError("Application not compiled with SDL %d.%d",
- SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
+ SDL_SetError("Application not compiled with SDL %d",
+ SDL_MAJOR_VERSION);
return SDL_FALSE;
}
}
diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c
index 6dcea5b..6608a5f 100644
--- a/src/video/windows/SDL_windowswindow.c
+++ b/src/video/windows/SDL_windowswindow.c
@@ -945,8 +945,8 @@ WIN_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
return SDL_TRUE;
} else {
- SDL_SetError("Application not compiled with SDL %d.%d",
- SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
+ SDL_SetError("Application not compiled with SDL %d",
+ SDL_MAJOR_VERSION);
return SDL_FALSE;
}
}
diff --git a/src/video/winrt/SDL_winrtvideo.cpp b/src/video/winrt/SDL_winrtvideo.cpp
index 6ed5918..e2d3f9e 100644
--- a/src/video/winrt/SDL_winrtvideo.cpp
+++ b/src/video/winrt/SDL_winrtvideo.cpp
@@ -834,8 +834,8 @@ WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
info->info.winrt.window = reinterpret_cast<IInspectable *>(data->coreWindow.Get());
return SDL_TRUE;
} else {
- SDL_SetError("Application not compiled with SDL %d.%d",
- SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
+ SDL_SetError("Application not compiled with SDL %d",
+ SDL_MAJOR_VERSION);
return SDL_FALSE;
}
return SDL_FALSE;
diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c
index 07fb602..8fb5ae9 100644
--- a/src/video/x11/SDL_x11window.c
+++ b/src/video/x11/SDL_x11window.c
@@ -1726,15 +1726,14 @@ X11_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
display = data->videodata->display;
- if (info->version.major == SDL_MAJOR_VERSION &&
- info->version.minor == SDL_MINOR_VERSION) {
+ if (info->version.major == SDL_MAJOR_VERSION) {
info->subsystem = SDL_SYSWM_X11;
info->info.x11.display = display;
info->info.x11.window = data->xwindow;
return SDL_TRUE;
} else {
- SDL_SetError("Application not compiled with SDL %d.%d",
- SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
+ SDL_SetError("Application not compiled with SDL %d",
+ SDL_MAJOR_VERSION);
return SDL_FALSE;
}
}