diff --git a/kitty/boss.py b/kitty/boss.py index e1121cfbb..554b41090 100755 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -451,7 +451,7 @@ class Boss: tb = traceback.format_exc() self.show_error(_('remote_control mapping failed'), tb) - def peer_message_received(self, msg_bytes: bytes) -> Optional[bytes]: + def peer_message_received(self, msg_bytes: bytes, peer_id: int) -> Optional[bytes]: cmd_prefix = b'\x1bP@kitty-cmd' terminator = b'\x1b\\' if msg_bytes.startswith(cmd_prefix) and msg_bytes.endswith(terminator): diff --git a/kitty/child-monitor.c b/kitty/child-monitor.c index 857e446d0..36bfb38d1 100644 --- a/kitty/child-monitor.c +++ b/kitty/child-monitor.c @@ -418,13 +418,14 @@ parse_input(ChildMonitor *self) { Message *msg = msgs + i; PyObject *resp = NULL; if (msg->data) { - resp = PyObject_CallMethod(global_state.boss, "peer_message_received", "y#", msg->data, (int)msg->sz); + resp = PyObject_CallMethod(global_state.boss, "peer_message_received", "y#K", msg->data, (int)msg->sz, msg->peer_id); free(msg->data); if (!resp) PyErr_Print(); } - if (resp && PyBytes_Check(resp)) send_response(msg->peer_id, PyBytes_AS_STRING(resp), PyBytes_GET_SIZE(resp)); - else send_response(msg->peer_id, NULL, 0); - Py_CLEAR(resp); + if (resp) { + if (PyBytes_Check(resp)) send_response(msg->peer_id, PyBytes_AS_STRING(resp), PyBytes_GET_SIZE(resp)); + Py_CLEAR(resp); + } else send_response(msg->peer_id, NULL, 0); } free(msgs); msgs = NULL; }