sdl3 Wayland display w/o fs: print SDL error

+ print the SDL_SetWindowPosition in verbose mode also in
Wayland (currently always an error - we are calling it with
x/y=SDL_WINDOWPOS_CENTERED_DISPLAY(0) if nothing is specified).
This commit is contained in:
Martin Pulec
2025-09-15 09:16:05 +02:00
parent cf20aea586
commit 2fd4d2e418
2 changed files with 20 additions and 12 deletions

View File

@@ -789,14 +789,18 @@ sdl3_set_window_position(struct state_sdl3 *s, int x, int y) {
const bool is_wayland =
strcmp(SDL_GetCurrentVideoDriver(), "wayland") == 0;
if (is_wayland && s->display_idx != -1 && !s->fs) {
MSG(ERROR, "In Wayland, display specification is available "
"only together with fullscreen flag ':fs'!\n");
} else if (!is_wayland || s->x != SDL_WINDOWPOS_UNDEFINED ||
s->y != SDL_WINDOWPOS_UNDEFINED) {
MSG(ERROR, "Error (SDL_SetWindowPosition): %s\n",
MSG(ERROR,
"In Wayland, display specification is possible only with "
"fullscreen flag ':fs' (%s)\n",
SDL_GetError());
return;
}
// no warning if wayland and x/y unspecified
const int ll = !is_wayland || s->x != SDL_WINDOWPOS_UNDEFINED ||
s->y != SDL_WINDOWPOS_UNDEFINED
? LOG_LEVEL_ERROR
: LOG_LEVEL_VERBOSE;
log_msg(ll, MOD_NAME "Error (SDL_SetWindowPosition): %s\n",
SDL_GetError());
}
static bool

View File

@@ -730,14 +730,18 @@ vulkan_sdl3_set_window_position(state_vulkan_sdl3 *s,
const bool is_wayland =
strcmp(SDL_GetCurrentVideoDriver(), "wayland") == 0;
if (is_wayland && args->display_idx != -1 && !s->fullscreen) {
MSG(ERROR, "In Wayland, display specification is available "
"only together with fullscreen flag ':fs'!\n");
} else if (!is_wayland || args->x != SDL_WINDOWPOS_UNDEFINED ||
args->y != SDL_WINDOWPOS_UNDEFINED) {
MSG(ERROR, "Error (SDL_SetWindowPosition): %s\n",
MSG(ERROR,
"In Wayland, display specification is possible only with "
"fullscreen flag ':fs' (%s)\n",
SDL_GetError());
return;
}
// no warning if wayland and x/y unspecified
const int ll = !is_wayland || args->x != SDL_WINDOWPOS_UNDEFINED ||
args->y != SDL_WINDOWPOS_UNDEFINED
? LOG_LEVEL_ERROR
: LOG_LEVEL_VERBOSE;
log_msg(ll, MOD_NAME "Error (SDL_SetWindowPosition): %s\n",
SDL_GetError());
}
void* display_vulkan_init(module* parent, const char* fmt, unsigned int flags) {