mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-27 18:51:41 +02:00
Provide cocoa_window_id() on non-Mac, also
So that its import in tabs.py doesn't have to be conditional.
This commit is contained in:
@@ -1045,15 +1045,18 @@ x11_window_id(PyObject UNUSED *self, PyObject *os_wid) {
|
|||||||
return Py_BuildValue("l", (long)glfwGetX11Window(w->handle));
|
return Py_BuildValue("l", (long)glfwGetX11Window(w->handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
cocoa_window_id(PyObject UNUSED *self, PyObject *os_wid) {
|
cocoa_window_id(PyObject UNUSED *self, PyObject *os_wid) {
|
||||||
OSWindow *w = find_os_window(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 (!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; }
|
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)));
|
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
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
get_primary_selection(PYNOARG) {
|
get_primary_selection(PYNOARG) {
|
||||||
@@ -1236,9 +1239,7 @@ static PyMethodDef module_methods[] = {
|
|||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
METHODB(dbus_send_notification, METH_VARARGS),
|
METHODB(dbus_send_notification, METH_VARARGS),
|
||||||
#endif
|
#endif
|
||||||
#ifdef __APPLE__
|
|
||||||
METHODB(cocoa_window_id, METH_O),
|
METHODB(cocoa_window_id, METH_O),
|
||||||
#endif
|
|
||||||
{"glfw_init", (PyCFunction)glfw_init, METH_VARARGS, ""},
|
{"glfw_init", (PyCFunction)glfw_init, METH_VARARGS, ""},
|
||||||
{"glfw_terminate", (PyCFunction)glfw_terminate, METH_NOARGS, ""},
|
{"glfw_terminate", (PyCFunction)glfw_terminate, METH_NOARGS, ""},
|
||||||
{"glfw_get_physical_dpi", (PyCFunction)glfw_get_physical_dpi, METH_NOARGS, ""},
|
{"glfw_get_physical_dpi", (PyCFunction)glfw_get_physical_dpi, METH_NOARGS, ""},
|
||||||
|
|||||||
Reference in New Issue
Block a user