From 69a2809d2b816252f4d427db8bc2e30785e67fbb Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Wed, 26 Mar 2025 06:55:50 +0300
Subject: [PATCH] avoid some integral constant will be truncated warnings
gcc7 and gcc14 asm outputs are the same before and after this patch
---
src/sdl2_compat.c | 18 +++++++++---------
src/sdl2_compat.h | 5 ++++-
2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index 9ff9387..edd2741 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -8789,7 +8789,7 @@ SDL_GetWindowFlags(SDL_Window *window)
}
if ((flags3 & SDL_WINDOW_FULLSCREEN)) {
if (SDL3_GetWindowFullscreenMode(window)) {
- flags |= SDL_WINDOW_FULLSCREEN;
+ flags |= SDL2_WINDOW_FULLSCREEN;
} else {
flags |= SDL2_WINDOW_FULLSCREEN_DESKTOP;
}
@@ -8906,12 +8906,12 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
if ((flags & SDL2_WINDOW_FULLSCREEN_DESKTOP) == SDL2_WINDOW_FULLSCREEN_DESKTOP) {
flags &= ~SDL2_WINDOW_FULLSCREEN_DESKTOP;
- flags |= SDL_WINDOW_FULLSCREEN; /* This is fullscreen desktop for new windows */
- } else if (flags & SDL_WINDOW_FULLSCREEN) {
+ flags |= SDL2_WINDOW_FULLSCREEN; /* This is fullscreen desktop for new windows */
+ } else if (flags & SDL2_WINDOW_FULLSCREEN) {
/* We'll set the fullscreen mode after window creation */
exclusive_fullscreen = true;
- flags &= ~SDL_WINDOW_FULLSCREEN;
+ flags &= ~SDL2_WINDOW_FULLSCREEN;
if (!(flags & SDL_WINDOW_HIDDEN)) {
flags |= SDL_WINDOW_HIDDEN;
manually_show = true;
@@ -8919,7 +8919,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
}
if (flags & SDL2_WINDOW_SKIP_TASKBAR) {
flags &= ~SDL2_WINDOW_SKIP_TASKBAR;
- flags |= SDL_WINDOW_UTILITY;
+ flags |= SDL2_WINDOW_UTILITY;
}
/* whoops, this changed values in SDL3. */
@@ -8928,8 +8928,8 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
flags |= SDL_WINDOW_ALWAYS_ON_TOP;
}
- if ((flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) && SDL3_GetHintBoolean("SDL_VIDEO_HIGHDPI_DISABLED", false)) {
- flags &= ~SDL_WINDOW_HIGH_PIXEL_DENSITY;
+ if ((flags & SDL2_WINDOW_ALLOW_HIGHDPI) && SDL3_GetHintBoolean("SDL_VIDEO_HIGHDPI_DISABLED", false)) {
+ flags &= ~SDL2_WINDOW_ALLOW_HIGHDPI;
}
if (!is_popup) {
@@ -8956,7 +8956,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
if (parent) {
/* UE5 mixes the utility flag with popup flags, which SDL3 does not allow. */
- flags &= ~SDL_WINDOW_UTILITY;
+ flags &= ~SDL2_WINDOW_UTILITY;
window = SDL3_CreatePopupWindow(parent, x, y, w, h, flags);
SDL_SetWindowData(window, PROP_WINDOW_PARENT_POINTER, parent);
@@ -9055,7 +9055,7 @@ SDL_SetWindowFullscreen(SDL_Window *window, Uint32 flags)
if (flags == SDL2_WINDOW_FULLSCREEN_DESKTOP) {
fullscreen = true;
ret = SDL3_SetWindowFullscreenMode(window, NULL) ? 0 : -1;
- } else if (flags == SDL_WINDOW_FULLSCREEN) {
+ } else if (flags == SDL2_WINDOW_FULLSCREEN) {
fullscreen = true;
ret = ApplyFullscreenMode(window);
}
diff --git a/src/sdl2_compat.h b/src/sdl2_compat.h
index bc8e5bd..b2758bd 100644
--- a/src/sdl2_compat.h
+++ b/src/sdl2_compat.h
@@ -45,8 +45,11 @@ typedef enum
/* removed in SDL3 (which only uses SDL_WINDOW_HIDDEN now). */
#define SDL2_WINDOW_SHOWN 0x000000004
-#define SDL2_WINDOW_FULLSCREEN_DESKTOP (0x00001000 | SDL_WINDOW_FULLSCREEN)
+#define SDL2_WINDOW_FULLSCREEN 0x00000001 /* same as SDL3 but 32 bits */
+#define SDL2_WINDOW_FULLSCREEN_DESKTOP (0x00001000 | SDL2_WINDOW_FULLSCREEN)
#define SDL2_WINDOW_SKIP_TASKBAR 0x00010000
+#define SDL2_WINDOW_UTILITY 0x00020000
+#define SDL2_WINDOW_ALLOW_HIGHDPI 0x00002000
/* has a different bit set for SDL3. */
#define SDL2_WINDOW_ALWAYS_ON_TOP 0x00008000