Skip to content

Commit 127a94c

Browse files
committed
Deprecate from_display_module
1 parent a0acfb7 commit 127a94c

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

docs/reST/ref/window.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,14 @@
247247
| :sl:`Create a Window object using window data from display module`
248248
| :sg:`from_display_module() -> Window`
249249
250+
**DON'T USE THIS!** If you want to draw to a surface and use the window
251+
API, use :func:`Window.get_surface` and :func:`Window.flip`.
252+
250253
Create a Window object that uses the same window data from the :mod:`pygame.display` module, created upon calling
251254
:func:`pygame.display.set_mode`.
252255

256+
.. deprecated:: 2.4.0
257+
253258
.. method:: get_surface
254259

255260
| :sl:`Get the window surface`

src_c/window.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -965,15 +965,22 @@ window_init(pgWindowObject *self, PyObject *args, PyObject *kwargs)
965965
static PyObject *
966966
window_from_display_module(PyTypeObject *cls, PyObject *_null)
967967
{
968-
SDL_Window *window;
969-
pgWindowObject *self;
970-
window = pg_GetDefaultWindow();
968+
if (PyErr_WarnEx(PyExc_DeprecationWarning,
969+
"Please use Window.get_surface and Window.flip to use "
970+
"surface-rendering with Window. This method will be "
971+
"removed in a future version.",
972+
1) == -1) {
973+
return NULL;
974+
}
975+
976+
SDL_Window *window = pg_GetDefaultWindow();
971977
if (!window) {
972978
return RAISE(pgExc_SDLError,
973979
"display.set_mode has not been called yet.");
974980
}
975981

976-
self = (pgWindowObject *)SDL_GetWindowData(window, "pg_window");
982+
pgWindowObject *self =
983+
(pgWindowObject *)SDL_GetWindowData(window, "pg_window");
977984
if (self != NULL) {
978985
Py_INCREF(self);
979986
return (PyObject *)self;

0 commit comments

Comments
 (0)