src/goose.c
author agaric <agaric@protonmail.com>
Tue, 09 Mar 2021 07:18:07 +0000
changeset 0 5f04caa7212d
permissions -rw-r--r--
git import
0
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
     1
#define _POSIX_C_SOURCE 201710L
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
     2
#include <fcntl.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
     3
#include <getopt.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
     4
#include <pango/pangocairo.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
     5
#include <signal.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
     6
#include <stdarg.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
     7
#include <stdlib.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
     8
#include <string.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
     9
#include <sys/socket.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    10
#include <sys/wait.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    11
#include <unistd.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    12
#include "goose.h"
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    13
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    14
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    15
/* globals *******************************************************************/
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    16
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    17
struct Server   _server = {0};
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    18
int             _ipc_socket = -1;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    19
struct timespec _start_time = {-1, -1};
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    20
Verbosity       _verbosity = LOG_LAST;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    21
bool            _colored = true;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    22
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    23
const char* log_colors[] = {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    24
  [LOG_QUIET] = "",
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    25
  [LOG_ERROR] = "\x1B[1;31m",
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    26
  [LOG_INFO]  = "\x1B[1;32m",
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    27
  [LOG_DEBUG] = "\x1B[1;34m",
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    28
};
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    29
const char* log_tags[] = {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    30
  [LOG_QUIET] = "",
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    31
  [LOG_ERROR] = "[ERROR]",
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    32
  [LOG_INFO]  = "[INFO]",
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    33
  [LOG_DEBUG] = "[DEBUG]",
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    34
};
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    35
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    36
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    37
/* entry *********************************************************************/
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    38
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    39
int
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    40
main(int argc, char** argv)
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    41
{
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    42
  int a;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    43
  if (0 != (a = argue(argc, argv))) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    44
    exit(0 > a ? EXIT_FAILURE : EXIT_SUCCESS);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    45
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    46
  if (!init_all()) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    47
    exit(EXIT_FAILURE);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    48
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    49
  if (!start_server(&_server)) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    50
    quit(EXIT_FAILURE);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    51
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    52
  spawn("imv");
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    53
  run_server(&_server);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    54
  quit(EXIT_SUCCESS);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    55
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    56
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    57
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    58
int
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    59
argue(int argc, char** argv)
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    60
{
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    61
  int opt;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    62
  struct option longs[] = {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    63
    { "help", 0, NULL, 'h' },
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    64
    { "quiet", 0, NULL, 'q' },
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    65
    { "verbose", 0, NULL, 'v' },
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    66
    { "version", 0, NULL, 'V' }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    67
  };
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    68
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    69
  while ((opt = getopt_long(argc, argv, "hv", longs, NULL)) != -1) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    70
    if ('h' == opt) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    71
      help(argv[0], EXIT_SUCCESS);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    72
      return 1;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    73
    } else if ('q' == opt) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    74
      _verbosity = LOG_QUIET;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    75
    } else if ('v' == opt) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    76
      _verbosity = LOG_INFO;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    77
      // count 'v's: debug
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    78
    } else if ('V' == opt) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    79
      version(argv[0]);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    80
      return 1;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    81
    } else {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    82
      help(argv[0], EXIT_FAILURE);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    83
      return -1;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    84
    }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    85
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    86
  if (optind < argc) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    87
    help(argv[0], EXIT_FAILURE);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    88
    return -1;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    89
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    90
  return 0;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    91
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    92
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    93
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    94
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    95
help(char* me, int code)
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    96
{
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    97
  fprintf(EXIT_SUCCESS == code ? stdout : stderr,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    98
          "Usage: %s -[hv]\n\
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    99
  -h --help     show this help\n\
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   100
  -v --version  show version", me);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   101
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   102
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   103
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   104
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   105
version(char* me)
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   106
{
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   107
  fprintf(stdout, "%s 0.1", me);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   108
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   109
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   110
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   111
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   112
handle_signal(int signal)
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   113
{
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   114
  quit(EXIT_SUCCESS);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   115
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   116
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   117
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   118
/* log ***********************************************************************/
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   119
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   120
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   121
init_log()
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   122
{
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   123
  init_time();
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   124
  // TODO
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   125
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   126
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   127
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   128
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   129
init_time(void)
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   130
{
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   131
  if (0 <= _start_time.tv_sec) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   132
    return;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   133
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   134
  clock_gettime(CLOCK_MONOTONIC, &_start_time);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   135
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   136
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   137
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   138
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   139
honk(Verbosity v, const char* format, ...)
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   140
{
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   141
  va_list args;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   142
  va_start(args, format);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   143
  _honk(v, format, args);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   144
  va_end(args);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   145
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   146
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   147
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   148
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   149
honk_va(Verbosity v, const char* format, va_list args)
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   150
{
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   151
  _honk(v, format, args);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   152
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   153
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   154
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   155
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   156
_honk(Verbosity v, const char* format, va_list args)
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   157
{
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   158
  init_time();
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   159
  if (v > _verbosity) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   160
    return;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   161
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   162
  unsigned c = (LOG_LAST > v) ? v : LOG_LAST - 1;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   163
  bool colored = _colored && isatty(STDERR_FILENO);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   164
  if (colored) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   165
    fprintf(stderr, "%s", log_colors[c]);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   166
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   167
  fprintf(stderr, "%s%s ", ME, log_tags[c]);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   168
  vfprintf(stderr, format, args);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   169
  if (colored) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   170
    fprintf(stderr, "\x1B[0m");
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   171
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   172
  fprintf(stderr, "\n");
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   173
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   174
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   175
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   176
/* spawn *********************************************************************/
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   177
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   178
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   179
spawn(char* c)
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   180
{
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   181
  honk(LOG_DEBUG, "spawning child: %s", c);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   182
  int p[2];
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   183
  if (0 != pipe(p)) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   184
    honk(LOG_ERROR, "cannot create pipe for fork");
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   185
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   186
  pid_t pid = -1;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   187
  pid_t child = -1;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   188
  if (0 == (pid = fork())) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   189
    setsid();
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   190
    sigset_t set;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   191
    sigemptyset(&set);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   192
    sigprocmask(SIG_SETMASK, &set, NULL);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   193
    close(p[0]);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   194
    if (0 == (child = fork())) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   195
      close(p[1]);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   196
      honk(LOG_DEBUG, "starting imv");
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   197
      execl("/bin/sh", "/bin/sh", "-c", c, (void*)NULL);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   198
      exit(0);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   199
    }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   200
    close(p[1]);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   201
    exit(0);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   202
  } else if (0 > pid) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   203
    close(p[0]);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   204
    close(p[1]);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   205
    honk(LOG_ERROR, "cannot fork");
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   206
    return;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   207
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   208
  close(p[1]);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   209
  close(p[0]);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   210
  waitpid(pid, NULL, 0);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   211
  if (0 < child) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   212
    honk(LOG_DEBUG, "child created with pid: %d", child);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   213
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   214
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   215
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   216
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   217
/* bump **********************************************************************/
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   218
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   219
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   220
/* up ************************************************************************/
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   221
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   222
bool
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   223
init_all(void) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   224
  init_log(_verbosity);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   225
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   226
  if (!getenv("XDG_RUNTIME_DIR")) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   227
    honk(LOG_ERROR, "XDG_RUNTIME_DIR must be set");
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   228
    return false;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   229
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   230
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   231
  if (!drop_root()) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   232
    return false;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   233
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   234
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   235
  signal(SIGTERM, handle_signal);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   236
  signal(SIGINT, handle_signal);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   237
  signal(SIGPIPE, SIG_IGN);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   238
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   239
  prep_init();
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   240
  init_server();
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   241
  init_ipc(&_server);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   242
  setenv("WAYLAND_DISPLAY", _server.socket, true);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   243
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   244
  return true;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   245
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   246
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   247
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   248
bool
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   249
drop_root(void)
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   250
{
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   251
  if (getuid() != geteuid() || getgid() != getegid()) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   252
    // set gid first
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   253
    if (0 != setgid(getgid())) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   254
      honk(LOG_ERROR, "cannot drop root group");
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   255
      return false;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   256
    }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   257
    if (0 != setuid(getuid())) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   258
      honk(LOG_ERROR, "cannot drop root user");
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   259
      return false;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   260
    }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   261
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   262
  if (-1 != setgid(0) || -1 != setuid(0)) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   263
    honk(LOG_ERROR, "cannot drop root");
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   264
    return false;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   265
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   266
  return true;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   267
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   268
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   269
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   270
bool
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   271
prep_init(void)
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   272
{
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   273
  honk(LOG_DEBUG, "preparing server init");
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   274
  _server.display = wl_display_create();
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   275
  _server.event_loop = wl_display_get_event_loop(_server.display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   276
  _server.backend = wlr_backend_autocreate(_server.display, NULL);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   277
  if (!_server.backend) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   278
    honk(LOG_ERROR, "cannot create backend");
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   279
    return false;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   280
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   281
  return true;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   282
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   283
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   284
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   285
bool
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   286
init_server(void)
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   287
{
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   288
  honk(LOG_DEBUG, "initialising server");
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   289
  struct wlr_renderer* renderer = wlr_backend_get_renderer(_server.backend);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   290
  // TODO: what if no renderer?
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   291
  wlr_renderer_init_wl_display(renderer, _server.display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   292
  _server.compositor = wlr_compositor_create(_server.display, renderer);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   293
  _server.compositor_new_surface.notify = handle_compositor_new_surface;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   294
  wl_signal_add(&_server.compositor->events.new_surface,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   295
                &_server.compositor_new_surface);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   296
  _server.data_device_manager =
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   297
    wlr_data_device_manager_create(_server.display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   298
  wlr_gamma_control_manager_v1_create(_server.display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   299
  _server.new_output.notify = handle_new_output;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   300
  wl_signal_add(&_server.backend->events.new_output, &_server.new_output);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   301
  //_server.output_layout_change.notify = handle_output_layout_change;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   302
  //wlr_xdg_output_manager_v1_create(_server.display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   303
  _server.idle = wlr_idle_create(_server.display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   304
  //_server.idle_inhibit_manager = sway_
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   305
  _server.layer_shell = wlr_layer_shell_v1_create(_server.display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   306
  wl_signal_add(&_server.layer_shell->events.new_surface,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   307
                &_server.layer_shell_surface);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   308
  _server.layer_shell_surface.notify = handle_layer_shell_surface;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   309
  _server.xdg_shell = wlr_xdg_shell_create(_server.display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   310
  wl_signal_add(&_server.xdg_shell->events.new_surface,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   311
                &_server.xdg_shell_surface);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   312
  _server.xdg_shell_surface.notify = handle_xdg_shell_surface;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   313
  _server.server_decoration_manager =
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   314
    wlr_server_decoration_manager_create(_server.display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   315
  wlr_server_decoration_manager_set_default_mode(
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   316
    _server.server_decoration_manager,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   317
    WLR_SERVER_DECORATION_MANAGER_MODE_SERVER);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   318
  wl_signal_add(&_server.server_decoration_manager->events.new_decoration,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   319
                &_server.server_decoration);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   320
  _server.server_decoration.notify = handle_server_decoration;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   321
  wl_list_init(&_server.server_decorations);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   322
  _server.xdg_decoration_manager =
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   323
    wlr_xdg_decoration_manager_v1_create(_server.display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   324
  wl_signal_add(
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   325
    &_server.xdg_decoration_manager->events.new_toplevel_decoration,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   326
    &_server.xdg_decoration);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   327
  _server.xdg_decoration.notify = handle_xdg_decoration;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   328
  wl_list_init(&_server.xdg_decorations);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   329
  _server.relative_pointer_manager =
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   330
    wlr_relative_pointer_manager_v1_create(_server.display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   331
  _server.pointer_constraints =
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   332
    wlr_pointer_constraints_v1_create(_server.display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   333
  _server.pointer_constraint.notify = handle_pointer_constraint;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   334
  wl_signal_add(&_server.pointer_constraints->events.new_constraint,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   335
                &_server.pointer_constraint);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   336
  _server.presentation =
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   337
    wlr_presentation_create(_server.display, _server.backend);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   338
  _server.output_manager =
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   339
    wlr_output_manager_v1_create(_server.display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   340
  _server.output_manager_apply.notify = handle_output_manager_apply;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   341
  wl_signal_add(&_server.output_manager->events.apply,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   342
                &_server.output_manager_apply);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   343
  _server.output_manager_test.notify = handle_output_manager_test;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   344
  wl_signal_add(&_server.output_manager->events.test,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   345
                &_server.output_manager_test);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   346
  _server.output_power_manager =
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   347
    wlr_output_power_manager_v1_create(_server.display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   348
  _server.output_power_manager_set_mode.notify =
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   349
    handle_output_power_manager_set_mode;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   350
  wl_signal_add(&_server.output_power_manager->events.set_mode,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   351
                &_server.output_power_manager_set_mode);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   352
  _server.input_method_manager =
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   353
    wlr_input_method_manager_v2_create(_server.display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   354
  _server.text_input_manager =
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   355
    wlr_text_input_manager_v3_create(_server.display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   356
  _server.foreign_toplevel_manager =
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   357
    wlr_foreign_toplevel_manager_v1_create(_server.display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   358
  wlr_export_dmabuf_manager_v1_create(_server.display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   359
  wlr_screencopy_manager_v1_create(_server.display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   360
  wlr_data_control_manager_v1_create(_server.display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   361
  wlr_primary_selection_v1_device_manager_create(_server.display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   362
  wlr_viewporter_create(_server.display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   363
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   364
  char name[16];
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   365
  for (int i = 1; i <= 32; ++i) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   366
    sprintf(name, "wayland-%d", i);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   367
    if (0 <= wl_display_add_socket(_server.display, name)) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   368
      _server.socket = strdup(name);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   369
      break;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   370
    }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   371
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   372
  if (!_server.socket) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   373
    honk(LOG_ERROR, "cannot open wayland socket");
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   374
    wlr_backend_destroy(_server.backend);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   375
    return false;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   376
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   377
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   378
  _server.noop_backend = wlr_noop_backend_create(_server.display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   379
  struct wlr_output* output = wlr_noop_add_output(_server.noop_backend);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   380
  _server.headless_backend =
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   381
    wlr_headless_backend_create_with_renderer(_server.display, renderer);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   382
  if (!_server.headless_backend) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   383
    honk(LOG_INFO, "cannot create headless backend, starting without");
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   384
  } else {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   385
    wlr_multi_backend_add(_server.backend, _server.headless_backend);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   386
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   387
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   388
  if (!_server.txn_timeout_ms) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   389
    _server.txn_timeout_ms = 200;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   390
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   391
  //_server.dirty_nodes = create_list();
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   392
  //_server.input = input_manager_create(_server);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   393
  //input_manager_get_default_seat();
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   394
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   395
  return true;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   396
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   397
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   398
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   399
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   400
init_ipc(struct Server* server)
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   401
{
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   402
  _ipc_socket = socket(AF_UNIX, SOCK_STREAM, 0);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   403
  if (-1 == _ipc_socket) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   404
    honk(LOG_ERROR, "cannot create ipc socket");
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   405
    quit(EXIT_FAILURE);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   406
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   407
  if (-1 == fcntl(_ipc_socket, F_SETFD, FD_CLOEXEC)) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   408
    honk(LOG_ERROR, "cannot set CLOEXEC on ipc socket");
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   409
    quit(EXIT_FAILURE);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   410
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   411
  if (-1 == fcntl(_ipc_socket, F_SETFL, O_NONBLOCK)) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   412
    honk(LOG_ERROR, "cannot set NONBLOCK on ipc socket");
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   413
    quit(EXIT_FAILURE);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   414
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   415
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   416
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   417
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   418
bool
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   419
start_server(struct Server* server)
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   420
{
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   421
#ifdef XWAYLAND
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   422
  server->xwayland.xwayland =
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   423
    wlr_xwayland_create(server->display, server->compositor,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   424
                        false); // XWAYLAND_MODE_LAZY
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   425
  if (!server->xwayland.xwayland) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   426
    honk(LOG_ERROR, "cannot start xwayland");
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   427
    unsetenv("DISPLAY");
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   428
  } else {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   429
    wl_signal_add(&server->xwayland.xwayland->events.new_surface,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   430
                  &server->xwayland_surface);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   431
    server->xwayland_surface.notify = handle_xwayland_surface;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   432
    wl_signal_add(&server->xwayland.xwayland->events.ready,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   433
                  &server->xwayland_ready);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   434
    server->xwayland_ready.notify = handle_xwayland_ready;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   435
    setenv("DISPLAY", server->xwayland.xwayland->display_name, true);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   436
    /* xcursor configured by default seat */
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   437
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   438
#endif
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   439
  honk(LOG_INFO, "starting backend on display: %s", server->socket);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   440
  if (!wlr_backend_start(server->backend)) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   441
    honk(LOG_INFO, "cannot start backend");
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   442
    wlr_backend_destroy(server->backend);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   443
    return false;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   444
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   445
  return true;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   446
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   447
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   448
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   449
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   450
run_server(struct Server* server)
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   451
{
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   452
  honk(LOG_INFO, "running %s on display: %s", ME, server->socket);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   453
  wl_display_run(server->display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   454
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   455
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   456
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   457
/* down **********************************************************************/
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   458
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   459
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   460
quit(int code) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   461
  if (!_server.display) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   462
    // ipc client
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   463
    exit(code);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   464
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   465
  // server
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   466
  wl_display_terminate(_server.display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   467
  honk(LOG_INFO, "stopping %s on display: %s", ME, _server.socket);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   468
  fin_server(&_server);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   469
  pango_cairo_font_map_set_default(NULL);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   470
  exit(code);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   471
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   472
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   473
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   474
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   475
fin_server(struct Server* server) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   476
#ifdef XWAYLAND
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   477
  wlr_xwayland_destroy(server->xwayland.xwayland);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   478
#endif
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   479
  wl_display_destroy_clients(server->display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   480
  wl_display_destroy(server->display);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   481
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   482
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   483
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   484
/* desktop *******************************************************************/
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   485
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   486
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   487
handle_destroy(struct wl_listener* listener, void* data) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   488
  // TODO
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   489
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   490
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   491
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   492
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   493
handle_compositor_new_surface(struct wl_listener* listener, void* data) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   494
  struct wlr_surface* surface = data;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   495
  // TODO
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   496
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   497
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   498
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   499
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   500
handle_new_output(struct wl_listener* listener, void* data) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   501
  struct wlr_output* output = data;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   502
  // TODO
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   503
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   504
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   505
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   506
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   507
handle_output_layout_change(struct wl_listener* listener, void* data) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   508
  //struct Server* server =
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   509
  //  wl_container_of(listener, server, output_layout_change);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   510
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   511
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   512
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   513
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   514
handle_layer_shell_surface(struct wl_listener* listener, void* data) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   515
  struct wlr_layer_surface_v1* surface = data;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   516
  // TODO
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   517
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   518
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   519
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   520
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   521
handle_xdg_shell_surface(struct wl_listener* listener, void* data) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   522
  struct wlr_xdg_surface* surface = data;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   523
  // TODO
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   524
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   525
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   526
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   527
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   528
handle_server_decoration(struct wl_listener* listener, void* data) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   529
  struct wlr_server_decoration* decoration = data;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   530
  // TODO
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   531
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   532
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   533
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   534
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   535
handle_xdg_decoration(struct wl_listener* listener, void* data) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   536
  struct wlr_xdg_toplevel_decoration_v1* decoration = data;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   537
  // TODO
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   538
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   539
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   540
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   541
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   542
handle_pointer_constraint(struct wl_listener* listener, void* data) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   543
  struct wlr_pointer_constraint_v1* coinstraint = data;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   544
  // TODO
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   545
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   546
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   547
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   548
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   549
handle_output_manager_apply(struct wl_listener *listener, void *data) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   550
  struct wlr_output_configuration_v1* config = data;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   551
  // TODO
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   552
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   553
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   554
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   555
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   556
handle_output_manager_test(struct wl_listener *listener, void *data) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   557
  struct wlr_output_configuration_v1* config = data;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   558
  // TODO
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   559
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   560
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   561
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   562
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   563
handle_output_power_manager_set_mode(
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   564
  struct wl_listener *listener, void *data
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   565
) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   566
  struct wlr_output_power_v1_set_mode_event* event = data;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   567
  // TODO
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   568
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   569
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   570
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   571
/* xwayland ******************************************************************/
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   572
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   573
// TODO: return object
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   574
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   575
create_unmanaged(struct wlr_xwayland_surface* surface)
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   576
{
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   577
  return;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   578
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   579
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   580
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   581
// TODO: return object
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   582
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   583
create_xwayland_view(struct wlr_xwayland_surface* surface)
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   584
{
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   585
  return;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   586
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   587
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   588
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   589
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   590
handle_xwayland_surface(struct wl_listener* listener, void* data)
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   591
{
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   592
  struct wlr_xwayland_surface* surface = data;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   593
  if (surface->override_redirect) {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   594
    honk(LOG_DEBUG, "new xwayland unmanaged surface");
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   595
    create_unmanaged(surface);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   596
    return;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   597
  }
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   598
  create_xwayland_view(surface);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   599
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   600
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   601
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   602
void
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   603
handle_xwayland_ready(struct wl_listener* listener, void* data)
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   604
{
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   605
  struct Server* server = wl_container_of(listener, server, xwayland_ready);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   606
  struct Xwayland* xwayland = &server->xwayland;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   607
}
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   608