Skip to content

Commit e3db181

Browse files
authored
Merge pull request #3386 from damusss/setmode-0size-warning-fix
Remove warning with zero size & RESIZABLE in display.set_mode
2 parents 62a4930 + aef8f35 commit e3db181

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src_c/display.c

+7-5
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,7 @@ pg_set_mode(PyObject *self, PyObject *arg, PyObject *kwds)
871871
SDL_Surface *newownedsurf = NULL;
872872
int depth = 0;
873873
int flags = 0;
874+
int zero_size = 0;
874875
int w, h, w_actual, h_actual;
875876
PyObject *size = NULL;
876877
int vsync = SDL_FALSE;
@@ -988,6 +989,7 @@ pg_set_mode(PyObject *self, PyObject *arg, PyObject *kwds)
988989
desktop resolution without breaking compatibility. */
989990
w = display_mode.w;
990991
h = display_mode.h;
992+
zero_size = 1;
991993
}
992994

993995
if (flags & PGS_FULLSCREEN) {
@@ -1432,16 +1434,16 @@ pg_set_mode(PyObject *self, PyObject *arg, PyObject *kwds)
14321434
* be respected enough that we don't need to issue a warning
14331435
*/
14341436
if (!state->using_gl && ((flags & (PGS_SCALED | PGS_FULLSCREEN)) == 0) &&
1435-
!vsync) {
1437+
!vsync && (((flags & PGS_RESIZABLE) == 0) || !zero_size)) {
14361438
if (((surface->surf->w != w_actual) ||
14371439
(surface->surf->h != h_actual)) &&
14381440
((surface->surf->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != 0)) {
14391441
char buffer[150];
14401442
char *format_string =
1441-
"Requested window size was smaller than minimum supported "
1442-
"window size on platform. Using (%d, %d) instead.";
1443-
snprintf(buffer, sizeof(buffer), format_string, surface->surf->w,
1444-
surface->surf->h);
1443+
"Requested window was forcibly resized by the OS.\n\t"
1444+
"Requested window size: (%d, %d)\n\tNew window size: (%d, %d)";
1445+
snprintf(buffer, sizeof(buffer), format_string, w_actual, h_actual,
1446+
surface->surf->w, surface->surf->h);
14451447
if (PyErr_WarnEx(PyExc_RuntimeWarning, buffer, 1) != 0) {
14461448
return NULL;
14471449
}

0 commit comments

Comments
 (0)