Skip to content

Commit b96080e

Browse files
committed
vulkan_sdl3: chech display_idx spec only with fs
In Wayland, the display/position specification is not possible. The display can be specified when having fullscreen. see also vdisp/sdl3
1 parent fc20578 commit b96080e

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/video_display/vulkan/vulkan_sdl3.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,27 @@ get_display_id_from_idx(int idx)
738738
return 0;
739739
}
740740

741+
void
742+
vulkan_sdl3_set_window_position(state_vulkan_sdl3 *s,
743+
const command_line_arguments *args, int x,
744+
int y)
745+
{
746+
if (SDL_SetWindowPosition(s->window, x, y)) {
747+
return;
748+
}
749+
const bool is_wayland =
750+
strcmp(SDL_GetCurrentVideoDriver(), "wayland") == 0;
751+
if (is_wayland && args->display_idx != -1 && !s->fullscreen) {
752+
MSG(ERROR, "In Wayland, display specification is available "
753+
"only together with fullscreen flag ':fs'!\n");
754+
} else if (!is_wayland || args->x != SDL_WINDOWPOS_UNDEFINED ||
755+
args->y != SDL_WINDOWPOS_UNDEFINED) {
756+
MSG(ERROR, "Error (SDL_SetWindowPosition): %s\n",
757+
SDL_GetError());
758+
}
759+
// no warning if wayland and x/y unspecified
760+
}
761+
741762
void* display_vulkan_init(module* parent, const char* fmt, unsigned int flags) {
742763
sdl_set_log_level();
743764
if (flags & DISPLAY_FLAG_AUDIO_ANY) {
@@ -820,7 +841,7 @@ void* display_vulkan_init(module* parent, const char* fmt, unsigned int flags) {
820841
return nullptr;
821842
}
822843
s->window_callback = new WindowCallback(s->window);
823-
SDL_CHECK(SDL_SetWindowPosition(s->window, x, y));
844+
vulkan_sdl3_set_window_position(s.get(), &args, x, y);
824845

825846
uint32_t extension_count = 0;
826847
const char *const *extensions = SDL_Vulkan_GetInstanceExtensions(&extension_count);

0 commit comments

Comments
 (0)