aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/matplotlib/py2/src/_windowing.cpp
diff options
context:
space:
mode:
authorzverevgeny <zverevgeny@yandex-team.com>2025-05-13 19:00:02 +0300
committerzverevgeny <zverevgeny@yandex-team.com>2025-05-13 19:13:54 +0300
commit92e06374736aa28637dc0e706455b65c8268a5e6 (patch)
tree3df370c199ae25d308e542f02af20f43eab78f8a /contrib/python/matplotlib/py2/src/_windowing.cpp
parentdc63d5794da99c2ebe3f32914d0351d9707660b0 (diff)
downloadydb-92e06374736aa28637dc0e706455b65c8268a5e6.tar.gz
Import matplotlib
commit_hash:d59c2338025ef8fd1e1f961ed9d8d5fd52d0bd96
Diffstat (limited to 'contrib/python/matplotlib/py2/src/_windowing.cpp')
-rw-r--r--contrib/python/matplotlib/py2/src/_windowing.cpp64
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 00000000000..7a20baa0a39
--- /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