Skip to content

Commit 020f6d0

Browse files
authored
Merge pull request #2624 from Starbuck5/deprecate-from-display-module
Deprecate from_display_module
2 parents f2b0160 + 127a94c commit 020f6d0

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
@@ -233,9 +233,14 @@
233233
| :sl:`Create a Window object using window data from display module`
234234
| :sg:`from_display_module() -> Window`
235235
236+
**DON'T USE THIS!** If you want to draw to a surface and use the window
237+
API, use :func:`Window.get_surface` and :func:`Window.flip`.
238+
236239
Create a Window object that uses the same window data from the :mod:`pygame.display` module, created upon calling
237240
:func:`pygame.display.set_mode`.
238241

242+
.. deprecated:: 2.4.0
243+
239244
.. method:: get_surface
240245

241246
| :sl:`Get the window surface`

src_c/window.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -939,15 +939,22 @@ window_init(pgWindowObject *self, PyObject *args, PyObject *kwargs)
939939
static PyObject *
940940
window_from_display_module(PyTypeObject *cls, PyObject *_null)
941941
{
942-
SDL_Window *window;
943-
pgWindowObject *self;
944-
window = pg_GetDefaultWindow();
942+
if (PyErr_WarnEx(PyExc_DeprecationWarning,
943+
"Please use Window.get_surface and Window.flip to use "
944+
"surface-rendering with Window. This method will be "
945+
"removed in a future version.",
946+
1) == -1) {
947+
return NULL;
948+
}
949+
950+
SDL_Window *window = pg_GetDefaultWindow();
945951
if (!window) {
946952
return RAISE(pgExc_SDLError,
947953
"display.set_mode has not been called yet.");
948954
}
949955

950-
self = (pgWindowObject *)SDL_GetWindowData(window, "pg_window");
956+
pgWindowObject *self =
957+
(pgWindowObject *)SDL_GetWindowData(window, "pg_window");
951958
if (self != NULL) {
952959
Py_INCREF(self);
953960
return (PyObject *)self;

0 commit comments

Comments
 (0)