diff --git a/src_c/base.c b/src_c/base.c index 36903b8656..61627b8a9d 100644 --- a/src_c/base.c +++ b/src_c/base.c @@ -326,7 +326,7 @@ pg_init(PyObject *self, PyObject *_null) const char *modnames[] = { IMPPREFIX "display", /* Display first, this also inits event,time */ IMPPREFIX "joystick", IMPPREFIX "font", IMPPREFIX "freetype", - IMPPREFIX "mixer", + IMPPREFIX "mixer", IMPPREFIX "_window", /* IMPPREFIX "_sdl2.controller", Is this required? Comment for now*/ NULL}; @@ -409,6 +409,7 @@ _pg_quit(void) IMPPREFIX "freetype", IMPPREFIX "font", IMPPREFIX "joystick", + IMPPREFIX "_window", IMPPREFIX "display", /* Display last, this also quits event,time */ NULL}; diff --git a/src_c/window.c b/src_c/window.c index 9629d0c325..d13a5de4ff 100644 --- a/src_c/window.c +++ b/src_c/window.c @@ -970,6 +970,20 @@ window_repr(pgWindowObject *self) return PyUnicode_FromFormat("", title, win_id); } +static PyObject * +_window_internal_mod_init(PyObject *self, PyObject *_null) +{ + SDL_AddEventWatch(_resize_event_watch, NULL); + Py_RETURN_NONE; +} + +static PyObject * +_window_internal_mod_quit(PyObject *self, PyObject *_null) +{ + SDL_DelEventWatch(_resize_event_watch, NULL); + Py_RETURN_NONE; +} + static PyMethodDef window_methods[] = { {"destroy", (PyCFunction)window_destroy, METH_NOARGS, DOC_SDL2_VIDEO_WINDOW_DESTROY}, @@ -1053,6 +1067,10 @@ static PyTypeObject pgWindow_Type = { static PyMethodDef _window_methods[] = { {"get_grabbed_window", (PyCFunction)get_grabbed_window, METH_NOARGS, DOC_SDL2_VIDEO_GETGRABBEDWINDOW}, + {"_internal_mod_init", (PyCFunction)_window_internal_mod_init, METH_NOARGS, + "auto initialize for _window module"}, + {"_internal_mod_quit", (PyCFunction)_window_internal_mod_quit, METH_NOARGS, + "auto quit for _window module"}, {NULL, NULL, 0, NULL}}; MODINIT_DEFINE(_window) @@ -1113,7 +1131,5 @@ MODINIT_DEFINE(_window) return NULL; } - SDL_AddEventWatch(_resize_event_watch, NULL); - return module; }