Skip to content

Commit

Permalink
Remove unused listwindows functions for Windows/3.12 support
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Feb 11, 2023
1 parent ac6b963 commit 826c981
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 76 deletions.
3 changes: 0 additions & 3 deletions src/_imaging.c
Original file line number Diff line number Diff line change
Expand Up @@ -3984,8 +3984,6 @@ PyImaging_GrabScreenWin32(PyObject *self, PyObject *args);
extern PyObject *
PyImaging_GrabClipboardWin32(PyObject *self, PyObject *args);
extern PyObject *
PyImaging_ListWindowsWin32(PyObject *self, PyObject *args);
extern PyObject *
PyImaging_EventLoopWin32(PyObject *self, PyObject *args);
extern PyObject *
PyImaging_DrawWmf(PyObject *self, PyObject *args);
Expand Down Expand Up @@ -4069,7 +4067,6 @@ static PyMethodDef functions[] = {
{"grabclipboard_win32", (PyCFunction)PyImaging_GrabClipboardWin32, METH_VARARGS},
{"createwindow", (PyCFunction)PyImaging_CreateWindowWin32, METH_VARARGS},
{"eventloop", (PyCFunction)PyImaging_EventLoopWin32, METH_VARARGS},
{"listwindows", (PyCFunction)PyImaging_ListWindowsWin32, METH_VARARGS},
{"drawwmf", (PyCFunction)PyImaging_DrawWmf, METH_VARARGS},
#endif
#ifdef HAVE_XCB
Expand Down
73 changes: 0 additions & 73 deletions src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,79 +421,6 @@ PyImaging_GrabScreenWin32(PyObject *self, PyObject *args) {
return NULL;
}

static BOOL CALLBACK
list_windows_callback(HWND hwnd, LPARAM lParam) {
PyObject *window_list = (PyObject *)lParam;
PyObject *item;
PyObject *title;
RECT inner, outer;
int title_size;
int status;

/* get window title */
title_size = GetWindowTextLength(hwnd);
if (title_size > 0) {
title = PyUnicode_FromStringAndSize(NULL, title_size);
if (title) {
GetWindowTextW(hwnd, PyUnicode_AS_UNICODE(title), title_size + 1);
}
} else {
title = PyUnicode_FromString("");
}
if (!title) {
return 0;
}

/* get bounding boxes */
GetClientRect(hwnd, &inner);
GetWindowRect(hwnd, &outer);

item = Py_BuildValue(
F_HANDLE "N(iiii)(iiii)",
hwnd,
title,
inner.left,
inner.top,
inner.right,
inner.bottom,
outer.left,
outer.top,
outer.right,
outer.bottom);
if (!item) {
return 0;
}

status = PyList_Append(window_list, item);

Py_DECREF(item);

if (status < 0) {
return 0;
}

return 1;
}

PyObject *
PyImaging_ListWindowsWin32(PyObject *self, PyObject *args) {
PyObject *window_list;

window_list = PyList_New(0);
if (!window_list) {
return NULL;
}

EnumWindows(list_windows_callback, (LPARAM)window_list);

if (PyErr_Occurred()) {
Py_DECREF(window_list);
return NULL;
}

return window_list;
}

/* -------------------------------------------------------------------- */
/* Windows clipboard grabber */

Expand Down

0 comments on commit 826c981

Please sign in to comment.