From 79d5049273ce4d485d3dd2ff73dcdab5b7c06a8a Mon Sep 17 00:00:00 2001 From: Jason Felice Date: Thu, 23 Jul 2020 18:55:00 -0400 Subject: [PATCH] Provide cocoa_window_id() on non-Mac, also So that its import in tabs.py doesn't have to be conditional. --- kitty/glfw.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kitty/glfw.c b/kitty/glfw.c index 0891a9894..8ae889f03 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -1045,15 +1045,18 @@ x11_window_id(PyObject UNUSED *self, PyObject *os_wid) { return Py_BuildValue("l", (long)glfwGetX11Window(w->handle)); } -#ifdef __APPLE__ static PyObject* cocoa_window_id(PyObject UNUSED *self, PyObject *os_wid) { OSWindow *w = find_os_window(os_wid); if (!w) { PyErr_SetString(PyExc_ValueError, "No OSWindow with the specified id found"); return NULL; } if (!glfwGetCocoaWindow) { PyErr_SetString(PyExc_RuntimeError, "Failed to load glfwGetCocoaWindow"); return NULL; } +#ifdef __APPLE__ return Py_BuildValue("l", (long)cocoa_window_number(glfwGetCocoaWindow(w->handle))); -} +#else + PyErr_SetString(PyExc_RuntimeError, "cocoa_window_id() is only supported on Mac"); + return NULL; #endif +} static PyObject* get_primary_selection(PYNOARG) { @@ -1236,9 +1239,7 @@ static PyMethodDef module_methods[] = { #ifndef __APPLE__ METHODB(dbus_send_notification, METH_VARARGS), #endif -#ifdef __APPLE__ METHODB(cocoa_window_id, METH_O), -#endif {"glfw_init", (PyCFunction)glfw_init, METH_VARARGS, ""}, {"glfw_terminate", (PyCFunction)glfw_terminate, METH_NOARGS, ""}, {"glfw_get_physical_dpi", (PyCFunction)glfw_get_physical_dpi, METH_NOARGS, ""},