wio

a wayland wm stylised after plan9 rio - forked from git.sr.ht/~srcmpwn/wio
git clone git://src.gearsix.net/wio
Log | Files | Refs | Atom | Submodules | README | LICENSE

server.h (3207B)


      1 #ifndef _WIO_SERVER_H
      2 #define _WIO_SERVER_H
      3 #include <signal.h>
      4 #include <wayland-server.h>
      5 #include <wlr/backend.h>
      6 #include <wlr/render/wlr_renderer.h>
      7 #include <wlr/util/box.h>
      8 #include <wlr/types/wlr_cursor.h>
      9 #include <wlr/types/wlr_seat.h>
     10 #include <wlr/types/wlr_keyboard.h>
     11 #include <wlr/types/wlr_output.h>
     12 #include <wlr/types/wlr_output_layout.h>
     13 #include <wlr/types/wlr_pointer.h>
     14 #include <wlr/types/wlr_xcursor_manager.h>
     15 #include <wlr/types/wlr_xdg_shell.h>
     16 
     17 static const int window_border = 5;
     18 
     19 enum wio_input_state {
     20 	INPUT_STATE_NONE = 0,
     21 	INPUT_STATE_MENU,
     22 	INPUT_STATE_NEW_START,
     23 	INPUT_STATE_NEW_END,
     24 	INPUT_STATE_MOVE_SELECT,
     25 	INPUT_STATE_MOVE,
     26 	INPUT_STATE_RESIZE_SELECT,
     27 	INPUT_STATE_RESIZE_START,
     28 	INPUT_STATE_RESIZE_END,
     29 	INPUT_STATE_BORDER_DRAG_TOP,
     30 	INPUT_STATE_BORDER_DRAG_RIGHT,
     31 	INPUT_STATE_BORDER_DRAG_BOTTOM,
     32 	INPUT_STATE_BORDER_DRAG_LEFT,
     33 	INPUT_STATE_DELETE_SELECT,
     34 	INPUT_STATE_HIDE_SELECT,
     35 };
     36 
     37 struct wio_server {
     38 	struct wl_display *wl_display;
     39 
     40 	const char *cage, *term;
     41 
     42 	struct wlr_backend *backend;
     43 	struct wlr_cursor *cursor;
     44 	struct wlr_output_layout *output_layout;
     45 	struct wlr_renderer *renderer;
     46 	struct wlr_seat *seat;
     47 	struct wlr_xcursor_manager *cursor_mgr;
     48 	struct wlr_xdg_shell *xdg_shell;
     49 	struct wlr_layer_shell_v1 *layer_shell;
     50 
     51 	struct wl_list outputs;
     52 	struct wl_list output_configs;
     53 	struct wl_list inputs;
     54 	struct wl_list pointers;
     55 	struct wl_list keyboards;
     56 	struct wl_list views;
     57 	struct wl_list new_views;
     58 
     59 	struct wl_listener new_output;
     60 	struct wl_listener new_input;
     61 	struct wl_listener cursor_motion;
     62 	struct wl_listener cursor_motion_absolute;
     63 	struct wl_listener cursor_button;
     64 	struct wl_listener cursor_axis;
     65 	struct wl_listener cursor_frame;
     66 	struct wl_listener request_cursor;
     67 
     68 	struct wl_listener new_xdg_surface;
     69 	struct wl_listener new_layer_surface;
     70 
     71 	struct {
     72 		int x, y;
     73 		int width, height;
     74 		struct wlr_texture *active_textures[5];
     75 		struct wlr_texture *inactive_textures[5];
     76 		int selected;
     77 	} menu;
     78 
     79 	struct {
     80 		int sx, sy;
     81 		struct wio_view *view;
     82 	} interactive;
     83 
     84 	enum wio_input_state input_state;
     85 };
     86 
     87 struct wio_output {
     88 	struct wl_list link;
     89 
     90 	struct wio_server *server;
     91 	struct wlr_output *wlr_output;
     92 	struct wl_list layers[4];
     93 
     94 	struct wl_listener frame;
     95 };
     96 
     97 struct wio_output_config {
     98 	const char *name;
     99 	int x, y;
    100 	int width, height;
    101 	int scale;
    102 	enum wl_output_transform transform;
    103 	struct wl_list link;
    104 };
    105 
    106 struct wio_keyboard {
    107 	struct wl_list link;
    108 
    109 	struct wio_server *server;
    110 	struct wlr_input_device *device;
    111 
    112 	struct wl_listener modifiers;
    113 	struct wl_listener key;
    114 };
    115 
    116 struct wio_new_view {
    117 	pid_t pid;
    118 	struct wlr_box box;
    119 	struct wl_list link;
    120 };
    121 
    122 void server_new_output(struct wl_listener *listener, void *data);
    123 void server_new_input(struct wl_listener *listener, void *data);
    124 void server_cursor_motion(struct wl_listener *listener, void *data);
    125 void server_cursor_motion_absolute(struct wl_listener *listener, void *data);
    126 void server_cursor_button(struct wl_listener *listener, void *data);
    127 void server_cursor_axis(struct wl_listener *listener, void *data);
    128 void server_cursor_frame(struct wl_listener *listener, void *data);
    129 void seat_request_cursor(struct wl_listener *listener, void *data);
    130 
    131 #endif