Skip to content

Commit 4c5b9d5

Browse files
authored
Merge pull request #2865 from pygame-community/ankith26-fix-window-size
Force window surface update after set_size, hopefully proper fix for that pesky frequent pypy test fail
2 parents aead275 + 38d66b6 commit 4c5b9d5

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src_c/window.c

+5
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,11 @@ window_set_size(pgWindowObject *self, PyObject *arg, void *v)
572572
}
573573

574574
SDL_SetWindowSize(self->_win, w, h);
575+
if (self->surf) {
576+
/* Ensure that the underlying surf is immediately updated, instead of
577+
* relying on the event callback */
578+
self->surf->surf = SDL_GetWindowSurface(self->_win);
579+
}
575580

576581
return 0;
577582
}

test/window_test.py

-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import unittest
22
import pygame
33
import os
4-
import time
54

65
from pygame import Window
76
from pygame.version import SDL
@@ -321,23 +320,16 @@ def test_from_display_module(self):
321320
pygame.init()
322321

323322
def test_window_surface(self):
324-
# window's surface uses an event callback that may take some time to get
325-
# processed by the system event queue - sleep for 1 second to give
326-
# the window event queue chance to catch up
327323
win = Window(size=(640, 480))
328-
time.sleep(1)
329324
surf = win.get_surface()
330325

331326
self.assertIsInstance(surf, pygame.Surface)
332327

333328
# test auto resize
334329
self.assertTupleEqual(win.size, surf.get_size())
335-
336330
win.size = (100, 100)
337-
time.sleep(1)
338331
self.assertTupleEqual(win.size, surf.get_size())
339332
win.size = (1280, 720)
340-
time.sleep(1)
341333
self.assertTupleEqual(win.size, surf.get_size())
342334

343335
# window surface should be invalid after the window is destroyed

0 commit comments

Comments
 (0)