aboutsummaryrefslogtreecommitdiff
path: root/cross/src/runtime_requests.c
blob: cf0955c79b5e09ba7a7046f5eb3afa97de4da663 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "util.h"
#include "wl.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static int world_hot_reload_same_state_action_(world_t *world, void *ignore)
{
  (void)ignore;
  return world_hot_reload_same_state(world);
}

void montis_do_request_hot_reload(void *plugv)
{
  world_t *world = plugv;

  size_t n = world->n_requested_actions++;
  if (n < MAX_QUEUED_ACTIONS) {
    world->requested_actions[n].action = world_hot_reload_same_state_action_;
    world->requested_actions[n].arg_dtor = NULL;
  }
}

static int world_do_log(world_t *world, void *chrs)
{
  (void)world;
  char *str = chrs;
  puts(str);
  return 0;
}

void montis_do_request_log(void *plugv, const char *str)
{
  world_t *world = plugv;

  size_t n = world->n_requested_actions++;
  if (n < MAX_QUEUED_ACTIONS) {
    world->requested_actions[n].action = world_do_log;
    world->requested_actions[n].str_arg = strdup(str);
    world->requested_actions[n].arg_dtor = free;
  }
}

static int arkworld_do_exit(void *plugv, int ec)
{
  (void)plugv;
  exit(ec);
  return 0;
}

void montis_do_request_exit(void *plugv, int ec)
{
  world_t *world = plugv;

  size_t n = world->n_requested_actions++;
  if (n < MAX_QUEUED_ACTIONS) {
    world->requested_actions[n].action =
        (int (*)(world_t *, void *))arkworld_do_exit;
    world->requested_actions[n].int_arg = ec;
    world->requested_actions[n].arg_dtor = NULL;
  }
}

void *arkworld_get_seat(void *ctx)
{
  struct montis_server *server = wl_container_of(ctx, server, world);
  return server->seat;
}