Ejemplo n.º 1
0
void remote_ui_init(void)
{
  connected_uis = pmap_new(uint64_t)();
  // Add handler for "attach_ui"
  String method = cstr_as_string("ui_attach");
  MsgpackRpcRequestHandler handler = {.fn = remote_ui_attach, .defer = false};
  msgpack_rpc_add_method_handler(method, handler);
  method = cstr_as_string("ui_detach");
  handler.fn = remote_ui_detach;
  msgpack_rpc_add_method_handler(method, handler);
  method = cstr_as_string("ui_try_resize");
  handler.fn = remote_ui_try_resize;
  msgpack_rpc_add_method_handler(method, handler);
}

void remote_ui_disconnect(uint64_t channel_id)
{
  UI *ui = pmap_get(uint64_t)(connected_uis, channel_id);
  if (!ui) {
    return;
  }
  UIData *data = ui->data;
  // destroy pending screen updates
  api_free_array(data->buffer);
  pmap_del(uint64_t)(connected_uis, channel_id);
  xfree(ui->data);
  ui_detach(ui);
  xfree(ui);
}
Ejemplo n.º 2
0
static void ui_bridge_stop(UI *b)
{
  UI_CALL(b, stop, 1, b);
  UIBridgeData *bridge = (UIBridgeData *)b;
  uv_thread_join(&bridge->ui_thread);
  uv_mutex_destroy(&bridge->mutex);
  uv_cond_destroy(&bridge->cond);
  ui_detach(b);
  xfree(b);
}