include/goose.h
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
#ifndef _GOOSE_SERVER_H
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
     2
#define _GOOSE_SERVER_H
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
     3
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
     4
#include <wlr/backend.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
     5
#include <wlr/backend/headless.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
     6
#include <wlr/backend/multi.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
     7
#include <wlr/backend/noop.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
     8
#include <wlr/backend/session.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
     9
#include <wlr/render/wlr_renderer.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    10
#include <wlr/types/wlr_data_device.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    11
#include <wlr/types/wlr_data_control_v1.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    12
#include <wlr/types/wlr_export_dmabuf_v1.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    13
#include <wlr/types/wlr_foreign_toplevel_management_v1.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    14
#include <wlr/types/wlr_gamma_control_v1.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    15
#include <wlr/types/wlr_idle.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    16
#include <wlr/types/wlr_idle_inhibit_v1.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    17
#include <wlr/types/wlr_input_method_v2.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    18
#include <wlr/types/wlr_layer_shell_v1.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    19
#include <wlr/types/wlr_output_management_v1.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    20
#include <wlr/types/wlr_output_power_management_v1.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    21
#include <wlr/types/wlr_pointer_constraints_v1.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    22
#include <wlr/types/wlr_presentation_time.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    23
#include <wlr/types/wlr_primary_selection_v1.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    24
#include <wlr/types/wlr_relative_pointer_v1.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    25
#include <wlr/types/wlr_screencopy_v1.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    26
#include <wlr/types/wlr_seat.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    27
#include <wlr/types/wlr_server_decoration.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    28
#include <wlr/types/wlr_text_input_v3.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    29
#include <wlr/types/wlr_viewporter.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    30
#include <wlr/types/wlr_xdg_shell.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    31
#include <wlr/types/wlr_xdg_decoration_v1.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    32
#ifdef XWAYLAND
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    33
#include <xcb/xcb.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    34
#include <wlr/xwayland.h>
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    35
#endif
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    36
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    37
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    38
/* macros ********************************************************************/
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    39
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    40
#define ME "goose"
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    41
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    42
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    43
/* structures ****************************************************************/
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    44
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    45
typedef enum {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    46
  LOG_QUIET = 0,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    47
  LOG_ERROR = 1,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    48
  LOG_INFO = 2,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    49
  LOG_DEBUG = 3,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    50
  LOG_LAST,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    51
} Verbosity;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    52
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    53
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    54
enum XwaylandAtom {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    55
  NET_WM_WINDOW_TYPE_NORMAL,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    56
  NET_WM_WINDOW_TYPE_DIALOG,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    57
  NET_WM_WINDOW_TYPE_UTILITY,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    58
  NET_WM_WINDOW_TYPE_TOOLBAR,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    59
  NET_WM_WINDOW_TYPE_SPLASH,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    60
  NET_WM_WINDOW_TYPE_MENU,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    61
  NET_WM_WINDOW_TYPE_DROPDOWN_MENU,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    62
  NET_WM_WINDOW_TYPE_POPUP_MENU,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    63
  NET_WM_WINDOW_TYPE_TOOLTIP,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    64
  NET_WM_WINDOW_TYPE_NOTIFICATION,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    65
  NET_WM_STATE_MODAL,
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    66
  ATOM_LAST,
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
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    70
struct Xwayland {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    71
  struct wlr_xwayland* xwayland;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    72
  struct wlr_xcursor_manager* xcursor_manager;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    73
  xcb_atom_t atoms[ATOM_LAST];
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    74
};
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    75
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    76
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    77
struct Server {
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    78
  struct wl_display*                      display;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    79
  struct wl_event_loop*                   event_loop;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    80
  const char*                             socket;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    81
  struct wlr_backend*                     backend;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    82
  struct wlr_backend*                     noop_backend;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    83
  struct wlr_backend*                     headless_backend;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    84
  struct wlr_compositor*                  compositor;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    85
  struct wl_listener                      compositor_new_surface;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    86
  struct wlr_data_device_manager*         data_device_manager;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    87
  // input_manager
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    88
  struct wl_listener                      new_output;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    89
  //struct wl_listener                      output_layout_change;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    90
  struct wlr_idle*                        idle;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    91
  //struct wlr_idle_inhibit_v1*             idle_inhibit;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    92
  struct wlr_layer_shell_v1*              layer_shell;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    93
  struct wl_listener                      layer_shell_surface;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    94
  struct wlr_xdg_shell*                   xdg_shell;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    95
  struct wl_listener                      xdg_shell_surface;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    96
  #ifdef XWAYLAND
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    97
  struct Xwayland                         xwayland;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    98
  struct wl_listener                      xwayland_surface;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
    99
  struct wl_listener                      xwayland_ready;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   100
  #endif
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   101
  struct wlr_relative_pointer_manager_v1* relative_pointer_manager;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   102
  struct wlr_server_decoration_manager*   server_decoration_manager;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   103
  struct wl_listener                      server_decoration;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   104
  struct wl_list                          server_decorations;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   105
  struct wlr_xdg_decoration_manager_v1*   xdg_decoration_manager;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   106
  struct wl_listener                      xdg_decoration;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   107
  struct wl_list                          xdg_decorations;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   108
  struct wlr_presentation*                presentation;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   109
  struct wlr_pointer_constraints_v1*      pointer_constraints;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   110
  struct wl_listener                      pointer_constraint;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   111
  struct wlr_output_manager_v1*           output_manager;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   112
  struct wl_listener                      output_manager_apply;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   113
  struct wl_listener                      output_manager_test;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   114
  struct wlr_output_power_manager_v1*     output_power_manager;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   115
  struct wl_listener                      output_power_manager_set_mode;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   116
  struct wlr_input_method_manager_v2*     input_method_manager;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   117
  struct wlr_text_input_manager_v3*       text_input_manager;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   118
  struct wlr_foreign_toplevel_manager_v1* foreign_toplevel_manager;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   119
  size_t txn_timeout_ms;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   120
  //list_t* dirty_nodes;
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   121
};
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   122
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   123
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   124
/* functions *****************************************************************/
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   125
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   126
/* program */
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   127
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   128
int argue(int argc, char** argv);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   129
void help(char* me, int code);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   130
void version(char* me);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   131
void handle_signal(int signal);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   132
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   133
/* log */
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   134
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   135
void handle_error(int signal);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   136
void init_time(void);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   137
void init_log(Verbosity v);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   138
void honk(Verbosity v, const char* format, ...);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   139
void honk_va(Verbosity v, const char* format, va_list args);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   140
void _honk(Verbosity v, const char* format, va_list args);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   141
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   142
/* spawn */
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   143
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   144
void spawn(char* child);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   145
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   146
/* bump */
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   147
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   148
/* server */
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   149
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   150
bool init_all(void);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   151
bool drop_root(void);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   152
bool prep_init(void);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   153
bool init_server(void);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   154
void init_ipc(struct Server* server);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   155
bool start_server(struct Server* server);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   156
void run_server(struct Server* server);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   157
void quit(int code);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   158
void fin_server(struct Server* server);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   159
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   160
/* desktop */
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   161
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   162
void handle_destroy(struct wl_listener* listener, void* data);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   163
void handle_compositor_new_surface(struct wl_listener* listener, void* data);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   164
void handle_new_output(struct wl_listener* listener, void* data);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   165
void handle_output_layout_change(struct wl_listener* listener, void* data);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   166
void handle_layer_shell_surface(struct wl_listener* listener, void* data);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   167
void handle_xdg_shell_surface(struct wl_listener* listener, void* data);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   168
void handle_server_decoration(struct wl_listener* listener, void* data);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   169
void handle_xdg_decoration(struct wl_listener* listener, void* data);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   170
void handle_pointer_constraint(struct wl_listener* listener, void* data);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   171
void handle_output_manager_apply(struct wl_listener *listener, void *data);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   172
void handle_output_manager_test(struct wl_listener *listener, void *data);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   173
void handle_output_power_manager_set_mode(
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   174
  struct wl_listener *listener, void *data);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   175
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   176
/* xwayland */
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   177
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   178
#ifdef XWAYLAND
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   179
void handle_xwayland_surface(struct wl_listener* listener, void* data);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   180
void handle_xwayland_ready(struct wl_listener* listener, void* data);
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   181
#endif
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   182
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   183
#endif
5f04caa7212d git import
agaric <agaric@protonmail.com>
parents:
diff changeset
   184