@@ -93,7 +93,7 @@ static void display_frame(struct state_sdl3 *s, struct video_frame *frame);
9393static struct video_frame * display_sdl3_getf (void * state );
9494static void display_sdl3_new_message (struct module * mod );
9595static bool display_sdl3_reconfigure_real (void * state , struct video_desc desc );
96- static void loadSplashscreen ( struct state_sdl3 * s );
96+ static void display_sdl3_done ( void * state );
9797
9898enum deint { DEINT_OFF , DEINT_ON , DEINT_FORCE };
9999
@@ -778,22 +778,30 @@ vulkan_warn(const char *req_renderers_name, const char *actual_renderer_name)
778778 explicit ? "" : " Please report!" );
779779}
780780
781- static void
781+ static bool
782782sdl3_set_window_position (struct state_sdl3 * s ) {
783783 if (s -> display_idx == -1 && s -> x == SDL_WINDOWPOS_UNDEFINED &&
784784 s -> y == SDL_WINDOWPOS_UNDEFINED ) {
785- return ;
785+ return true; // nothing to set
786786 }
787787 int x = s -> x ;
788788 int y = s -> y ;
789789 if (s -> display_idx != -1 ) {
790+ if (x != SDL_WINDOWPOS_UNDEFINED || y != SDL_WINDOWPOS_UNDEFINED ) {
791+ MSG (ERROR , "Do not set windows positiona and display "
792+ "at the same time!\n" );
793+ return false;
794+ }
790795 const SDL_DisplayID display_id =
791796 get_display_id_from_idx (s -> display_idx );
797+ if (display_id == 0 ) {
798+ return false;
799+ }
792800 x = (int ) SDL_WINDOWPOS_CENTERED_DISPLAY (display_id );
793801 y = (int ) SDL_WINDOWPOS_CENTERED_DISPLAY (display_id );
794802 }
795803 if (SDL_SetWindowPosition (s -> window , x , y )) {
796- return ;
804+ return true ;
797805 }
798806 const bool is_wayland =
799807 strcmp (SDL_GetCurrentVideoDriver (), "wayland" ) == 0 ;
@@ -802,11 +810,11 @@ sdl3_set_window_position(struct state_sdl3 *s) {
802810 "In Wayland, display specification is possible only with "
803811 "fullscreen flag ':fs' (%s)\n" ,
804812 SDL_GetError ());
805- return ;
813+ } else {
814+ MSG (ERROR , "Error (SDL_SetWindowPosition): %s\n" ,
815+ SDL_GetError ());
806816 }
807- const int ll = !is_wayland ? LOG_LEVEL_ERROR : LOG_LEVEL_VERBOSE ;
808- log_msg (ll , MOD_NAME "Error (SDL_SetWindowPosition): %s\n" ,
809- SDL_GetError ());
817+ return false;
810818}
811819
812820static bool
@@ -839,7 +847,10 @@ display_sdl3_reconfigure_real(void *state, struct video_desc desc)
839847 MSG (ERROR , "Unable to create window: %s\n" , SDL_GetError ());
840848 return false;
841849 }
842- sdl3_set_window_position (s );
850+ ;
851+ if (!sdl3_set_window_position (s )) {
852+ return false;
853+ }
843854
844855 if (s -> renderer ) {
845856 SDL_DestroyRenderer (s -> renderer );
@@ -893,14 +904,14 @@ display_sdl3_reconfigure_real(void *state, struct video_desc desc)
893904 return true;
894905}
895906
896- static void
907+ static bool
897908loadSplashscreen (struct state_sdl3 * s )
898909{
899910 struct video_frame * frame = get_splashscreen ();
900911 if (!display_sdl3_reconfigure_real (s , video_desc_from_frame (frame ))) {
901912 MSG (WARNING , "Cannot render splashscreeen!\n" );
902913 vf_free (frame );
903- return ;
914+ return false ;
904915 }
905916 struct video_frame * splash = display_sdl3_getf (s );
906917 memcpy (splash -> tiles [0 ].data , frame -> tiles [0 ].data ,
@@ -909,6 +920,7 @@ loadSplashscreen(struct state_sdl3 *s)
909920 display_frame (s , splash ); // don't be tempted to use _putf() - it will
910921 // use event queue and there may arise a
911922 // race-condition with recv thread
923+ return true;
912924}
913925
914926static bool
@@ -1113,7 +1125,10 @@ display_sdl3_init(struct module *parent, const char *fmt, unsigned int flags)
11131125 keybindings [i ].description );
11141126 }
11151127
1116- loadSplashscreen (s );
1128+ if (!loadSplashscreen (s )) {
1129+ display_sdl3_done (s );
1130+ return NULL ;
1131+ }
11171132
11181133 log_msg (LOG_LEVEL_NOTICE , "SDL3 initialized successfully.\n" );
11191134
0 commit comments