Skip to content

Commit b8dec4f

Browse files
committed
Address conventions and improve tests
1 parent 4831155 commit b8dec4f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src_c/display.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2304,7 +2304,7 @@ pg_get_desktop_usable_bounds(PyObject *self, PyObject *_null)
23042304

23052305
VIDEO_INIT_CHECK();
23062306

2307-
#if PG_SDL3
2307+
#if SDL_VERSION_ATLEAST(3, 0, 0)
23082308
SDL_DisplayID *displays = SDL_GetDisplays(&display_count);
23092309
if (displays == NULL) {
23102310
return RAISE(pgExc_SDLError, SDL_GetError());
@@ -2328,7 +2328,7 @@ pg_get_desktop_usable_bounds(PyObject *self, PyObject *_null)
23282328
SDL_Rect bounds;
23292329
#if PG_SDL3
23302330
SDL_DisplayID display_id = displays[i];
2331-
if (SDL_GetDisplayUsableBounds(display_id, &bounds) == SDL_FALSE) {
2331+
if (!SDL_GetDisplayUsableBounds(display_id, &bounds)) {
23322332
Py_DECREF(result);
23332333
SDL_free(displays);
23342334
return RAISE(pgExc_SDLError, SDL_GetError());

test/display_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,10 @@ def test_get_desktop_usable_bounds(self):
707707
size = sizes[i]
708708
self.assertLessEqual(bound.w, size[0])
709709
self.assertLessEqual(bound.h, size[1])
710+
for j, coord in enumerate(bound):
711+
self.assertGreaterEqual(
712+
coord, 0, f"Bounds rect coordinate {j} is negative ({coord})"
713+
)
710714

711715

712716
class DisplayUpdateTest(unittest.TestCase):

0 commit comments

Comments
 (0)