Skip to content

Commit fede184

Browse files
committed
sdl3(display): handle MessageBox changes
1 parent ac352fb commit fede184

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src_c/display.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,13 @@ pg_ResizeEventWatch(void *userdata, SDL_Event *event)
718718
_DisplayState *state;
719719
SDL_Window *window;
720720

721-
if (event->type != SDL_WINDOWEVENT) {
721+
#if SDL_VERSION_ATLEAST(3, 0, 0)
722+
if (event->type >= SDL_EVENT_WINDOW_FIRST &&
723+
event->type <= SDL_EVENT_WINDOW_LAST)
724+
#else
725+
if (event->type == SDL_WINDOWEVENT)
726+
#endif
727+
{
722728
return 0;
723729
}
724730

@@ -3067,7 +3073,11 @@ pg_message_box(PyObject *self, PyObject *arg, PyObject *kwargs)
30673073
if (buttons == NULL) {
30683074
buttons_data = malloc(sizeof(SDL_MessageBoxButtonData));
30693075
buttons_data->flags = 0;
3076+
#if SDL_VERSION_ATLEAST(3, 0, 0)
3077+
buttons_data->buttonID = 0;
3078+
#else
30703079
buttons_data->buttonid = 0;
3080+
#endif
30713081
buttons_data->text = "OK";
30723082

30733083
msgbox_data.numbuttons = 1;
@@ -3141,6 +3151,19 @@ pg_message_box(PyObject *self, PyObject *arg, PyObject *kwargs)
31413151
}
31423152

31433153
buttons_data[i].text = btn_name;
3154+
#if SDL_VERSION_ATLEAST(3, 0, 0)
3155+
buttons_data[i].buttonID = (int)i;
3156+
buttons_data[i].flags = 0;
3157+
if (return_button_index == buttons_data[i].buttonID) {
3158+
buttons_data[i].flags |=
3159+
SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT;
3160+
}
3161+
if (escape_button_used &&
3162+
escape_button_index == buttons_data[i].buttonID) {
3163+
buttons_data[i].flags |=
3164+
SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
3165+
}
3166+
#else
31443167
buttons_data[i].buttonid = (int)i;
31453168
buttons_data[i].flags = 0;
31463169
if (return_button_index == buttons_data[i].buttonid) {
@@ -3152,6 +3175,7 @@ pg_message_box(PyObject *self, PyObject *arg, PyObject *kwargs)
31523175
buttons_data[i].flags |=
31533176
SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
31543177
}
3178+
#endif
31553179
}
31563180
}
31573181

0 commit comments

Comments
 (0)