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