#<- vio, msg

state = 
{
  ...
};

void >> ()
{
  msg_queue = create_queue ();

  layer = create_layer (&mp),
  {
    mp = {
           layer_proc : vio_msg_proc,
           placement : PRIMARY_LAYER,
           wm_mode : ALLOW_READ_WRITE
         }
  };

  msg_in (msg_queue, (pstruct -w reply, p_msg message) { 
                                                         dispatch (reply, &state, message);
                                                       }),
  {
    state _ = .;
  };
}
/
{
  free (&layer, &msg_queue);
}

void vio_msg_proc (pstruct -w reply, p_state -&w _, p_msg _)
{
  select (msg->message)
  {
    case WM_CHAR:
      ...
    return;

    case WM_BUTTON_1_DOWN:
      ...
    return;

    case WM_PAINT:
      ...
    return;
  }
  else
  {
    ;
  }
}