Skip to content

Commit 52034ca

Browse files
authored
Merge pull request #3591 from pygame-community/ankith26-misc-fixes
Misc bug fixes (display, window, image, pixelarray)
2 parents 3cb14a5 + b438502 commit 52034ca

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

src_c/display.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -894,10 +894,10 @@ pg_ResizeEventWatch(void *userdata, SDL_Event *event)
894894
SDL_Window *window;
895895

896896
#if SDL_VERSION_ATLEAST(3, 0, 0)
897-
if (event->type >= SDL_EVENT_WINDOW_FIRST &&
898-
event->type <= SDL_EVENT_WINDOW_LAST)
897+
if (!(event->type >= SDL_EVENT_WINDOW_FIRST &&
898+
event->type <= SDL_EVENT_WINDOW_LAST))
899899
#else
900-
if (event->type == SDL_WINDOWEVENT)
900+
if (event->type != SDL_WINDOWEVENT)
901901
#endif
902902
{
903903
return 0;
@@ -1832,12 +1832,7 @@ pg_set_mode(PyObject *self, PyObject *arg, PyObject *kwds)
18321832
if (!state->using_gl && ((flags & (PGS_SCALED | PGS_FULLSCREEN)) == 0) &&
18331833
!vsync && (((flags & PGS_RESIZABLE) == 0) || !zero_size)) {
18341834
if (((surface->surf->w != w_actual) ||
1835-
(surface->surf->h != h_actual)) &&
1836-
#if SDL_VERSION_ATLEAST(3, 0, 0)
1837-
((surface->surf->flags & SDL_WINDOW_FULLSCREEN) != 0)) {
1838-
#else
1839-
((surface->surf->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != 0)) {
1840-
#endif
1835+
(surface->surf->h != h_actual))) {
18411836
char buffer[150];
18421837
char *format_string =
18431838
"Requested window was forcibly resized by the OS.\n\t"

src_c/image.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,8 +698,8 @@ image_tobytes(PyObject *self, PyObject *arg, PyObject *kwarg)
698698
for (w = 0; w < surf->w; ++w) {
699699
color = *ptr++;
700700
data[0] = (char)(((color & Rmask) >> Rshift) << Rloss);
701-
data[1] = (char)(((color & Gmask) >> Gshift) << Rloss);
702-
data[2] = (char)(((color & Bmask) >> Bshift) << Rloss);
701+
data[1] = (char)(((color & Gmask) >> Gshift) << Gloss);
702+
data[2] = (char)(((color & Bmask) >> Bshift) << Bloss);
703703
data += 3;
704704
}
705705
pad(&data, padding);

src_c/pixelarray_methods.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ _make_surface(pgPixelArrayObject *array, PyObject *args)
158158
}
159159

160160
/* Acquire a temporary lock. */
161-
if (SDL_MUSTLOCK(new_surf) == 0) {
161+
if (SDL_MUSTLOCK(new_surf)) {
162162
SDL_LockSurface(new_surf);
163163
}
164164

@@ -237,7 +237,7 @@ _make_surface(pgPixelArrayObject *array, PyObject *args)
237237
}
238238
Py_END_ALLOW_THREADS;
239239

240-
if (SDL_MUSTLOCK(new_surf) == 0) {
240+
if (SDL_MUSTLOCK(new_surf)) {
241241
SDL_UnlockSurface(new_surf);
242242
}
243243
return (PyObject *)new_surface;

src_c/window.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ window_set_modal_for(pgWindowObject *self, PyObject *arg)
473473
return RAISE(PyExc_TypeError,
474474
"Argument to set_modal_for must be a Window.");
475475
}
476-
if (!PG_SetWindowModalFor(self->_win, ((pgWindowObject *)arg)->_win)) {
476+
if (PG_SetWindowModalFor(self->_win, ((pgWindowObject *)arg)->_win) < 0) {
477477
return RAISE(pgExc_SDLError, SDL_GetError());
478478
}
479479
Py_RETURN_NONE;

0 commit comments

Comments
 (0)