diff options
author | maxim-yurchuk <maxim-yurchuk@yandex-team.com> | 2024-10-09 12:29:46 +0300 |
---|---|---|
committer | maxim-yurchuk <maxim-yurchuk@yandex-team.com> | 2024-10-09 13:14:22 +0300 |
commit | 9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80 (patch) | |
tree | a8fb3181d5947c0d78cf402aa56e686130179049 /contrib/python/matplotlib/py2/src/_windowing.cpp | |
parent | a44b779cd359f06c3ebbef4ec98c6b38609d9d85 (diff) | |
download | ydb-9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80.tar.gz |
publishFullContrib: true for ydb
<HIDDEN_URL>
commit_hash:c82a80ac4594723cebf2c7387dec9c60217f603e
Diffstat (limited to 'contrib/python/matplotlib/py2/src/_windowing.cpp')
-rw-r--r-- | contrib/python/matplotlib/py2/src/_windowing.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/contrib/python/matplotlib/py2/src/_windowing.cpp b/contrib/python/matplotlib/py2/src/_windowing.cpp new file mode 100644 index 0000000000..7a20baa0a3 --- /dev/null +++ b/contrib/python/matplotlib/py2/src/_windowing.cpp @@ -0,0 +1,64 @@ +#include "Python.h" +#include <windows.h> + +static PyObject * +_GetForegroundWindow(PyObject *module, PyObject *args) +{ + HWND handle = GetForegroundWindow(); + if (!PyArg_ParseTuple(args, ":GetForegroundWindow")) + { + return NULL; + } + return PyLong_FromSize_t((size_t)handle); +} + +static PyObject * +_SetForegroundWindow(PyObject *module, PyObject *args) +{ + HWND handle; + if (!PyArg_ParseTuple(args, "n:SetForegroundWindow", &handle)) + { + return NULL; + } + if (!SetForegroundWindow(handle)) + { + return PyErr_Format(PyExc_RuntimeError, + "Error setting window"); + } + Py_INCREF(Py_None); + return Py_None; +} + +static PyMethodDef _windowing_methods[] = +{ + {"GetForegroundWindow", _GetForegroundWindow, METH_VARARGS}, + {"SetForegroundWindow", _SetForegroundWindow, METH_VARARGS}, + {NULL, NULL} +}; + +#if PY_MAJOR_VERSION >= 3 + +static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, + "_windowing", + "", + -1, + _windowing_methods, + NULL, + NULL, + NULL, + NULL +}; + +PyMODINIT_FUNC PyInit__windowing(void) +{ + PyObject *module = PyModule_Create(&moduledef); + return module; +} + +#else +PyMODINIT_FUNC init_windowing() +{ + Py_InitModule("_windowing", _windowing_methods); +} +#endif |