@@ -584,7 +584,7 @@ struct command_line_arguments {
584584 bool tearing_permitted = false ;
585585 bool validation = false ;
586586
587- int display_idx = 0 ;
587+ int display_idx = - 1 ;
588588 int x = SDL_WINDOWPOS_UNDEFINED;
589589 int y = SDL_WINDOWPOS_UNDEFINED;
590590
@@ -693,6 +693,24 @@ bool parse_command_line_arguments(command_line_arguments& args, state_vulkan_sdl
693693 return true ;
694694}
695695
696+ void
697+ vulkan_sdl2_validate_params (state_vulkan_sdl2 *s,
698+ const command_line_arguments *args)
699+ {
700+ if (strcmp (SDL_GetCurrentVideoDriver (), " wayland" ) != 0 ) {
701+ return ;
702+ }
703+ if (args->display_idx != -1 && !s->fullscreen ) {
704+ MSG (WARNING, " In Wayland, display specification is available "
705+ " only together with fullscreen flag ':fs'!\n " );
706+ }
707+ if (args->x != SDL_WINDOWPOS_UNDEFINED ||
708+ args->y != SDL_WINDOWPOS_UNDEFINED) {
709+ MSG (WARNING,
710+ " Window positon should not be specified with Wayland!\n " );
711+ }
712+ }
713+
696714void * display_vulkan_init (module * parent, const char * fmt, unsigned int flags) {
697715 if (flags & DISPLAY_FLAG_AUDIO_ANY) {
698716 log_msg (LOG_LEVEL_ERROR, " UltraGrid VULKAN_SDL2 module currently doesn't support audio!\n " );
@@ -739,8 +757,9 @@ void* display_vulkan_init(module* parent, const char* fmt, unsigned int flags) {
739757 window_title = get_commandline_param (" window-title" );
740758 }
741759
742- int x = (args.x == SDL_WINDOWPOS_UNDEFINED ? SDL_WINDOWPOS_CENTERED_DISPLAY (args.display_idx ) : args.x );
743- int y = (args.y == SDL_WINDOWPOS_UNDEFINED ? SDL_WINDOWPOS_CENTERED_DISPLAY (args.display_idx ) : args.y );
760+ int display_idx = args.display_idx == -1 ? 0 : args.display_idx ;
761+ int x = (args.x == SDL_WINDOWPOS_UNDEFINED ? SDL_WINDOWPOS_CENTERED_DISPLAY (display_idx) : args.x );
762+ int y = (args.y == SDL_WINDOWPOS_UNDEFINED ? SDL_WINDOWPOS_CENTERED_DISPLAY (display_idx) : args.y );
744763 if (s->width == -1 && s->height == -1 ){
745764 SDL_DisplayMode mode;
746765 int display_index = 0 ;
@@ -762,6 +781,7 @@ void* display_vulkan_init(module* parent, const char* fmt, unsigned int flags) {
762781 window_flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
763782 }
764783
784+ vulkan_sdl2_validate_params (s.get (), &args);
765785 s->window = SDL_CreateWindow (window_title, x, y, s->width , s->height , window_flags);
766786 if (!s->window ) {
767787 log_msg (LOG_LEVEL_ERROR, MOD_NAME " Unable to create window : %s\n " , SDL_GetError ());
0 commit comments