-
-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Another attempt to fix multimonitor issues with SDL backend #2010
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm mostly fine with these changes, but you need to format the code.
engine/platform/sdl/vid_sdl.c
Outdated
@@ -757,34 +778,37 @@ qboolean VID_CreateWindow( int width, int height, window_mode_t window_mode ) | |||
|
|||
if( window_mode == WINDOW_MODE_WINDOWED ) | |||
{ | |||
SDL_Rect r; | |||
SDL_Rect *display_rects = (SDL_Rect *)malloc( num_displays * sizeof( SDL_Rect )); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You forgot to free display_rects
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused: have I done this correctly now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the memory you allocated with malloc
must be deallocated using free
, once you don't need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. Should be done now.
5c459a9
to
b5402f9
Compare
engine/platform/sdl/vid_sdl.c
Outdated
if( !display_rects ) | ||
{ | ||
Con_Printf( S_ERROR "Failed to allocate memory for display rects!\n" ); | ||
SDL_Quit(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it should be Sys_Error, if you want to exit.
But it would be more correct to handle the error if allocating display_rects
has failed and just fall back to SDL_WINDOWPOS_UNDEFINED
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
engine/platform/sdl/vid_sdl.c
Outdated
{ | ||
if( SDL_GetDisplayBounds( i, &display_rects[i] ) != 0 ) | ||
{ | ||
Con_Printf( S_ERROR "Failed to get bounds for display %d! SDL_Error: %s\n", i, SDL_GetError()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to handle this error as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
engine/platform/sdl/vid_sdl.c
Outdated
} | ||
free(display_rects); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spaces in parentheses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. One day I'll get used to this.
… located is instead of display zero
I've uploaded one more fix. Previously window position would only be saved in window mode, and display in fullscreen mode would always be dictated by the platform. Now engine will also remember last used display. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, looks good to me! Thank you!
In this PR we will do the next: