From 22354b414276872f50218a9596d10fd2f4d0ad82 Mon Sep 17 00:00:00 2001 From: pionere Date: Sat, 12 Nov 2022 08:29:15 +0100 Subject: [PATCH] video: simplify window-type check in SDL_CreateWindow --- src/video/SDL_video.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 0495e8ca9..fdfd912cd 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1597,7 +1597,7 @@ SDL_Window * SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) { SDL_Window *window; - Uint32 graphics_flags = flags & (SDL_WINDOW_OPENGL | SDL_WINDOW_METAL | SDL_WINDOW_VULKAN); + Uint32 type_flags, graphics_flags = flags & (SDL_WINDOW_OPENGL | SDL_WINDOW_METAL | SDL_WINDOW_VULKAN); if (!_this) { /* Initialize the video system if needed */ @@ -1606,7 +1606,9 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) } } - if ((((flags & SDL_WINDOW_UTILITY) != 0) + ((flags & SDL_WINDOW_TOOLTIP) != 0) + ((flags & SDL_WINDOW_POPUP_MENU) != 0)) > 1) { + /* ensure no more than one of these flags is set */ + type_flags = flags & (SDL_WINDOW_UTILITY | SDL_WINDOW_TOOLTIP | SDL_WINDOW_POPUP_MENU); + if ((type_flags & (type_flags - 1)) != 0) { SDL_SetError("Conflicting window flags specified"); return NULL; }